Kleinere Bereinigungen von Dependencies.

git-svn-id: https://svn.libreccm.org/ccm/trunk@1622 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2012-04-29 07:30:52 +00:00
parent 718e988884
commit 1b59e20837
15 changed files with 22 additions and 338 deletions

View File

@ -16,13 +16,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.arsdigita.london.util.ui;
package com.arsdigita.categorization.ui;
import com.arsdigita.categorization.ui.ObjectCategoryPicker;
import com.arsdigita.web.Web;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.bebop.PageState;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.web.Web;
/**
* Minimal implementation of abstract class ObjectCategoryPicker
*
*/
public class ApplicationCategoryPicker extends ObjectCategoryPicker {
public ApplicationCategoryPicker(String name) {

View File

@ -22,7 +22,7 @@ package com.arsdigita.core.upgrade;
import com.arsdigita.loader.CoreLoader;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.KernelExcursion;
import com.arsdigita.packaging.Program;
import com.arsdigita.util.cmd.Program;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.TransactionContext;

View File

@ -20,6 +20,7 @@ package com.arsdigita.packaging;
import java.io.PrintStream;
import java.io.PrintWriter;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;

View File

@ -73,8 +73,8 @@ public class MasterTool {
*
* @param args the command line arguments
*/
public static final void main(final String[] args) {
final PrintStream out = System.out;
final PrintStream err = System.err;
@ -125,6 +125,9 @@ public class MasterTool {
}
}
/**
*
*/
private static final class Commands {
private List m_commands = new ArrayList();

View File

@ -108,7 +108,7 @@ public class SQLRegressionGenerator {
* an exception is for the build process within ant to fail on
* error.
**/
public static final void main(String[] args) throws PDLException {
public static void main(String[] args) throws PDLException {
org.apache.log4j.BasicConfigurator.configure();

View File

@ -1,166 +0,0 @@
/*
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.templating;
import com.arsdigita.util.cmd.CommandLine;
import com.arsdigita.util.cmd.StringSwitch;
import com.arsdigita.util.cmd.BooleanSwitch;
import com.arsdigita.util.UncheckedWrapperException;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import java.util.Date;
import java.util.Map;
import java.util.HashMap;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.PatternLayout;
public class ApplyTemplates {
private static final String OPT_LOOP = "-loop";
private static final String OPT_LOG = "-log";
private static final String OPT_WARMUP = "-warmup";
private static final String OPT_VERBOSE = "-verbose";
private static final Logger s_log = Logger.getLogger(ApplyTemplates.class);
private static CommandLine s_cmd = new CommandLine(
"apply-templates",
"java com.arsdigita.templating.ApplyTemplates " +
"-loop [count] -log [loglevel] -verbose -warmup [count] Stylesheet Input Output "
);
static {
s_log.debug("Static initalizer starting...");
s_cmd.addSwitch(new StringSwitch(OPT_LOG,
"Log4j debug level",
"warn"));
s_cmd.addSwitch(new StringSwitch(OPT_LOOP,
"Number of iterations to apply xsl",
"1"));
s_cmd.addSwitch(new StringSwitch(OPT_WARMUP,
"Number of iterations to warm up on",
"0"));
s_cmd.addSwitch(new BooleanSwitch(OPT_VERBOSE,
"Display progress",
Boolean.FALSE));
s_log.debug("Static initalizer finished.");
}
public final static void main(String[] args) {
ConsoleAppender log =
new ConsoleAppender(new PatternLayout("%d{ISO8601} [%5.5t] %-5p %c{2} - %m%n"));
log.setThreshold(Level.toLevel("warn"));
BasicConfigurator.configure(log);
Map options = new HashMap();
args = s_cmd.parse(options, args);
String stylesheet = args[0];
String input = args[1];
String output = args[2];
log.setThreshold(Level.toLevel((String)options.get(OPT_LOG)));
s_log.debug("Build xml source " + new Date());
StreamSource xml = new StreamSource(input);
s_log.debug("Build xsl source " + new Date());
StreamSource xsl = new StreamSource(stylesheet);
s_log.debug("Build html dest " + new Date());
StreamResult html = new StreamResult(output);
s_log.debug("Build transformer factory " + new Date());
TransformerFactory fact = TransformerFactory.newInstance();
s_log.debug("Build templates " + new Date());
Templates templates = null;
try {
templates = fact.newTemplates(xsl);
} catch (TransformerConfigurationException tce) {
throw new UncheckedWrapperException(tce);
}
Transformer xf = null;
try {
xf = templates.newTransformer();
} catch (TransformerConfigurationException tce) {
throw new UncheckedWrapperException(tce);
}
boolean verbose = Boolean.TRUE.equals(options.get(OPT_VERBOSE));
try {
int warmup = (new Integer((String)options.get(OPT_WARMUP))).intValue();
Date start = new Date();
s_log.debug("Warming up " + start);
for (int i = 0 ; i < warmup ; i++) {
xf.setOutputProperty("encoding", "UTF-8");
xf.transform(xml,
html);
if (verbose) {
System.out.print(".");
System.out.flush();
}
}
if (warmup > 0 && verbose) {
System.out.println();
}
int loop = (new Integer((String)options.get(OPT_LOOP))).intValue();
start = new Date();
s_log.debug("Start " + start);
for (int i = 0 ; i < loop ; i++) {
xf.setOutputProperty("encoding", "UTF-8");
xf.transform(xml,
html);
if (verbose) {
System.out.print(".");
System.out.flush();
}
}
if (verbose) {
System.out.println();
}
Date end = new Date();
s_log.debug("End " + end);
long duration = end.getTime() - start.getTime();
s_log.info("Duration for " + loop + " iterations with " +
" is " + duration + " milliseconds");
} catch (TransformerException ex) {
throw new UncheckedWrapperException("cannot transform document", ex);
}
}
}

View File

@ -13,7 +13,7 @@
*
*/
package com.arsdigita.packaging;
package com.arsdigita.util.cmd;
import com.arsdigita.runtime.Startup;

View File

@ -13,7 +13,7 @@
*
*/
package com.arsdigita.packaging;
package com.arsdigita.util.cmd;
import com.arsdigita.logging.ErrorReport;

View File

@ -30,7 +30,7 @@ import org.apache.log4j.Logger;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.kernel.Group;
import com.arsdigita.packaging.Program;
import com.arsdigita.util.cmd.Program;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.SessionManager;

View File

@ -24,7 +24,7 @@ package com.arsdigita.london.util;
* @deprecated - use {@link com.arsdigita.packaging.Program}
*
*/
public abstract class Program extends com.arsdigita.packaging.Program {
public abstract class Program extends com.arsdigita.util.cmd.Program {
public Program(String name,
String version,

View File

@ -25,7 +25,7 @@ import com.arsdigita.logging.ErrorReport;
* @deprecated - use {@link com.arsdigita.packaging.ProgramErrorReport}
*
*/
public class ProgramErrorReport extends com.arsdigita.packaging.ProgramErrorReport {
public class ProgramErrorReport extends com.arsdigita.util.cmd.ProgramErrorReport {
public ProgramErrorReport(Throwable throwable,
String[] args) {

View File

@ -1,157 +0,0 @@
/*
* Copyright (C) 2005-2006 UNDP. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.arsdigita.london.util;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.web.ParameterMap;
import com.arsdigita.web.URL;
public class UrlUtil {
/**
* Processes the URL for location.
*/
public static String prepareURL(final PageState state, String location, ParameterMap params) {
return prepareURL(state, location, params, true);
}
/**
* Processes the URL for location.
*/
public static String prepareURL(PageState state, String location, ParameterMap params, boolean includeDispatcherPath) {
return prepareURL(state, location, params, includeDispatcherPath, (List) null, false);
}
/**
* Processes the URL for location.
*/
public static String prepareURL(final PageState state, String location, ParameterMap params, boolean includeDispatcherPath, String ignoreParam) {
ArrayList ignoreParams = new ArrayList();
ignoreParams.add(ignoreParam);
return prepareURL(state, location, params, includeDispatcherPath, ignoreParams, false);
}
/**
* Processes the URL for location.
*/
public static String prepareURL(final PageState state, String location,
ParameterMap params, boolean includeDispatcherPath,
List ignoreParams, boolean addPageStateParams) {
final HttpServletRequest req = state.getRequest();
final HttpServletResponse resp = state.getResponse();
if (params == null) {
params = new ParameterMap();
}
//add global state parameters
if (addPageStateParams) {
Iterator stateParams = state.getPage().getParameters();
while (stateParams.hasNext()) {
ParameterModel param = (ParameterModel) stateParams.next();
Object value = state.getValue(param);
if (value != null) {
String paramName = param.getName();
//don't replace param
if (params.getParameter(paramName) == null) {
params.setParameter(paramName, value);
}
}
}
}
params.runListeners(req);
if (includeDispatcherPath && location.startsWith("/")) {
location = URL.getDispatcherPath() + location;
}
String url;
if (location.indexOf("?") == -1) {
// m_params adds the "?" as needed.
url = resp.encodeURL(location + params);
}
else {
// The location already includes a query string, so
// append to it without including a "?".
if (location.endsWith("&")) {
url = resp.encodeURL(location + params.getQueryString());
}
else {
url = resp.encodeURL(location + "&" + params.getQueryString());
}
}
//remove ignored params
if (ignoreParams != null) {
Iterator iParsIter = ignoreParams.iterator();
while (iParsIter.hasNext()) {
String ignoreParam = (String) iParsIter.next();
url = removeParameter(url, ignoreParam);
}
}
return url;
}
/**
* Removes the URL's paremeter
*/
public static String removeParameter(String url, String parameter) {
Pattern p = Pattern.compile("[?&]" + parameter + "=[^&]*");
Matcher m = p.matcher(url);
int index = 0;
int lastIndex = 0;
int length = url.length();
StringBuffer out = new StringBuffer();
while (m.find(index)) {
index = m.start();
int end = m.end();
if (url.charAt(index) == '&') {
out.append(url.substring(lastIndex, index));
}
else {
//start with ?...
out.append(url.substring(lastIndex, index + 1));
if (length > end && url.charAt(end) == '&') {
end++;
}
}
index = end;
lastIndex = index;
}
if (url.length() > lastIndex) {
out.append(url.substring(lastIndex));
}
//remove '?' as last char
index = out.length() - 1;
if (index >= 0 && out.charAt(index) == '?') {
out.deleteCharAt(index);
}
return out.toString();
}
}

View File

@ -4,7 +4,7 @@ import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.packaging.Program;
import com.arsdigita.util.cmd.Program;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.Session;

View File

@ -6,7 +6,7 @@ import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ContentSectionCollection;
import com.arsdigita.cms.Folder;
import com.arsdigita.cms.ItemCollection;
import com.arsdigita.packaging.Program;
import com.arsdigita.util.cmd.Program;
import java.util.Arrays;
import org.apache.commons.cli.CommandLine;

View File

@ -2,7 +2,7 @@ package com.arsdigita.london.util.cmd;
import com.arsdigita.cms.contenttypes.XMLContentTypeHandler;
import com.arsdigita.london.util.Transaction;
import com.arsdigita.packaging.Program;
import com.arsdigita.util.cmd.Program;
import com.arsdigita.xml.XML;
import org.apache.commons.cli.CommandLine;