svn commit: r741654 [7/9] - in /lenya/trunk: org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/ org.apache.lenya.core.ac/src/main/java/org/apache/lenya/cms/ac/ org.apache.lenya.core.ac/src/main/java/org/apache/lenya/cms/cocoon/acting/ org...
[email protected] Fri, 06 Feb 2009 17:55:33 -0000
Newsgroups
gmane.comp.cms.lenya.cvs
Message-ID
<[email protected] >
Modified: lenya/trunk/org.apache.lenya.module.export/src/main/java/org/apache/lenya/cms/export/Import.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.export/src/main/java/org/apache/lenya/cms/export/Import.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.export/src/main/java/org/apache/lenya/cms/export/Import.java (original)
+++ lenya/trunk/org.apache.lenya.module.export/src/main/java/org/apache/lenya/cms/export/Import.java Fri Feb 6 17:55:28 2009
@@ -19,11 +19,13 @@
import java.io.File;
+import org.apache.excalibur.source.SourceResolver;
import org.apache.lenya.cms.cocoon.source.SourceUtil;
import org.apache.lenya.cms.publication.Area;
+import org.apache.lenya.cms.publication.DocumentManager;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.PublicationUtil;
+import org.apache.lenya.cms.publication.ResourceTypeResolver;
import org.apache.lenya.cms.publication.URLInformation;
import org.apache.lenya.cms.usecase.AbstractUsecase;
@@ -31,18 +33,21 @@
* Import content.
*/
public class Import extends AbstractUsecase {
+
+ private SourceResolver sourceResolver;
+ private DocumentManager documentManager;
+ private ResourceTypeResolver resourceTypeResolver;
protected void initParameters() {
super.initParameters();
-
- Publication publication;
+ String pubId = new URLInformation(getSourceURL()).getPublicationId();
+ Publication pub;
try {
- publication = PublicationUtil.getPublicationFromUrl(this.manager, getDocumentFactory(),
- getSourceURL());
+ pub = getDocumentFactory().getPublication(pubId);
} catch (PublicationException e) {
throw new RuntimeException(e);
}
- String path = getExampleContentPath(publication);
+ String path = getExampleContentPath(pub);
if (!new File(path).exists()) {
path = getExampleContentPath(getDefaultPub());
}
@@ -91,7 +96,7 @@
String path = getParameterAsString("path");
String baseUri = "file://" + path;
String sitetreeUri = baseUri + "/sitetree.xml";
- if (!SourceUtil.exists(sitetreeUri, this.manager)) {
+ if (!SourceUtil.exists(sitetreeUri, getSourceResolver())) {
addErrorMessage("The sitetree file does not exist in this directory.");
}
}
@@ -99,8 +104,44 @@
protected void doExecute() throws Exception {
super.doExecute();
String path = getParameterAsString("path");
- Importer importer = new Importer(this.manager, getLogger());
+ Importer importer = new Importer(getLogger());
+ importer.setDocumentManager(getDocumentManager());
+ importer.setResourceTypeResolver(getResourceTypeResolver());
+ importer.setSourceResolver(getSourceResolver());
importer.importContent(getDefaultPub(), getArea(), path);
}
+ protected SourceResolver getSourceResolver() {
+ return sourceResolver;
+ }
+
+ /**
+ * TODO: Bean wiring
+ */
+ public void setSourceResolver(SourceResolver sourceResolver) {
+ this.sourceResolver = sourceResolver;
+ }
+
+ protected ResourceTypeResolver getResourceTypeResolver() {
+ return resourceTypeResolver;
+ }
+
+ /**
+ * TODO: Bean wiring
+ */
+ public void setResourceTypeResolver(ResourceTypeResolver resourceTypeResolver) {
+ this.resourceTypeResolver = resourceTypeResolver;
+ }
+
+ protected DocumentManager getDocumentManager() {
+ return documentManager;
+ }
+
+ /**
+ * TODO: Bean wiring
+ */
+ public void setDocumentManager(DocumentManager documentManager) {
+ this.documentManager = documentManager;
+ }
+
}
Modified: lenya/trunk/org.apache.lenya.module.export/src/main/java/org/apache/lenya/cms/export/Importer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.export/src/main/java/org/apache/lenya/cms/export/Importer.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.export/src/main/java/org/apache/lenya/cms/export/Importer.java (original)
+++ lenya/trunk/org.apache.lenya.module.export/src/main/java/org/apache/lenya/cms/export/Importer.java Fri Feb 6 17:55:28 2009
@@ -17,8 +17,6 @@
*/
package org.apache.lenya.cms.export;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.commons.logging.Log;
import org.apache.excalibur.source.SourceResolver;
@@ -30,6 +28,7 @@
import org.apache.lenya.cms.publication.DocumentManager;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.publication.ResourceTypeResolver;
import org.apache.lenya.cms.site.SiteNode;
import org.apache.lenya.cms.site.SiteStructure;
import org.apache.lenya.cms.site.tree.DefaultSiteTree;
@@ -42,16 +41,17 @@
*/
public class Importer extends AbstractLogEnabled {
- private ServiceManager manager;
+ private SourceResolver sourceResolver;
+ private ResourceTypeResolver resourceTypeResolver;
+ private DocumentManager documentManager;
/**
* Ctor.
* @param manager The service manager.
* @param logger The logger.
*/
- public Importer(ServiceManager manager, Log logger) {
+ public Importer(Log logger) {
setLogger(logger);
- this.manager = manager;
}
/**
@@ -77,7 +77,7 @@
String baseUri = "file://" + path;
String sitetreeUri = baseUri + "/sitetree.xml";
- org.w3c.dom.Document xml = SourceUtil.readDOM(sitetreeUri, this.manager);
+ org.w3c.dom.Document xml = SourceUtil.readDOM(sitetreeUri, getSourceResolver());
NamespaceHelper helper = new NamespaceHelper(DefaultSiteTree.NAMESPACE_URI, "", xml);
Element siteElement = xml.getDocumentElement();
@@ -86,6 +86,10 @@
convertLinks(srcPub, area);
}
+ protected SourceResolver getSourceResolver() {
+ return this.sourceResolver;
+ }
+
protected void importElement(Area area, NamespaceHelper helper, Element element,
String baseUri, String parentPath) {
String path = parentPath + "/" + element.getAttribute("id");
@@ -111,13 +115,9 @@
String contentUri = baseUri + path + "/index_" + language;
String metaUri = contentUri + ".meta";
- DocumentManager docManager = null;
- ServiceSelector selector = null;
- ResourceType resourceType = null;
- SourceResolver resolver = null;
try {
- org.w3c.dom.Document xml = SourceUtil.readDOM(metaUri, this.manager);
+ org.w3c.dom.Document xml = SourceUtil.readDOM(metaUri, getSourceResolver());
NamespaceHelper helper = new NamespaceHelper(
"http://apache.org/cocoon/lenya/page-envelope/1.0", "", xml);
Element metaElement = helper.getFirstChild(xml.getDocumentElement(), "meta");
@@ -128,23 +128,19 @@
Element mimeTypeElement = helper.getFirstChild(internalElement, "mimeType");
String mimeType = DocumentHelper.getSimpleElementText(mimeTypeElement);
- selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE + "Selector");
- resourceType = (ResourceType) selector.select(resourceTypeName);
-
- docManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
+ ResourceType resourceType = getResourceTypeResolver().getResourceType(resourceTypeName);
Document newDoc;
SiteStructure site = area.getSite();
if (!site.contains(path) || site.getNode(path).getLanguages().length == 0) {
- newDoc = docManager.add(area.getPublication().getFactory(), resourceType,
+ newDoc = getDocumentManager().add(area.getPublication().getFactory(), resourceType,
contentUri, area.getPublication(), area.getName(), path, language, "xml",
navigationTitle, visibleInNav);
newDoc.setMimeType(mimeType);
} else {
SiteNode node = site.getNode(path);
Document doc = node.getLink(node.getLanguages()[0]).getDocument();
- newDoc = docManager.addVersion(doc, area.getName(), language, true);
- resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
- SourceUtil.copy(resolver, contentUri, newDoc.getOutputStream());
+ newDoc = getDocumentManager().addVersion(doc, area.getName(), language, true);
+ SourceUtil.copy(getSourceResolver(), contentUri, newDoc.getOutputStream());
newDoc.getLink().setLabel(navigationTitle);
}
@@ -163,16 +159,6 @@
} catch (Exception e) {
throw new RuntimeException(e);
- } finally {
- if (docManager != null) {
- this.manager.release(docManager);
- }
- if (selector != null) {
- this.manager.release(selector);
- }
- if (resolver != null) {
- this.manager.release(resolver);
- }
}
}
@@ -187,9 +173,29 @@
protected void convertLinks(Publication srcPub, Area area) {
Document[] docs = area.getDocuments();
for (int i = 0; i < docs.length; i++) {
- LinkConverter converter = new LinkConverter(this.manager, getLogger());
+ LinkConverter converter = new LinkConverter(getLogger());
converter.convertUrlsToUuids(srcPub, docs[i], false);
}
}
+ protected ResourceTypeResolver getResourceTypeResolver() {
+ return resourceTypeResolver;
+ }
+
+ public void setResourceTypeResolver(ResourceTypeResolver resourceTypeResolver) {
+ this.resourceTypeResolver = resourceTypeResolver;
+ }
+
+ protected DocumentManager getDocumentManager() {
+ return documentManager;
+ }
+
+ public void setDocumentManager(DocumentManager documentManager) {
+ this.documentManager = documentManager;
+ }
+
+ public void setSourceResolver(SourceResolver sourceResolver) {
+ this.sourceResolver = sourceResolver;
+ }
+
}
Modified: lenya/trunk/org.apache.lenya.module.fckeditor/src/main/java/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.fckeditor/src/main/java/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.fckeditor/src/main/java/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java (original)
+++ lenya/trunk/org.apache.lenya.module.fckeditor/src/main/java/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java Fri Feb 6 17:55:28 2009
@@ -27,15 +27,15 @@
import java.io.Writer;
import java.util.Arrays;
import java.util.Properties;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stream.StreamResult;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.OutputKeys;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
-import org.apache.cocoon.components.ContextHelper;
-import org.apache.cocoon.environment.Request;
import org.apache.cocoon.xml.XMLUtils;
import org.apache.excalibur.source.ModifiableSource;
import org.apache.excalibur.source.Source;
@@ -54,8 +54,8 @@
import org.apache.lenya.xml.Schema;
import org.apache.lenya.xml.ValidationUtil;
import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
import org.w3c.tidy.Tidy;
+import org.xml.sax.SAXException;
/**
* Fckeditor Usecase
@@ -65,6 +65,8 @@
public static final String TIDY_CONFIG = "tidyConfig";
public static final String XSLT_CLEAN_FORMAT = "xslt-clean";
+
+ private SourceResolver sourceResolver;
/**
* @see org.apache.lenya.cms.usecase.AbstractUsecase#getNodesToLock()
@@ -80,13 +82,13 @@
protected void initParameters() {
super.initParameters();
- Request request = ContextHelper.getRequest(this.context);
+ HttpServletRequest request = getRequest();
String requesturi = request.getRequestURI();
setParameter("requesturi", requesturi);
URLInformation info = new URLInformation(getSourceURL());
String pubId = info.getPublicationId();
- LinkRewriter rewriter = new OutgoingLinkRewriter(this.manager, getSession(),
- getSourceURL(), request.isSecure(), false, false);
+ LinkRewriter rewriter = new OutgoingLinkRewriter(getSession(), getSourceURL(), request
+ .isSecure(), false, false);
setParameter("proxyUrl", rewriter.rewrite("/" + pubId));
}
@@ -97,8 +99,7 @@
protected void doCheckPreconditions() throws Exception {
super.doCheckPreconditions();
- UsecaseWorkflowHelper.checkWorkflow(this.manager, this, getEvent(), getSourceDocument(),
- getLogger());
+ UsecaseWorkflowHelper.checkWorkflow(this, getEvent(), getSourceDocument(), getLogger());
}
/**
@@ -114,7 +115,7 @@
}
// Aggregate content
- Request request = ContextHelper.getRequest(this.context);
+ HttpServletRequest request = getRequest();
String encoding = request.getCharacterEncoding();
String content = "<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n"
+ addNamespaces(namespaces, getParameterAsString("content"));
@@ -130,13 +131,12 @@
* @throws Exception if an error occurs.
*/
protected void saveDocument(String encoding, String content) throws Exception {
- SourceResolver resolver = null;
+ SourceResolver resolver = getSourceResolver();
Source indexSource = null;
Source tidySource = null;
ModifiableSource xsltSource = null;
Properties properties = null;
try {
- resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
saveXMLFile(encoding, content, getSourceDocument().getOutputStream());
Document xmlDoc = null;
@@ -228,7 +228,7 @@
saveXMLFile(encoding, content, getSourceDocument().getOutputStream());
}
// Convert URLs back to UUIDs. convert() does a save
- LinkConverter converter = new LinkConverter(this.manager, getLogger());
+ LinkConverter converter = new LinkConverter(getLogger());
converter.convertUrlsToUuids(getSourceDocument(), false);
xmlDoc = DocumentHelper.readDocument(getSourceDocument().getInputStream());
@@ -237,11 +237,10 @@
ResourceType resourceType = getSourceDocument().getResourceType();
Schema schema = resourceType.getSchema();
- ValidationUtil
- .validate(this.manager, xmlDoc, schema, new UsecaseErrorHandler(this));
+ ValidationUtil.validate(xmlDoc, schema, new UsecaseErrorHandler(this));
if (!hasErrors()) {
- WorkflowUtil.invoke(this.manager, getLogger(), getSourceDocument(), getEvent());
+ WorkflowUtil.invoke(getLogger(), getSourceDocument(), getEvent());
}
}
@@ -256,7 +255,6 @@
if (xsltSource != null) {
resolver.release(xsltSource);
}
- this.manager.release(resolver);
}
}
}
@@ -326,4 +324,15 @@
return "edit";
}
+ /**
+ * TODO: Bean wiring
+ */
+ public void setSourceResolver(SourceResolver sourceResolver) {
+ this.sourceResolver = sourceResolver;
+ }
+
+ public SourceResolver getSourceResolver() {
+ return sourceResolver;
+ }
+
}
Modified: lenya/trunk/org.apache.lenya.module.lenyadoc/pom.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.lenyadoc/pom.xml?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.lenyadoc/pom.xml (original)
+++ lenya/trunk/org.apache.lenya.module.lenyadoc/pom.xml Fri Feb 6 17:55:28 2009
@@ -16,6 +16,10 @@
<name>Apache Lenya Module Lenyadoc</name>
<dependencies>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.avalon.framework</groupId>
<artifactId>avalon-framework-api</artifactId>
</dependency>
Modified: lenya/trunk/org.apache.lenya.module.lenyadoc/src/main/java/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.lenyadoc/src/main/java/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.lenyadoc/src/main/java/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java (original)
+++ lenya/trunk/org.apache.lenya.module.lenyadoc/src/main/java/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java Fri Feb 6 17:55:28 2009
@@ -21,19 +21,12 @@
import java.net.MalformedURLException;
import java.util.Map;
-import org.apache.avalon.framework.configuration.Configurable;
+import javax.servlet.http.HttpServletRequest;
+
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.components.ContextHelper;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
@@ -44,9 +37,10 @@
import org.apache.lenya.cms.publication.DocumentUtil;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.PublicationUtil;
import org.apache.lenya.cms.publication.URLInformation;
+import org.apache.lenya.cms.repository.NodeFactory;
import org.apache.lenya.cms.repository.RepositoryException;
+import org.apache.lenya.cms.repository.RepositoryManager;
import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.util.ServletHelper;
@@ -67,28 +61,12 @@
* @version $Id:$
* @deprecated Use <code>lenya-document</code> instead (see {@link org.apache.lenya.cms.cocoon.source.DocumentSourceFactory}.
*/
-public class LenyaDocSourceFactory extends AbstractLogEnabled implements SourceFactory, ThreadSafe,
- Contextualizable, Serviceable, Configurable {
+public class LenyaDocSourceFactory extends AbstractLogEnabled implements SourceFactory {
protected static final String SCHEME = "lenyadoc";
-
- private Context context;
- private ServiceManager manager;
-
- /**
- * Used for resolving the object model.
- * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
- */
- public void contextualize(Context context) throws ContextException {
- this.context = context;
- }
-
- /**
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
- }
+
+ private RepositoryManager repositoryManager;
+ private NodeFactory nodeFactory;
/**
* @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
@@ -123,9 +101,16 @@
+ "]");
}
- Map objectModel = ContextHelper.getObjectModel(this.context);
- Request request = ObjectModelHelper.getRequest(objectModel);
- DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
+ ProcessInfoProvider processInfoProvider = (ProcessInfoProvider) WebAppContextUtils
+ .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+ HttpServletRequest request = processInfoProvider.getRequest();
+ Session session;
+ try {
+ session = RepositoryUtil.getSession(getRepositoryManager(), request);
+ } catch (RepositoryException e) {
+ throw new RuntimeException(e);
+ }
+ DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
start = end + 1;
@@ -162,7 +147,8 @@
end += 1;
// Relative: get publication id and area from page envelope
try {
- pub = PublicationUtil.getPublication(this.manager, objectModel);
+ String id = new URLInformation(ServletHelper.getWebappURI(request)).getPublicationId();
+ pub = factory.getPublication(id);
} catch (PublicationException e) {
throw new SourceException("Error getting publication id / area from page envelope ["
+ location + "]");
@@ -191,13 +177,6 @@
start = end + 1;
uuid = location.substring(start);
- Session session;
- try {
- session = RepositoryUtil.getSession(this.manager, request);
- } catch (RepositoryException e1) {
- throw new RuntimeException(e1);
- }
-
if (getLogger().isDebugEnabled()) {
getLogger().debug("Creating repository source for URI [" + location + "]");
}
@@ -217,7 +196,7 @@
getLogger().debug("Creating repository source for URI [" + lenyaURL + "]");
}
- return new RepositorySource(manager, lenyaURL, session, getLogger());
+ return new RepositorySource(getNodeFactory(), lenyaURL, session, getLogger());
}
/**
@@ -226,4 +205,20 @@
public void release(Source source) {
// Source will be released by delegated source factory.
}
+
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
+ }
+
+ public void setNodeFactory(NodeFactory nodeFactory) {
+ this.nodeFactory = nodeFactory;
+ }
+
+ public NodeFactory getNodeFactory() {
+ return nodeFactory;
+ }
}
\ No newline at end of file
Modified: lenya/trunk/org.apache.lenya.module.linkcheck/pom.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.linkcheck/pom.xml?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.linkcheck/pom.xml (original)
+++ lenya/trunk/org.apache.lenya.module.linkcheck/pom.xml Fri Feb 6 17:55:28 2009
@@ -16,6 +16,10 @@
<name>Apache Lenya Module Link Check</name>
<dependencies>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.avalon.framework</groupId>
<artifactId>avalon-framework-api</artifactId>
</dependency>
Modified: lenya/trunk/org.apache.lenya.module.linkcheck/src/main/java/org/apache/lenya/cms/cocoon/generation/LinkStatusGenerator.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.linkcheck/src/main/java/org/apache/lenya/cms/cocoon/generation/LinkStatusGenerator.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.linkcheck/src/main/java/org/apache/lenya/cms/cocoon/generation/LinkStatusGenerator.java (original)
+++ lenya/trunk/org.apache.lenya.module.linkcheck/src/main/java/org/apache/lenya/cms/cocoon/generation/LinkStatusGenerator.java Fri Feb 6 17:55:28 2009
@@ -32,6 +32,7 @@
import org.apache.lenya.cms.publication.DocumentFactory;
import org.apache.lenya.cms.publication.DocumentUtil;
import org.apache.lenya.cms.repository.RepositoryException;
+import org.apache.lenya.cms.repository.RepositoryManager;
import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
import org.apache.regexp.RE;
@@ -197,6 +198,7 @@
protected Source inputSource;
String src;
private DocumentFactory identityMap;
+ private RepositoryManager repositoryManager;
/**
* Stores links to process and the referrer links
@@ -320,11 +322,11 @@
Request request = ObjectModelHelper.getRequest(objectModel);
Session session;
try {
- session = RepositoryUtil.getSession(this.manager, request);
+ session = RepositoryUtil.getSession(getRepositoryManager(), request);
} catch (RepositoryException e) {
throw new ProcessingException(e);
}
- this.identityMap = DocumentUtil.createDocumentFactory(this.manager, session);
+ this.identityMap = DocumentUtil.createDocumentFactory(session);
super.setup(resolver, objectModel, src, par);
this.src = src;
@@ -700,4 +702,12 @@
this.attributes = null;
super.recycle();
}
+
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
+ }
}
Modified: lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/cocoon/components/search/Index.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/cocoon/components/search/Index.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/cocoon/components/search/Index.java (original)
+++ lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/cocoon/components/search/Index.java Fri Feb 6 17:55:28 2009
@@ -22,12 +22,11 @@
import java.util.Date;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.components.search.components.AnalyzerManager;
import org.apache.cocoon.components.search.components.Indexer;
import org.apache.cocoon.components.search.fieldmodel.DateFieldDefinition;
import org.apache.cocoon.components.search.fieldmodel.FieldDefinition;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -35,6 +34,7 @@
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
+import org.springframework.web.context.WebApplicationContext;
/**
* Index Class
@@ -73,19 +73,16 @@
* is the indexer working (not released)
*/
private boolean indexer_busy;
-
+
/**
* Indexer Role name
*/
private String indexer_role;
- private ServiceManager manager;
-
/**
* Create a lucene document
*
- * @param uid
- * String the document uid
+ * @param uid String the document uid
* @return Document a empty document
*/
public Document createDocument(String uid) {
@@ -100,17 +97,13 @@
/**
* create a lucene field
*
- * @param fieldname
- * String fieldname (must existed in the index structure)
- * @param value
- * String value
+ * @param fieldname String fieldname (must existed in the index structure)
+ * @param value String value
*/
- public Field createField(String fieldname, String value)
- throws IndexException {
+ public Field createField(String fieldname, String value) throws IndexException {
FieldDefinition f = structure.getFieldDef(fieldname);
if (f == null) {
- throw new IndexException("Field with the name: " + fieldname
- + " doesn't exist");
+ throw new IndexException("Field with the name: " + fieldname + " doesn't exist");
}
return f.createLField(value);
}
@@ -118,22 +111,17 @@
/**
* create a lucene field for date value
*
- * @param fieldname
- * String fieldname (must existed in the index structure)
- * @param value
- * String value
- */
- public Field createField(String fieldname, Date value)
- throws IndexException {
- DateFieldDefinition f = (DateFieldDefinition) structure
- .getFieldDef(fieldname);
+ * @param fieldname String fieldname (must existed in the index structure)
+ * @param value String value
+ */
+ public Field createField(String fieldname, Date value) throws IndexException {
+ DateFieldDefinition f = (DateFieldDefinition) structure.getFieldDef(fieldname);
if (f == null) {
- throw new IndexException("Field with the name: " + fieldname
- + " doesn't exist");
+ throw new IndexException("Field with the name: " + fieldname + " doesn't exist");
}
return f.createLField(value);
}
-
+
/**
* get the indexer of the index
*
@@ -152,18 +140,17 @@
}
if (indexer_busy) {
- throw new IndexException(
- "Timeout to access to the indexer (the indexer is indexing)");
+ throw new IndexException("Timeout to access to the indexer (the indexer is indexing)");
}
AnalyzerManager analyzerM = null;
try {
indexer_busy = true;
- Indexer indexer = (Indexer) this.manager.lookup(indexer_role);
+ WebApplicationContext context = WebAppContextUtils.getCurrentWebApplicationContext();
+ Indexer indexer = (Indexer) context.getBean(indexer_role);
// update maybe the analyzer
- analyzerM = (AnalyzerManager) this.manager
- .lookup(AnalyzerManager.ROLE);
+ analyzerM = (AnalyzerManager) context.getBean(AnalyzerManager.ROLE);
String analyzerId = getDefaultAnalyzerID();
if (analyzerId != null) {
@@ -173,14 +160,8 @@
indexer.setIndex(directory);
return indexer;
- } catch (ServiceException ex1) {
- throw new IndexException(ex1);
} catch (ConfigurationException ex2) {
throw new IndexException(ex2);
- } finally {
- if (analyzerM != null) {
- manager.release(analyzerM);
- }
}
}
@@ -191,7 +172,6 @@
*/
public synchronized void releaseIndexer(Indexer indexer) {
if (indexer != null) {
- this.manager.release(indexer);
indexer_busy = false;
}
notifyAll();
@@ -209,8 +189,7 @@
/**
* Set the index ID
*
- * @param id
- * index ID
+ * @param id index ID
*/
public void setID(String id) {
this.id = id;
@@ -228,8 +207,7 @@
/**
* set the default Analyzer
*
- * @param defaultAnalyzerID
- * the id of the default Analyzer
+ * @param defaultAnalyzerID the id of the default Analyzer
*/
public void setDefaultAnalyzerID(String defaultAnalyzerID) {
this.defaultAnalyzer = defaultAnalyzerID;
@@ -247,17 +225,12 @@
/**
* Set the index structure
*
- * @param structure
- * IndexStructure
+ * @param structure IndexStructure
*/
public void setStructure(IndexStructure structure) {
this.structure = structure;
}
- public void setManager(ServiceManager manager) {
- this.manager = manager;
- }
-
/**
* get the lucene directory
*
@@ -270,8 +243,7 @@
/**
* Set the lucene Directory
*
- * @param dir
- * lucene Directory
+ * @param dir lucene Directory
* @return success or not
* @throws IOException
*/
@@ -297,8 +269,7 @@
/**
* Set the index path directory
*
- * @param path
- * String
+ * @param path String
* @throws IOException
*/
public boolean setDirectory(String path) throws IOException {
Modified: lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java (original)
+++ lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java Fri Feb 6 17:55:28 2009
@@ -22,13 +22,11 @@
import java.util.HashMap;
import java.util.Map;
-import org.apache.avalon.framework.configuration.Configurable;
+import javax.servlet.http.HttpServletRequest;
+
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.search.Index;
import org.apache.cocoon.components.search.IndexException;
import org.apache.cocoon.components.search.IndexStructure;
@@ -37,18 +35,22 @@
import org.apache.cocoon.components.search.fieldmodel.DateFieldDefinition;
import org.apache.cocoon.components.search.fieldmodel.FieldDefinition;
import org.apache.cocoon.components.search.utils.SourceHelper;
-import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceResolver;
import org.apache.excalibur.source.SourceUtil;
-import org.apache.lenya.cms.cocoon.components.context.ContextUtility;
import org.apache.lenya.cms.metadata.MetaDataException;
import org.apache.lenya.cms.publication.DocumentFactory;
import org.apache.lenya.cms.publication.DocumentUtil;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationManager;
+import org.apache.lenya.cms.repository.RepositoryException;
+import org.apache.lenya.cms.repository.RepositoryManager;
+import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.modules.lucene.MetaDataFieldRegistry;
+import org.springframework.web.context.WebApplicationContext;
/**
* Index Manager Component. Configure and Manage the differents indexes.
@@ -56,8 +58,7 @@
* @author Maisonneuve Nicolas
* @version 1.0
*/
-public class IndexManagerImpl extends AbstractLogEnabled implements IndexManager, Serviceable,
- ThreadSafe, Configurable {
+public class IndexManagerImpl extends AbstractLogEnabled implements IndexManager {
/**
* indexer element
@@ -107,8 +108,7 @@
/**
* type of the field: "text, "keyword", "date" (see
*
- * @see org.apache.cocoon.components.search.fieldmodel.FieldDefinition
- * class)
+ * @see org.apache.cocoon.components.search.fieldmodel.FieldDefinition class)
*/
public static final String TYPE_ATTRIBUTE = "type";
@@ -128,8 +128,8 @@
public static final String INDEX_CONF_FILE = "search/lucene_index.xml";
/**
- * check the config file each time the getIndex is called to update if
- * necessary the configuration
+ * check the config file each time the getIndex is called to update if necessary the
+ * configuration
*/
// public static final String CHECK_ATTRIBUTE = "check";
/**
@@ -137,15 +137,15 @@
*/
// public static final String CONFIG_ATTRIBUTE = "config";
/**
- * Check or not the configuration file (automatic update if the file is
- * changed)
+ * Check or not the configuration file (automatic update if the file is changed)
*/
// private boolean check;
/**
* Index configuration file
*/
- // private Source configfile;
- private ServiceManager manager;
+
+ private RepositoryManager repositoryManager;
+ private SourceResolver sourceResolver;
private Map indexMap;
@@ -194,7 +194,9 @@
/*
* (non-Javadoc)
*
- * @see org.apache.cocoon.components.search.components.IndexManager#addIndex(org.apache.cocoon.components.search.Index)
+ * @see
+ * org.apache.cocoon.components.search.components.IndexManager#addIndex(org.apache.cocoon.components
+ * .search.Index)
*/
public void addIndex(Index base) {
this.indexes().put(base.getID(), base);
@@ -213,43 +215,32 @@
// configure the index manager:
// now check all publications and add their indexes:
- PublicationManager pubManager = null;
- SourceResolver resolver = null;
Source confSource = null;
- ContextUtility util = null;
try {
- util = (ContextUtility) this.manager.lookup(ContextUtility.ROLE);
- Request request = util.getRequest();
- DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
- pubManager = (PublicationManager) this.manager.lookup(PublicationManager.ROLE);
- Publication[] publications = pubManager.getPublications(factory);
- resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+ ProcessInfoProvider process = (ProcessInfoProvider) WebAppContextUtils
+ .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+ HttpServletRequest request = process.getRequest();
+ Session session = RepositoryUtil.getSession(this.repositoryManager, request);
+ DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
+
+ Publication[] publications = factory.getPublications();
for (int i = 0; i < publications.length; i++) {
String uri = "context://" + Publication.PUBLICATION_PREFIX_URI + "/"
+ publications[i].getId() + "/" + Publication.CONFIGURATION_PATH + "/"
+ INDEX_CONF_FILE;
- confSource = resolver.resolveURI(uri);
+ confSource = this.sourceResolver.resolveURI(uri);
if (confSource.exists()) {
addIndexes(confSource);
}
}
} catch (IOException e) {
throw new RuntimeException("Config file error", e);
- } catch (ServiceException e) {
- throw new RuntimeException("PublicationManager lookup error", e);
+ } catch (RepositoryException e) {
+ throw new RuntimeException("Repository access error", e);
} finally {
- if (pubManager != null) {
- this.manager.release(pubManager);
- }
- if (resolver != null) {
- if (confSource != null) {
- resolver.release(confSource);
- }
- this.manager.release(resolver);
- }
- if (util != null) {
- this.manager.release(util);
+ if (confSource != null) {
+ this.sourceResolver.release(confSource);
}
}
@@ -259,7 +250,9 @@
/*
* (non-Javadoc)
*
- * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+ * @see
+ * org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework
+ * .configuration.Configuration)
*/
public void configure(Configuration configuration) throws ConfigurationException {
this.indexerRole = configuration.getChild(INDEXER_ELEMENT).getAttribute(
@@ -294,8 +287,10 @@
throw new ConfigurationException("no index is defined !");
}
try {
- analyzerManager = (AnalyzerManager) this.manager.lookup(AnalyzerManager.ROLE);
- registry = (MetaDataFieldRegistry) this.manager.lookup(MetaDataFieldRegistry.ROLE);
+ // TODO: replace with bean wiring
+ WebApplicationContext context = WebAppContextUtils.getCurrentWebApplicationContext();
+ analyzerManager = (AnalyzerManager) context.getBean(AnalyzerManager.ROLE);
+ registry = (MetaDataFieldRegistry) context.getBean(MetaDataFieldRegistry.ROLE);
// configure each index
for (int i = 0; i < confs.length; i++) {
@@ -313,12 +308,13 @@
IndexStructure docdecl = new IndexStructure();
addMetaDataFieldDefinitions(registry, docdecl);
-
+
FieldDefinition uuidDef = FieldDefinition.create("uuid", FieldDefinition.KEYWORD);
uuidDef.setStore(true);
docdecl.addFieldDef(uuidDef);
- FieldDefinition langDef = FieldDefinition.create("language", FieldDefinition.KEYWORD);
+ FieldDefinition langDef = FieldDefinition.create("language",
+ FieldDefinition.KEYWORD);
langDef.setStore(true);
docdecl.addFieldDef(langDef);
@@ -374,7 +370,6 @@
index.setDefaultAnalyzerID(analyzerid);
}
index.setStructure(docdecl);
- index.setManager(manager);
this.addIndex(index);
this.getLogger()
@@ -384,13 +379,6 @@
throw new ConfigurationException("AnalyzerManager lookup error", e);
} catch (Exception e) {
throw new ConfigurationException(e.getMessage(), e);
- } finally {
- if (analyzerManager != null) {
- this.manager.release(analyzerManager);
- }
- if (registry != null) {
- this.manager.release(registry);
- }
}
}
@@ -413,36 +401,32 @@
* @throws Exception if an error occurs.
*/
public String getServletContextPath() throws Exception {
- SourceResolver resolver = null;
Source source = null;
try {
- resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
- source = resolver.resolveURI("context:///");
+ source = this.sourceResolver.resolveURI("context:///");
return SourceUtil.getFile(source).getCanonicalPath();
} finally {
- if (resolver != null) {
- if (source != null) {
- resolver.release(source);
- }
- this.manager.release(resolver);
+ if (source != null) {
+ this.sourceResolver.release(source);
}
}
}
/*
* (non-Javadoc)
+ *
* @see org.apache.cocoon.components.search.components.IndexManager#getIndex()
*/
public Index[] getIndex() {
return (Index[]) this.indexes().values().toArray(new Index[indexes().size()]);
}
- /*
- * (non-Javadoc)
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public void setSourceResolver(SourceResolver sourceResolver) {
+ this.sourceResolver = sourceResolver;
}
}
Modified: lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/cocoon/transformation/LuceneIndexTransformer2.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/cocoon/transformation/LuceneIndexTransformer2.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/cocoon/transformation/LuceneIndexTransformer2.java (original)
+++ lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/cocoon/transformation/LuceneIndexTransformer2.java Fri Feb 6 17:55:28 2009
@@ -17,11 +17,12 @@
package org.apache.cocoon.transformation;
import java.io.IOException;
-import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Map;
+import javax.servlet.http.HttpSession;
+
import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
@@ -40,11 +41,12 @@
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.processing.ProcessInfoProvider;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.lenya.ac.Identifiable;
+import org.apache.lenya.ac.Identity;
import org.apache.lenya.ac.User;
import org.apache.lenya.ac.UserManager;
-import org.apache.lenya.cms.repository.RepositoryUtil;
-import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.modules.lucene.MetaDataFieldRegistry;
import org.apache.lenya.notification.Message;
import org.apache.lenya.notification.NotificationUtil;
@@ -657,8 +659,11 @@
closeIndexer();
try {
- Session session = RepositoryUtil.getSession(this.manager, this.request);
- User sender = session.getIdentity().getUser();
+ ProcessInfoProvider process = (ProcessInfoProvider) WebAppContextUtils
+ .getCurrentWebApplicationContext().getBean(ProcessInfoProvider.ROLE);
+ HttpSession session = process.getRequest().getSession();
+ Identity identity = (Identity) session.getAttribute(Identity.class.getName());
+ User sender = identity.getUser();
UserManager userManager = (UserManager) sender.getItemManager();
User recipient = userManager.getUser(this.notificationRecipient);
Identifiable[] recipients = { recipient };
Modified: lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/lenya/cms/lucene/IndexDocument.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/lenya/cms/lucene/IndexDocument.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/lenya/cms/lucene/IndexDocument.java (original)
+++ lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/lenya/cms/lucene/IndexDocument.java Fri Feb 6 17:55:28 2009
@@ -24,13 +24,14 @@
import org.apache.lenya.cms.repository.Node;
import org.apache.lenya.cms.usecase.DocumentUsecase;
import org.apache.lenya.cms.usecase.UsecaseException;
-import org.xml.sax.InputSource;
/**
* Usecase to maintain lucene index.
*/
public class IndexDocument extends DocumentUsecase {
+ private SourceResolver sourceResolver;
+
/**
* The URI to copy the document source from.
*/
@@ -46,7 +47,7 @@
*/
protected void doExecute() throws Exception {
super.doExecute();
- SourceResolver resolver = null;
+ SourceResolver resolver = getSourceResolver();
Source source = null;
String action = super.getParameterAsString(INDEX_ACTION);
@@ -55,25 +56,25 @@
try {
String[] formats = getSourceDocument().getResourceType().getFormats();
if (!Arrays.asList(formats).contains("luceneIndex")) {
- getLogger().warn("Document ["+getSourceDocument()+"] is not being indexed because resource type [" + getSourceDocument().getResourceType().getName() + "] does not support indexing!");
+ getLogger().warn(
+ "Document [" + getSourceDocument()
+ + "] is not being indexed because resource type ["
+ + getSourceDocument().getResourceType().getName()
+ + "] does not support indexing!");
return;
}
- resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
if (action.equals(INDEX)) {
// index
source = resolver.resolveURI("cocoon://modules/lucene/index-" + area + ".xml");
- InputSource xmlInputSource = org.apache.cocoon.components.source.SourceUtil.getInputSource(source);
+ org.apache.cocoon.components.source.SourceUtil.getInputSource(source);
} else if (action.equals(DELETE)) {
// delete
source = resolver.resolveURI("cocoon://modules/lucene/delete-" + area + ".xml");
- InputSource xmlInputSource = org.apache.cocoon.components.source.SourceUtil.getInputSource(source);
+ org.apache.cocoon.components.source.SourceUtil.getInputSource(source);
}
} finally {
- if (resolver != null) {
- if (source != null) {
- resolver.release(source);
- }
- this.manager.release(resolver);
+ if (source != null) {
+ resolver.release(source);
}
}
}
@@ -83,12 +84,24 @@
*/
protected Node[] getNodesToLock() throws UsecaseException {
if (getLogger().isDebugEnabled()) {
- getLogger().debug("IndexDocument::getObjectsToLock() called on source document ["
- + getSourceDocument() + "]");
+ getLogger().debug(
+ "IndexDocument::getObjectsToLock() called on source document ["
+ + getSourceDocument() + "]");
}
Node[] objects = { getSourceDocument().getRepositoryNode() };
return objects;
}
+ /**
+ * TODO: Bean wiring
+ */
+ public void setSourceResolver(SourceResolver sourceResolver) {
+ this.sourceResolver = sourceResolver;
+ }
+
+ public SourceResolver getSourceResolver() {
+ return sourceResolver;
+ }
+
}
Modified: lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/lenya/cms/lucene/IndexSite.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/lenya/cms/lucene/IndexSite.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/lenya/cms/lucene/IndexSite.java (original)
+++ lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/lenya/cms/lucene/IndexSite.java Fri Feb 6 17:55:28 2009
@@ -29,6 +29,8 @@
*/
public class IndexSite extends AbstractUsecase {
+ private IndexUpdater indexUpdater;
+
public void doExecute() throws Exception {
String url = getSourceURL();
URLInformation info = new URLInformation(url);
@@ -40,24 +42,27 @@
Document[] docs = area.getDocuments();
- IndexUpdater updater = null;
- try {
- updater = (IndexUpdater) this.manager.lookup(IndexUpdater.ROLE);
- for (int i = 0; i < docs.length; i++) {
- try {
- updater.index(getSession(), docs[i].getResourceType(), pubId, area.getName(),
- docs[i].getUUID(), docs[i].getLanguage());
- } catch (Exception e) {
- String message = "Error indexing document [" + docs[i].getPath() + ":"
- + docs[i].getLanguage() + "], UUID=" + docs[i].getUUID();
- addErrorMessage(e + ", see logfiles for more information.");
- getLogger().error(message, e);
- }
- }
- } finally {
- if (updater != null) {
- this.manager.release(updater);
+ for (int i = 0; i < docs.length; i++) {
+ try {
+ getIndexUpdater().index(getSession(), docs[i].getResourceType(), pubId,
+ area.getName(), docs[i].getUUID(), docs[i].getLanguage());
+ } catch (Exception e) {
+ String message = "Error indexing document [" + docs[i].getPath() + ":"
+ + docs[i].getLanguage() + "], UUID=" + docs[i].getUUID();
+ addErrorMessage(e + ", see logfiles for more information.");
+ getLogger().error(message, e);
}
}
}
+
+ /**
+ * TODO: Bean wiring
+ */
+ public void setIndexUpdater(IndexUpdater indexUpdater) {
+ this.indexUpdater = indexUpdater;
+ }
+
+ public IndexUpdater getIndexUpdater() {
+ return indexUpdater;
+ }
}
Modified: lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/lenya/cms/lucene/IndexUpdaterImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/lenya/cms/lucene/IndexUpdaterImpl.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/lenya/cms/lucene/IndexUpdaterImpl.java (original)
+++ lenya/trunk/org.apache.lenya.module.lucene/src/main/java/org/apache/lenya/cms/lucene/IndexUpdaterImpl.java Fri Feb 6 17:55:28 2009
@@ -115,7 +115,7 @@
public void index(Session session, ResourceType resourceType, String pubId, String area,
String uuid, String language) throws IndexException {
- DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
+ DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
try {
Publication pub = factory.getPublication(pubId);
Area areaObj = pub.getArea(area);
Modified: lenya/trunk/org.apache.lenya.module.menubar/src/main/java/org/apache/lenya/modules/menubar/MenuFilterTransformer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.menubar/src/main/java/org/apache/lenya/modules/menubar/MenuFilterTransformer.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.menubar/src/main/java/org/apache/lenya/modules/menubar/MenuFilterTransformer.java (original)
+++ lenya/trunk/org.apache.lenya.module.menubar/src/main/java/org/apache/lenya/modules/menubar/MenuFilterTransformer.java Fri Feb 6 17:55:28 2009
@@ -34,6 +34,9 @@
import org.apache.lenya.cms.publication.DocumentUtil;
import org.apache.lenya.cms.publication.URLInformation;
import org.apache.lenya.cms.repository.RepositoryException;
+import org.apache.lenya.cms.repository.RepositoryManager;
+import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.cms.usecase.Usecase;
import org.apache.lenya.cms.usecase.UsecaseResolver;
import org.apache.lenya.cms.usecase.gui.Tab;
@@ -51,6 +54,8 @@
private static final String ATTR_AREAS = "areas";
private static final String ATTR_RESOURCE_TYPES = "resourceTypes";
private Set attributeHandlers;
+
+ private RepositoryManager repositoryManager;
public MenuFilterTransformer() {
this.defaultNamespaceURI = NAMESPACE;
@@ -72,7 +77,8 @@
this.attributeHandlers.add(new AttributeHandler(ATTR_AREAS, area));
try {
- DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
+ Session session = RepositoryUtil.getSession(this.repositoryManager, request);
+ DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
String resourceType = factory.isDocument(webappUri) ?
resourceType = factory.getFromURL(webappUri).getResourceType().getName()
: null;
@@ -145,6 +151,14 @@
}
}
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
+ }
+
/**
* Searches an attribute value (space-separated list) for a certain value.
*/
Modified: lenya/trunk/org.apache.lenya.module.navigation/pom.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.navigation/pom.xml?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.navigation/pom.xml (original)
+++ lenya/trunk/org.apache.lenya.module.navigation/pom.xml Fri Feb 6 17:55:28 2009
@@ -16,6 +16,10 @@
<name>Apache Lenya Module Navigation</name>
<dependencies>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.lenya</groupId>
<artifactId>lenya-core-api</artifactId>
</dependency>
Modified: lenya/trunk/org.apache.lenya.module.navigation/src/main/java/org/apache/lenya/modules/navigation/SiteFragmentGenerator.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.navigation/src/main/java/org/apache/lenya/modules/navigation/SiteFragmentGenerator.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.navigation/src/main/java/org/apache/lenya/modules/navigation/SiteFragmentGenerator.java (original)
+++ lenya/trunk/org.apache.lenya.module.navigation/src/main/java/org/apache/lenya/modules/navigation/SiteFragmentGenerator.java Fri Feb 6 17:55:28 2009
@@ -21,9 +21,6 @@
import java.io.Serializable;
import java.util.Map;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
@@ -37,6 +34,9 @@
import org.apache.lenya.cms.publication.DocumentFactory;
import org.apache.lenya.cms.publication.DocumentUtil;
import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.repository.RepositoryManager;
+import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.cms.site.Link;
import org.apache.lenya.cms.site.SiteException;
import org.apache.lenya.cms.site.SiteNode;
@@ -81,6 +81,8 @@
private String selectorClass;
private String path;
private String selectorPath;
+
+ private RepositoryManager repositoryManager;
public void setup(org.apache.cocoon.environment.SourceResolver resolver, Map objectModel,
String src, Parameters params) throws ProcessingException, SAXException, IOException {
@@ -96,7 +98,8 @@
this.path = params.getParameter(PARAM_PATH);
this.selectorPath = params.getParameter(PARAM_SELECTOR_PATH, "");
- DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
+ Session session = RepositoryUtil.getSession(this.repositoryManager, request);
+ DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
Publication pub = factory.getPublication(pubId);
this.site = pub.getArea(area).getSite();
@@ -235,4 +238,12 @@
this.selectorClass = params.getParameter(PARAM_SELECTOR);
}
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
+ }
+
}
Modified: lenya/trunk/org.apache.lenya.module.navigation/src/main/java/org/apache/lenya/modules/navigation/SiteMetaDataTransformer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.navigation/src/main/java/org/apache/lenya/modules/navigation/SiteMetaDataTransformer.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.navigation/src/main/java/org/apache/lenya/modules/navigation/SiteMetaDataTransformer.java (original)
+++ lenya/trunk/org.apache.lenya.module.navigation/src/main/java/org/apache/lenya/modules/navigation/SiteMetaDataTransformer.java Fri Feb 6 17:55:28 2009
@@ -39,6 +39,9 @@
import org.apache.lenya.cms.publication.DocumentUtil;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.URLInformation;
+import org.apache.lenya.cms.repository.RepositoryManager;
+import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.util.ServletHelper;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@@ -52,16 +55,18 @@
private Area area;
private LinkResolver linkResolver;
+ private RepositoryManager repositoryManager;
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters params)
throws ProcessingException, SAXException, IOException {
super.setup(resolver, objectModel, src, params);
Request req = ObjectModelHelper.getRequest(objectModel);
- DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
- String webappUrl = ServletHelper.getWebappURI(req);
- URLInformation info = new URLInformation(webappUrl);
try {
+ Session session = RepositoryUtil.getSession(this.repositoryManager, req);
+ DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
+ String webappUrl = ServletHelper.getWebappURI(req);
+ URLInformation info = new URLInformation(webappUrl);
Publication pub = factory.getPublication(info.getPublicationId());
this.area = pub.getArea(info.getArea());
} catch (Exception e) {
@@ -157,4 +162,12 @@
return link.getUri();
}
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
+ }
+
}
Modified: lenya/trunk/org.apache.lenya.module.notification/src/main/java/org/apache/lenya/inbox/InboxModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.notification/src/main/java/org/apache/lenya/inbox/InboxModule.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.notification/src/main/java/org/apache/lenya/inbox/InboxModule.java (original)
+++ lenya/trunk/org.apache.lenya.module.notification/src/main/java/org/apache/lenya/inbox/InboxModule.java Fri Feb 6 17:55:28 2009
@@ -21,13 +21,11 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
import org.apache.cocoon.components.modules.input.AbstractInputModule;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.lenya.ac.User;
+import org.apache.lenya.cms.repository.RepositoryManager;
import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
@@ -43,21 +41,21 @@
* string</li>
* </ul>
*/
-public class InboxModule extends AbstractInputModule implements Serviceable {
+public class InboxModule extends AbstractInputModule {
protected static final String NEW_MESSAGE_COUNT = "newMessageCount";
- protected ServiceManager manager;
+
+ private InboxManager inboxManager;
+ private RepositoryManager repositoryManager;
public Object getAttribute(String name, Configuration modeConf, Map objectModel)
throws ConfigurationException {
Object value = null;
if (name.equals(NEW_MESSAGE_COUNT)) {
- InboxManager inboxManager = null;
try {
- inboxManager = (InboxManager) this.manager.lookup(InboxManager.ROLE);
Request request = ObjectModelHelper.getRequest(objectModel);
- Session session = RepositoryUtil.getSession(manager, request);
+ Session session = RepositoryUtil.getSession(this.repositoryManager, request);
User user = session.getIdentity().getUser();
if (user == null) {
return "0";
@@ -75,10 +73,6 @@
} catch (Exception e) {
throw new ConfigurationException("Attribute [" + name + "]: ", e);
- } finally {
- if (inboxManager != null) {
- this.manager.release(inboxManager);
- }
}
}
else {
@@ -87,8 +81,20 @@
return value;
}
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
+ public void setInboxManager(InboxManager inboxManager) {
+ this.inboxManager = inboxManager;
+ }
+
+ public InboxManager getInboxManager() {
+ return inboxManager;
+ }
+
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
}
}
Modified: lenya/trunk/org.apache.lenya.module.notification/src/main/java/org/apache/lenya/inbox/usecases/AbstractInboxUsecase.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.notification/src/main/java/org/apache/lenya/inbox/usecases/AbstractInboxUsecase.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.notification/src/main/java/org/apache/lenya/inbox/usecases/AbstractInboxUsecase.java (original)
+++ lenya/trunk/org.apache.lenya.module.notification/src/main/java/org/apache/lenya/inbox/usecases/AbstractInboxUsecase.java Fri Feb 6 17:55:28 2009
@@ -28,6 +28,8 @@
protected static final String PARAM_USER = "user";
protected static final String PARAM_INBOX = "inbox";
+
+ private InboxManager inboxManager;
protected void prepareView() throws Exception {
super.prepareView();
@@ -40,20 +42,25 @@
protected org.apache.lenya.inbox.Inbox getInbox() {
org.apache.lenya.inbox.Inbox inbox = (org.apache.lenya.inbox.Inbox) getParameter(PARAM_INBOX);
if (inbox == null) {
- InboxManager inboxManager = null;
try {
- inboxManager = (InboxManager) this.manager.lookup(InboxManager.ROLE);
- inbox = inboxManager.getInbox(getUser());
+ inbox = getInboxManager().getInbox(getUser());
setParameter(PARAM_INBOX, inbox);
} catch (Exception e) {
throw new RuntimeException(e);
- } finally {
- if (inboxManager != null) {
- this.manager.release(inboxManager);
- }
}
}
return inbox;
}
+ /**
+ * TODO: Bean wiring
+ */
+ public void setInboxManager(InboxManager inboxManager) {
+ this.inboxManager = inboxManager;
+ }
+
+ public InboxManager getInboxManager() {
+ return inboxManager;
+ }
+
}
Modified: lenya/trunk/org.apache.lenya.module.notification/src/main/java/org/apache/lenya/inbox/usecases/SendMessage.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.notification/src/main/java/org/apache/lenya/inbox/usecases/SendMessage.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.notification/src/main/java/org/apache/lenya/inbox/usecases/SendMessage.java (original)
+++ lenya/trunk/org.apache.lenya.module.notification/src/main/java/org/apache/lenya/inbox/usecases/SendMessage.java Fri Feb 6 17:55:28 2009
@@ -22,7 +22,7 @@
import org.apache.lenya.ac.UserManager;
import org.apache.lenya.inbox.InboxMessage;
import org.apache.lenya.notification.Message;
-import org.apache.lenya.notification.NotificationUtil;
+import org.apache.lenya.notification.Notifier;
import org.apache.lenya.util.Assert;
/**
@@ -35,6 +35,8 @@
protected static final String PARAM_RECIPIENT = "recipient";
protected static final String PARAM_USER = "user";
protected static final String PARAM_REPLY_TO = "replyTo";
+
+ private Notifier notifier;
protected void prepareView() throws Exception {
super.prepareView();
@@ -108,8 +110,19 @@
Message message = new Message(subject, new String[0], body, new String[0], sender,
recipients);
- NotificationUtil.notify(this.manager, message);
+ getNotifier().notify(message);
}
+ /**
+ * TODO: Bean wiring
+ */
+ public void setNotifier(Notifier notifier) {
+ this.notifier = notifier;
+ }
+
+ public Notifier getNotifier() {
+ return notifier;
+ }
+
}
Modified: lenya/trunk/org.apache.lenya.module.opendocument/src/main/java/org/apache/lenya/cms/site/usecases/UploadOpenDocument.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.opendocument/src/main/java/org/apache/lenya/cms/site/usecases/UploadOpenDocument.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.opendocument/src/main/java/org/apache/lenya/cms/site/usecases/UploadOpenDocument.java (original)
+++ lenya/trunk/org.apache.lenya.module.opendocument/src/main/java/org/apache/lenya/cms/site/usecases/UploadOpenDocument.java Fri Feb 6 17:55:28 2009
@@ -33,7 +33,7 @@
protected void doCheckPreconditions() throws Exception {
super.doCheckPreconditions();
- if (!ServletHelper.isUploadEnabled(manager)) {
+ if (!ServletHelper.isUploadEnabled()) {
addErrorMessage("Upload is not enabled. Please check local.build.properties!");
}
Document doc = getSourceDocument();
Modified: lenya/trunk/org.apache.lenya.module.resource/src/main/java/org/apache/lenya/cms/publication/ResourceWrapper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.resource/src/main/java/org/apache/lenya/cms/publication/ResourceWrapper.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.resource/src/main/java/org/apache/lenya/cms/publication/ResourceWrapper.java (original)
+++ lenya/trunk/org.apache.lenya.module.resource/src/main/java/org/apache/lenya/cms/publication/ResourceWrapper.java Fri Feb 6 17:55:28 2009
@@ -27,8 +27,6 @@
import javax.imageio.ImageIO;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.servlet.multipart.Part;
import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.commons.io.IOUtils;
@@ -46,20 +44,20 @@
public class ResourceWrapper extends AbstractLogEnabled {
protected static final String MEDIA_METADATA_NAMESPACE = "http://apache.org/lenya/metadata/media/1.0";
- private ServiceManager manager;
private Document document;
+ private SourceResolver sourceResolver;
private static final String MIME_IMAGE_PJPEG = "image/pjpeg";
private static final String MIME_IMAGE_JPEG = "image/jpeg";
/**
* @param document The document to wrap.
- * @param manager The service manager.
+ * @param resolver The source resolver.
* @param logger The logger.
*/
- public ResourceWrapper(Document document, ServiceManager manager, Log logger) {
+ public ResourceWrapper(Document document, SourceResolver resolver, Log logger) {
this.document = document;
- this.manager = manager;
+ this.sourceResolver = resolver;
}
protected Document getDocument() {
@@ -70,12 +68,11 @@
* @param file The part to write.
* @throws IOException
* @throws MetaDataException
- * @throws ServiceException
* @throws RepositoryException
* @throws DocumentException
*/
- public void write(Part file) throws IOException, MetaDataException, ServiceException,
- RepositoryException, DocumentException {
+ public void write(Part file) throws IOException, MetaDataException, RepositoryException,
+ DocumentException {
String mimeType = file.getMimeType();
String fileName = file.getFileName();
@@ -88,30 +85,22 @@
/**
* Writes the content of the resource from a source.
* @param sourceUri The source URI.
- * @throws ServiceException
* @throws MalformedURLException
* @throws IOException
* @throws RepositoryException
* @throws DocumentException
* @throws MetaDataException
*/
- public void write(String sourceUri) throws ServiceException, MalformedURLException,
- IOException, RepositoryException, DocumentException, MetaDataException {
- SourceResolver resolver = null;
+ public void write(String sourceUri) throws MalformedURLException, IOException,
+ RepositoryException, DocumentException, MetaDataException {
TraversableSource source = null;
try {
- resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
- source = (TraversableSource) resolver.resolveURI(sourceUri);
- write(source.getInputStream(),
- source.getMimeType(),
- source.getName(),
- source.getContentLength());
+ source = (TraversableSource) this.sourceResolver.resolveURI(sourceUri);
+ write(source.getInputStream(), source.getMimeType(), source.getName(), source
+ .getContentLength());
} finally {
- if (resolver != null) {
- if (source != null) {
- resolver.release(source);
- }
- this.manager.release(resolver);
+ if (source != null) {
+ this.sourceResolver.release(source);
}
}
}
@@ -124,14 +113,13 @@
* @param fileSize The file size.
* @throws IOException
* @throws MetaDataException
- * @throws ServiceException
* @throws MalformedURLException
* @throws RepositoryException
* @throws DocumentException
*/
public void write(InputStream inputStream, String mimeType, String fileName, long fileSize)
- throws IOException, MetaDataException, ServiceException, MalformedURLException,
- RepositoryException, DocumentException {
+ throws IOException, MetaDataException, MalformedURLException, RepositoryException,
+ DocumentException {
final ByteArrayOutputStream sourceBos = new ByteArrayOutputStream();
IOUtils.copy(inputStream, sourceBos);
@@ -159,17 +147,17 @@
if (getLogger().isDebugEnabled())
getLogger().debug("Resource::addResource() done.");
}
-
+
/**
* Updates the image width and height depending on the content, if possible.
*/
public void updateImageDimensions() {
Document doc = getDocument();
try {
- updateImageDimensions(doc.getMimeType(), doc.getInputStream(), doc.getMetaData(MEDIA_METADATA_NAMESPACE),
- doc.toString() + " (" + doc.getPath() + ")");
- }
- catch (Exception e) {
+ updateImageDimensions(doc.getMimeType(), doc.getInputStream(), doc
+ .getMetaData(MEDIA_METADATA_NAMESPACE), doc.toString() + " (" + doc.getPath()
+ + ")");
+ } catch (Exception e) {
throw new RuntimeException(e);
}
}
@@ -182,14 +170,13 @@
updateImageDimensions(mimeType, stream, customMeta, fileName);
}
- protected void updateImageDimensions(String mimeType, InputStream stream, MetaData customMeta, String logInfo)
- throws IOException, MetaDataException {
+ protected void updateImageDimensions(String mimeType, InputStream stream, MetaData customMeta,
+ String logInfo) throws IOException, MetaDataException {
if (canReadMimeType(mimeType)) {
BufferedImage input = ImageIO.read(stream);
if (input == null) {
getLogger().warn("Couln't read image information from [" + logInfo + "].");
- }
- else {
+ } else {
String width = Integer.toString(input.getWidth());
String height = Integer.toString(input.getHeight());
customMeta.setValue("height", height);
@@ -209,15 +196,14 @@
}
/**
- * Translates the mime type if it can be read, but the tools don't think so.
- * For example, all jpegs from IE are marked as image/pjpeg, which ImageIO
- * doesn't return a ImageReader for, even though the one for image/jpeg
- * works just fine, even for a real image/pjpeg.
+ * Translates the mime type if it can be read, but the tools don't think so. For example, all
+ * jpegs from IE are marked as image/pjpeg, which ImageIO doesn't return a ImageReader for, even
+ * though the one for image/jpeg works just fine, even for a real image/pjpeg.
* @param mimeType The mime type.
* @return The translated or original mime type if no translation was applied
*/
private static String translateMimeType(String mimeType) {
- if(mimeType.equals(MIME_IMAGE_PJPEG)) {
+ if (mimeType.equals(MIME_IMAGE_PJPEG)) {
return MIME_IMAGE_JPEG;
}
return mimeType;
Modified: lenya/trunk/org.apache.lenya.module.resource/src/main/java/org/apache/lenya/cms/site/usecases/CreateResource.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.resource/src/main/java/org/apache/lenya/cms/site/usecases/CreateResource.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.resource/src/main/java/org/apache/lenya/cms/site/usecases/CreateResource.java (original)
+++ lenya/trunk/org.apache.lenya.module.resource/src/main/java/org/apache/lenya/cms/site/usecases/CreateResource.java Fri Feb 6 17:55:28 2009
@@ -21,6 +21,7 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.cocoon.servlet.multipart.Part;
+import org.apache.excalibur.source.SourceResolver;
import org.apache.lenya.cms.metadata.MetaDataException;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentException;
@@ -42,10 +43,12 @@
protected static final String MESSAGE_UPLOAD_SIZE_EXCEEDED = "upload-size-exceeded";
protected static final String MESSAGE_UPLOAD_RESET = "upload-reset";
protected static final String MESSAGE_UPLOAD_MISSING_EXTENSION = "upload-missing-extension";
+
+ private SourceResolver sourceResolver;
protected void doCheckPreconditions() throws Exception {
super.doCheckPreconditions();
- if (!ServletHelper.isUploadEnabled(this.manager)) {
+ if (!ServletHelper.isUploadEnabled()) {
addErrorMessage(MESSAGE_UPLOAD_DISABLED);
setParameter(PARAMETER_CAN_SUBMIT, Boolean.FALSE);
}
@@ -112,7 +115,7 @@
Part file = getPart(PARAMETER_FILE);
Document document = getNewDocument();
- ResourceWrapper wrapper = new ResourceWrapper(document, this.manager, getLogger());
+ ResourceWrapper wrapper = new ResourceWrapper(document, getSourceResolver(), getLogger());
wrapper.write(file);
}
@@ -130,4 +133,15 @@
return extension.toLowerCase();
}
+ /**
+ * TODO: Bean wiring
+ */
+ public void setSourceResolver(SourceResolver sourceResolver) {
+ this.sourceResolver = sourceResolver;
+ }
+
+ public SourceResolver getSourceResolver() {
+ return sourceResolver;
+ }
+
}
Modified: lenya/trunk/org.apache.lenya.module.resource/src/main/java/org/apache/lenya/cms/site/usecases/UploadResource.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.resource/src/main/java/org/apache/lenya/cms/site/usecases/UploadResource.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.resource/src/main/java/org/apache/lenya/cms/site/usecases/UploadResource.java (original)
+++ lenya/trunk/org.apache.lenya.module.resource/src/main/java/org/apache/lenya/cms/site/usecases/UploadResource.java Fri Feb 6 17:55:28 2009
@@ -18,6 +18,7 @@
package org.apache.lenya.cms.site.usecases;
import org.apache.cocoon.servlet.multipart.Part;
+import org.apache.excalibur.source.SourceResolver;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.ResourceWrapper;
@@ -29,10 +30,12 @@
*
*/
public class UploadResource extends InvokeWorkflow {
+
+ private SourceResolver sourceResolver;
protected void doCheckPreconditions() throws Exception {
super.doCheckPreconditions();
- if (!ServletHelper.isUploadEnabled(manager)) {
+ if (!ServletHelper.isUploadEnabled()) {
addErrorMessage("Upload is not enabled. Please check local.build.properties!");
}
Document doc = getSourceDocument();
@@ -57,8 +60,19 @@
super.doExecute();
Part file = getPart("file");
Document document = getSourceDocument();
- ResourceWrapper wrapper = new ResourceWrapper(document, this.manager, getLogger());
+ ResourceWrapper wrapper = new ResourceWrapper(document, getSourceResolver(), getLogger());
wrapper.write(file);
}
+ /**
+ * TODO: Bean wiring
+ */
+ public void setSourceResolver(SourceResolver sourceResolver) {
+ this.sourceResolver = sourceResolver;
+ }
+
+ public SourceResolver getSourceResolver() {
+ return sourceResolver;
+ }
+
}
\ No newline at end of file
Modified: lenya/trunk/org.apache.lenya.module.simplesite/src/main/java/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.simplesite/src/main/java/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java?rev=741654&r1=741653&r2=741654&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.simplesite/src/main/java/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java (original)
+++ lenya/trunk/org.apache.lenya.module.simplesite/src/main/java/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java Fri Feb 6 17:55:28 2009
@@ -17,11 +17,8 @@
*/
package org.apache.lenya.cms.site.simple;
-import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.util.AbstractLogEnabled;
-import org.apache.commons.logging.Log;
import org.apache.lenya.cms.publication.Area;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentFactory;
@@ -42,16 +39,7 @@
*/
public class DocumentStoreFactory extends AbstractLogEnabled implements RepositoryItemFactory {
- protected ServiceManager manager;
-
- /**
- * Ctor.
- * @param manager The service manager.
- * @param logger The logger.
- */
- public DocumentStoreFactory(ServiceManager manager, Log logger) {
- this.manager = manager;
- }
+ private DocumentManager documentManager;
/**
* @see org.apache.lenya.cms.repository.RepositoryItemFactory#getItemType()
@@ -74,7 +62,7 @@
String uuid = snippets[2];
DocumentStore store;
try {
- DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
+ DocumentFactory factory = DocumentUtil.createDocumentFactory(session);
Publication publication = factory.getPublication(publicationId);
Area area = publication.getArea(areaName);
String lang = publication.getDefaultLanguage();
@@ -94,21 +82,24 @@
protected void createAreaVersion(Publication publication, String areaName, String uuid,
String lang) throws PublicationException, ServiceException {
- DocumentManager docManager = null;
- try {
- Area authoring = publication.getArea(Publication.AUTHORING_AREA);
- Document authoringDoc = authoring.getDocument(uuid, lang);
- docManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
- docManager.copyToArea(authoringDoc, areaName);
- } finally {
- if (docManager != null) {
- this.manager.release(docManager);
- }
- }
+ Area authoring = publication.getArea(Publication.AUTHORING_AREA);
+ Document authoringDoc = authoring.getDocument(uuid, lang);
+ getDocumentManager().copyToArea(authoringDoc, areaName);
}
public boolean isSharable() {
return false;
}
+ /**
+ * TODO: Bean wiring
+ */
+ public void setDocumentManager(DocumentManager documentManager) {
+ this.documentManager = documentManager;
+ }
+
+ public DocumentManager getDocumentManager() {
+ return documentManager;
+ }
+
}
\ No newline at end of file