You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2004/09/16 16:18:44 UTC
svn commit: rev 46178 - incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting
Author: andreas
Date: Thu Sep 16 07:18:43 2004
New Revision: 46178
Modified:
incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/DefaultCreatorAction.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckinAction.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckoutAction.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ValidateAction.java
Log:
get rid of log4j
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/DefaultCreatorAction.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/DefaultCreatorAction.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/DefaultCreatorAction.java Thu Sep 16 07:18:43 2004
@@ -14,9 +14,6 @@
* limitations under the License.
*/
-/* $Id$ */
-
-
package org.apache.lenya.cms.cocoon.acting;
import java.io.File;
@@ -42,29 +39,24 @@
import org.apache.lenya.cms.publication.PublicationFactory;
import org.apache.lenya.cms.site.tree.DefaultSiteTree;
import org.apache.lenya.cms.site.tree.Label;
-import org.apache.log4j.Category;
-
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.io.SAXReader;
-
/**
- * DOCUMENT ME!
+ * Default creator action.
+ *
+ * @version $Id:$
*/
-public class DefaultCreatorAction extends AbstractComplementaryConfigurableAction implements Configurable {
- Category log = Category.getInstance(DefaultCreatorAction.class);
+public class DefaultCreatorAction extends AbstractComplementaryConfigurableAction implements
+ Configurable {
private String docsPath = null;
private String doctypesPath = null;
/**
- * DOCUMENT ME!
- *
- * @param conf DOCUMENT ME!
- *
- * @throws ConfigurationException DOCUMENT ME!
+ * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
*/
public void configure(Configuration conf) throws ConfigurationException {
super.configure(conf);
@@ -75,19 +67,19 @@
/**
* DOCUMENT ME!
- *
+ *
* @param redirector DOCUMENT ME!
* @param resolver DOCUMENT ME!
* @param objectModel DOCUMENT ME!
* @param src DOCUMENT ME!
* @param parameters DOCUMENT ME!
- *
+ *
* @return DOCUMENT ME!
- *
+ *
* @throws Exception DOCUMENT ME!
*/
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src,
- Parameters parameters) throws Exception {
+ Parameters parameters) throws Exception {
Publication publication = PublicationFactory.getPublication(objectModel);
// Get request object
@@ -102,21 +94,19 @@
// Get parameters
//String parentid = request.getParameter("parentid");
String parentid = request.getParameter("properties.create.parent-id");
- log.debug("properties.create.parent-id = " + parentid);
+ getLogger().debug("properties.create.parent-id = " + parentid);
//String childid = request.getParameter("childid");
String childid = request.getParameter("properties.create.child-id");
- log.debug("properties.create.child-id = " + childid);
+ getLogger().debug("properties.create.child-id = " + childid);
//String childname = request.getParameter("childname");
String childname = request.getParameter("properties.create.child-name");
- log.debug("properties.create.child-name = " + childname);
+ getLogger().debug("properties.create.child-name = " + childname);
//String childtype = request.getParameter("childtype");
String childtype = request.getParameter("properties.create.child-type");
- log.debug("properties.create.childtype = " + childtype);
-
-
+ getLogger().debug("properties.create.childtype = " + childtype);
short childType;
if (childtype.equals("branch")) {
@@ -124,22 +114,17 @@
} else if (childtype.equals("leaf")) {
childType = ParentChildCreatorInterface.LEAF_NODE;
} else {
- log.error("No such child type: " + childtype);
+ getLogger().error("No such child type: " + childtype);
return null;
}
-
-
//String doctype = request.getParameter("doctype");
String doctype = request.getParameter("properties.create.doctype");
- log.debug("poperties.create.doctype = " + doctype);
+ getLogger().debug("poperties.create.doctype = " + doctype);
//String language = request.getParameter("language");
String language = request.getParameter("properties.create.language");
- log.debug("poperties.create.language = " + language);
-
-
-
+ getLogger().debug("poperties.create.language = " + language);
if (!validate(parentid, childid, childname, childtype, doctype)) {
getLogger().error("Exception: Validation of parameters failed");
@@ -159,19 +144,24 @@
// Get creator
ParentChildCreatorInterface creator = null;
String absoluteDoctypesPath = publication.getDirectory() + File.separator + doctypesPath;
- Document doctypesDoc = new SAXReader().read("file:" + absoluteDoctypesPath +
- "doctypes.xconf");
- Attribute creator_src = (Attribute) doctypesDoc.selectSingleNode("/doctypes/doc[@type='" +
- doctype + "']/creator/@src");
+ Document doctypesDoc = new SAXReader().read("file:" + absoluteDoctypesPath
+ + "doctypes.xconf");
+ Attribute creator_src = (Attribute) doctypesDoc.selectSingleNode("/doctypes/doc[@type='"
+ + doctype + "']/creator/@src");
if (creator_src != null) {
- log.info("Creator found for \"" + doctype + "\": " + creator_src.getName() + " " + creator_src.getPath() + " " + creator_src.getValue());
+ getLogger().info(
+ "Creator found for \"" + doctype + "\": " + creator_src.getName() + " "
+ + creator_src.getPath() + " " + creator_src.getValue());
// now get the constructor that accepts the configuration
Class creatorClass = Class.forName(creator_src.getValue());
creator = (ParentChildCreatorInterface) creatorClass.newInstance();
} else {
- log.warn("No creator found for \"" + doctype + "\". DefaultBranchCreator will be taken.");
+ getLogger()
+ .warn(
+ "No creator found for \"" + doctype
+ + "\". DefaultBranchCreator will be taken.");
creator = new org.apache.lenya.cms.authoring.DefaultBranchCreator();
}
@@ -180,8 +170,8 @@
// Init creator
// "Read" the configuration from the DOM node
DefaultConfigurationBuilder defaultConfigBuilder = new DefaultConfigurationBuilder();
- Configuration[] docTypeConfigs = defaultConfigBuilder.buildFromFile(absoluteDoctypesPath +
- "doctypes.xconf").getChildren();
+ Configuration[] docTypeConfigs = defaultConfigBuilder.buildFromFile(
+ absoluteDoctypesPath + "doctypes.xconf").getChildren();
Configuration doctypeConf = null;
@@ -228,8 +218,8 @@
if (allParameters.containsKey(requestParameterName)) {
// we do not allow name clashes
- throw new ProcessingException("Name clash in request parameter " +
- "and sitemap parameter: " + requestParameterName);
+ throw new ProcessingException("Name clash in request parameter "
+ + "and sitemap parameter: " + requestParameterName);
}
allParameters.put(requestParameterName, request.getParameter(requestParameterName));
@@ -242,19 +232,19 @@
if (allParameters.containsKey(sessionAttributeName)) {
// we do not allow name clashes
- throw new ProcessingException("Name clash in session attribute " +
- "and request parameter or sitemap parameter: " + sessionAttributeName);
+ throw new ProcessingException("Name clash in session attribute "
+ + "and request parameter or sitemap parameter: " + sessionAttributeName);
}
allParameters.put(sessionAttributeName, session.getAttribute(sessionAttributeName));
}
try {
- creator.create(new File(absoluteDoctypesPath + "samples"),
- new File(publication.getDirectory(), docsPath + parentid), childid, childType,
- childname, language, allParameters);
+ creator.create(new File(absoluteDoctypesPath + "samples"), new File(publication
+ .getDirectory(), docsPath + parentid), childid, childType, childname, language,
+ allParameters);
} catch (Exception e) {
- log.error("Creator threw exception: " + e);
+ getLogger().error("Creator threw exception: ", e);
return null;
}
@@ -268,19 +258,20 @@
/**
* DOCUMENT ME!
- *
+ *
* @param parentid DOCUMENT ME!
* @param childid DOCUMENT ME!
* @param childname DOCUMENT ME!
* @param childtype DOCUMENT ME!
* @param doctype DOCUMENT ME!
- *
+ *
* @return DOCUMENT ME!
*/
public boolean validate(String parentid, String childid, String childname, String childtype,
- String doctype) {
- getLogger().debug(".validate(): parentid=" + parentid + " ; childid=" + childid +
- " ; childname=" + childname + " ; childtype=" + childtype + " ; doctype=" + doctype);
+ String doctype) {
+ getLogger().debug(
+ ".validate(): parentid=" + parentid + " ; childid=" + childid + " ; childname="
+ + childname + " ; childtype=" + childtype + " ; doctype=" + doctype);
if ((childid.indexOf(" ") >= 0) || (childid.length() == 0)) {
return false;
@@ -292,4 +283,4 @@
return true;
}
-}
+}
\ No newline at end of file
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckinAction.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckinAction.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckinAction.java Thu Sep 16 07:18:43 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: ReservedCheckinAction.java,v 1.16 2004/05/23 12:52:43 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.cocoon.acting;
@@ -27,32 +27,28 @@
import org.apache.cocoon.environment.SourceResolver;
import org.apache.lenya.cms.rc.FileReservedCheckInException;
-
/**
* Checkin document
*/
public class ReservedCheckinAction extends RevisionControllerAction {
/**
* Checkin document
- *
- * @param redirector DOCUMENT ME!
- * @param resolver DOCUMENT ME!
- * @param objectModel DOCUMENT ME!
- * @param src DOCUMENT ME!
- * @param parameters DOCUMENT ME!
- *
* @return HashMap with checkin parameters
- *
- * @throws Exception DOCUMENT ME!
+ *
+ * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector,
+ * org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String,
+ * org.apache.avalon.framework.parameters.Parameters)
*/
- public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src, Parameters parameters) throws Exception {
+ public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src,
+ Parameters parameters) throws Exception {
super.act(redirector, resolver, objectModel, src, parameters);
HashMap actionMap = new HashMap();
boolean backup = true;
- if (parameters.getParameter("backup", "true").equals("false")) backup = false;
- log.debug("Backup: " + backup);
+ if (parameters.getParameter("backup", "true").equals("false"))
+ backup = false;
+ getLogger().debug("Backup: " + backup);
try {
getRc().reservedCheckIn(getFilename(), getUsername(), backup);
@@ -76,4 +72,4 @@
return null;
}
-}
+}
\ No newline at end of file
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckoutAction.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckoutAction.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckoutAction.java Thu Sep 16 07:18:43 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: ReservedCheckoutAction.java,v 1.18 2004/05/22 19:43:41 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.cocoon.acting;
@@ -26,34 +26,27 @@
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.lenya.cms.rc.FileReservedCheckOutException;
-import org.apache.log4j.Category;
/**
* Action doing reserved checkout
*/
public class ReservedCheckoutAction extends RevisionControllerAction {
- Category log = Category.getInstance(ReservedCheckoutAction.class);
/**
* DOCUMENT ME!
- *
+ *
* @param redirector DOCUMENT ME!
* @param resolver DOCUMENT ME!
* @param objectModel DOCUMENT ME!
* @param src DOCUMENT ME!
* @param parameters DOCUMENT ME!
- *
+ *
* @return DOCUMENT ME!
- *
+ *
* @throws Exception DOCUMENT ME!
*/
- public Map act(
- Redirector redirector,
- SourceResolver resolver,
- Map objectModel,
- String src,
- Parameters parameters)
- throws Exception {
+ public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src,
+ Parameters parameters) throws Exception {
super.act(redirector, resolver, objectModel, src, parameters);
HashMap actionMap = new HashMap();
@@ -78,23 +71,19 @@
actionMap.put("user", e.getCheckOutUsername());
actionMap.put("date", e.getCheckOutDate());
getLogger().warn(
- "Document "
- + getFilename()
- + " already checked-out by "
- + e.getCheckOutUsername()
- + " since "
- + e.getCheckOutDate());
+ "Document " + getFilename() + " already checked-out by "
+ + e.getCheckOutUsername() + " since " + e.getCheckOutDate());
return actionMap;
} catch (Exception e) {
actionMap.put("exception", "genericException");
actionMap.put("filename", getFilename());
actionMap.put("message", "" + e.getMessage());
- log.error("The document " + getFilename() + " couldn't be checked out: ", e);
+ getLogger().error("The document " + getFilename() + " couldn't be checked out: ", e);
return actionMap;
}
return null;
}
-}
+}
\ No newline at end of file
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java Thu Sep 16 07:18:43 2004
@@ -15,8 +15,6 @@
*
*/
-/* $Id: RevisionControllerAction.java,v 1.35 2004/08/16 12:14:13 andreas Exp $ */
-
package org.apache.lenya.cms.cocoon.acting;
import java.io.File;
@@ -38,10 +36,13 @@
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.rc.RCEnvironment;
import org.apache.lenya.cms.rc.RevisionController;
-import org.apache.log4j.Category;
+/**
+ * Revision controller action.
+ *
+ * @version $Id:$
+ */
public class RevisionControllerAction extends AbstractAction {
- Category log = Category.getInstance(RevisionControllerAction.class);
private String rcmlDirectory = null;
private String backupDirectory = null;
@@ -50,25 +51,12 @@
private String filename = null;
/**
- * DOCUMENT ME!
- *
- * @param redirector DOCUMENT ME!
- * @param resolver DOCUMENT ME!
- * @param objectModel DOCUMENT ME!
- * @param src DOCUMENT ME!
- * @param parameters DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws Exception DOCUMENT ME!
+ * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector,
+ * org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String,
+ * org.apache.avalon.framework.parameters.Parameters)
*/
- public Map act(
- Redirector redirector,
- SourceResolver resolver,
- Map objectModel,
- String src,
- Parameters parameters)
- throws Exception {
+ public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src,
+ Parameters parameters) throws Exception {
// Get request object
Request request = ObjectModelHelper.getRequest(objectModel);
@@ -93,8 +81,8 @@
//get Parameters for RC
String publicationPath = publication.getDirectory().getCanonicalPath();
- RCEnvironment rcEnvironment =
- RCEnvironment.getInstance(publication.getServletContext().getCanonicalPath());
+ RCEnvironment rcEnvironment = RCEnvironment.getInstance(publication.getServletContext()
+ .getCanonicalPath());
rcmlDirectory = rcEnvironment.getRCMLDirectory();
rcmlDirectory = publicationPath + File.separator + rcmlDirectory;
backupDirectory = rcEnvironment.getBackupDirectory();
@@ -117,7 +105,8 @@
Identity identity = (Identity) session.getAttribute(Identity.class.getName());
getLogger().debug(".act(): Identity: " + identity);
- //FIXME: hack because of the uri for the editor bitflux. The filename cannot be get from the page-envelope
+ //FIXME: hack because of the uri for the editor bitflux. The filename cannot be get from
+ // the page-envelope
String documentid = document.getId();
int bx = documentid.lastIndexOf("-bxeng");
@@ -135,16 +124,15 @@
if (lang > 0 && langLength + lang < l) {
language = documentid.substring(lang + 1, lang + langLength);
- documentid =
- documentid.substring(0, lang)
+ documentid = documentid.substring(0, lang)
+ documentid.substring(lang + langLength, l - bxLength);
}
}
DocumentBuilder builder = publication.getDocumentBuilder();
- String srcUrl =
- builder.buildCanonicalUrl(publication, document.getArea(), documentid, language);
+ String srcUrl = builder.buildCanonicalUrl(publication, document.getArea(), documentid,
+ language);
Document srcDoc = builder.buildDocument(publication, srcUrl);
File newFile = srcDoc.getFile();
filename = newFile.getCanonicalPath();
@@ -154,7 +142,7 @@
}
filename = filename.substring(publicationPath.length());
- log.debug("Filename: " + filename);
+ getLogger().debug("Filename: " + filename);
username = null;
@@ -199,4 +187,4 @@
return username;
}
-}
+}
\ No newline at end of file
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ValidateAction.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ValidateAction.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ValidateAction.java Thu Sep 16 07:18:43 2004
@@ -39,7 +39,6 @@
import org.apache.cocoon.environment.SourceResolver;
import org.apache.lenya.xml.DocumentHelper;
import org.apache.lenya.xml.RelaxNG;
-import org.apache.log4j.Category;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@@ -47,24 +46,18 @@
* Action to validate an xml document with relax ng schema.
*/
public class ValidateAction extends AbstractConfigurableAction {
- Category log = Category.getInstance(ValidateAction.class);
- /** (non-Javadoc)
- * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector, org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
- **/
- public Map act(
- Redirector redirector,
- SourceResolver resolver,
- Map objectModel,
- String source,
- Parameters parameters)
- throws Exception {
+ /**
+ * (non-Javadoc)
+ * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector,
+ * org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String,
+ * org.apache.avalon.framework.parameters.Parameters)
+ */
+ public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source,
+ Parameters parameters) throws Exception {
File sitemap = new File(new URL(resolver.resolveURI("").getURI()).getFile());
- File schema =
- new File(
- sitemap.getAbsolutePath()
- + File.separator
- + parameters.getParameter("schema"));
+ File schema = new File(sitemap.getAbsolutePath() + File.separator
+ + parameters.getParameter("schema"));
getLogger().debug("schema: " + schema.getAbsolutePath());
Request request = ObjectModelHelper.getRequest(objectModel);
@@ -74,7 +67,7 @@
return null;
}
if (!schema.isFile()) {
- log.warn("No such schema: " + schema.getAbsolutePath());
+ getLogger().warn("No such schema: " + schema.getAbsolutePath());
return null;
}
@@ -88,7 +81,7 @@
return hmap;
}
} catch (Exception e) {
- // FIXME: could it be that the tmpFile is not removed in the case of
+ // FIXME: could it be that the tmpFile is not removed in the case of
// an exception? Exceptions happen everytime the validation fails
getLogger().error("RELAX NG Validation failed: " + e.getMessage());
HashMap hmap = new HashMap();
@@ -110,15 +103,21 @@
}
- private File createTmpFile(String content)
- throws SAXException, ParserConfigurationException, TransformerException, IOException {
+ private File createTmpFile(String content) throws SAXException, ParserConfigurationException,
+ TransformerException, IOException {
File tmpFile = File.createTempFile("OneformEditor", null);
getLogger().debug("file: " + tmpFile.getAbsolutePath());
//write POST content in temporary file
- FileWriter fileWriter = new FileWriter(tmpFile);
- fileWriter.write(content);
- fileWriter.close();
+ FileWriter fileWriter = null;
+ try {
+ fileWriter = new FileWriter(tmpFile);
+ fileWriter.write(content);
+ } finally {
+ if (fileWriter != null) {
+ fileWriter.close();
+ }
+ }
Document document = null;
DocumentBuilderFactory parserFactory = DocumentBuilderFactory.newInstance();
@@ -133,4 +132,4 @@
return tmpFile;
}
-}
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org