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 2005/04/07 11:31:00 UTC
svn commit: r160396 [1/2] - in lenya/trunk/src:
java/org/apache/lenya/ac/impl/
java/org/apache/lenya/cms/cocoon/components/modules/input/
java/org/apache/lenya/cms/cocoon/source/
java/org/apache/lenya/cms/metadata/dublincore/
java/org/apache/lenya/cms/metadata/usecases/
java/org/apache/lenya/cms/publication/ java/org/apache/lenya/cms/rc/
java/org/apache/lenya/cms/site/ java/org/apache/lenya/cms/site/topicmap/
java/org/apache/lenya/cms/site/tree/ java/org/apache/lenya/cms/usecase/
java/org/apache/lenya/cms/usecase/scheduling/
java/org/apache/lenya/cms/workflow/ java/org/apache/lenya/transaction/
webapp/lenya/pubs/default/
webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/
webapp/lenya/usecases/
Author: andreas
Date: Thu Apr 7 02:30:55 2005
New Revision: 160396
URL: http://svn.apache.org/viewcvs?view=rev&rev=160396
Log:
Introduced lightweigt repository layer using RepositorySource which is resolved by the lenya:// protocol. This allows transparent transaction handling in the source layer. The implementation is currently done using context:// sources, this can be changed to JCR later on.
Modified:
lenya/trunk/src/java/org/apache/lenya/ac/impl/UserAuthenticator.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/WorkflowModule.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java
lenya/trunk/src/java/org/apache/lenya/cms/metadata/dublincore/DublinCoreImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/metadata/usecases/Metadata.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java
lenya/trunk/src/java/org/apache/lenya/cms/rc/RevisionController.java
lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java
lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java
lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTree.java
lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeFactory.java
lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java
lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java
lenya/trunk/src/java/org/apache/lenya/cms/usecase/Usecase.java
lenya/trunk/src/java/org/apache/lenya/cms/usecase/scheduling/UsecaseCronJob.java
lenya/trunk/src/java/org/apache/lenya/cms/workflow/CMSHistory.java
lenya/trunk/src/java/org/apache/lenya/cms/workflow/History.java
lenya/trunk/src/java/org/apache/lenya/cms/workflow/WorkflowManagerImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/workflow/WorkflowResolverImpl.java
lenya/trunk/src/java/org/apache/lenya/transaction/AbstractOperation.java
lenya/trunk/src/java/org/apache/lenya/transaction/IdentityMapImpl.java
lenya/trunk/src/java/org/apache/lenya/transaction/Transactionable.java
lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWorkImpl.java
lenya/trunk/src/webapp/lenya/pubs/default/doctypes.xmap
lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
lenya/trunk/src/webapp/lenya/usecases/usecases.js
Modified: lenya/trunk/src/java/org/apache/lenya/ac/impl/UserAuthenticator.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/ac/impl/UserAuthenticator.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/ac/impl/UserAuthenticator.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/ac/impl/UserAuthenticator.java Thu Apr 7 02:30:55 2005
@@ -49,6 +49,11 @@
Identity identity = (Identity) request.getSession(false).getAttribute(
Identity.class.getName());
+
+ if (identity == null) {
+ throw new AccessControlException("The session does not contain the identity!");
+ }
+
boolean authenticated = authenticate(accreditableManager, username, password, identity);
return authenticated;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/WorkflowModule.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/WorkflowModule.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/WorkflowModule.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/WorkflowModule.java Thu Apr 7 02:30:55 2005
@@ -17,13 +17,13 @@
package org.apache.lenya.cms.cocoon.components.modules.input;
+import java.io.File;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.lenya.cms.publication.DefaultDocument;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.PageEnvelope;
import org.apache.lenya.cms.workflow.WorkflowResolver;
@@ -47,6 +47,7 @@
public static final String VARIABLE_PREFIX = "variable.";
/**
* <code>HISTORY_PATH</code> The history path
+ * @deprecated Exposes implementation details.
*/
public static final String HISTORY_PATH = "history-path";
@@ -68,15 +69,14 @@
if (document != null) {
resolver = (WorkflowResolver) this.manager.lookup(WorkflowResolver.ROLE);
if (resolver.hasWorkflow(document)) {
-
+
Version latestVersion = document.getLatestVersion();
-
+
if (name.equals(STATE)) {
if (latestVersion == null) {
Workflow workflow = resolver.getWorkflowSchema(document);
value = workflow.getInitialState();
- }
- else {
+ } else {
value = latestVersion.getState();
}
} else if (name.startsWith(VARIABLE_PREFIX)) {
@@ -86,13 +86,18 @@
if (Arrays.asList(variableNames).contains(variableName)) {
if (latestVersion == null) {
value = Boolean.valueOf(workflow.getInitialValue(variableName));
- }
- else {
+ } else {
value = Boolean.valueOf(latestVersion.getValue(variableName));
}
}
} else if (name.equals(HISTORY_PATH)) {
- value = ((DefaultDocument) document).getHistoryFile().getAbsolutePath();
+ final String path = document.getPublication().getPathMapper()
+ .getPath(document.getId(), document.getLanguage());
+ final String uri = "content/workflow/history/" + path;
+ final File pubDir = document.getPublication().getDirectory();
+ final File workflowFile = new File(pubDir, uri.replace('/',
+ File.separatorChar));
+ value = workflowFile.getAbsolutePath();
} else {
throw new ConfigurationException("The attribute [" + name
+ "] is not supported!");
@@ -103,8 +108,7 @@
throw e;
} catch (Exception e) {
throw new ConfigurationException("Resolving attribute failed: ", e);
- }
- finally {
+ } finally {
if (resolver != null) {
this.manager.release(resolver);
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java Thu Apr 7 02:30:55 2005
@@ -31,6 +31,7 @@
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.Session;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.SourceFactory;
@@ -40,12 +41,13 @@
import org.apache.lenya.cms.publication.PageEnvelopeException;
import org.apache.lenya.cms.publication.PageEnvelopeFactory;
import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.transaction.IdentityMap;
+import org.apache.lenya.transaction.UnitOfWork;
/**
- * A factory for the "lenya" scheme (virtual protocol), which is used to
- * resolve any src="lenya:..." attributes in sitemaps. This implementation constructs
- * the path to the source document from the page envelope and delegates
- * any further resolving to the "context" source resolver of Cocoon.
+ * A factory for the "lenya" scheme (virtual protocol), which is used to resolve any src="lenya:..."
+ * attributes in sitemaps. This implementation constructs the path to the source document from the
+ * page envelope and delegates any further resolving to the "context" source resolver of Cocoon.
*
* @version $Id$
*/
@@ -109,8 +111,8 @@
PageEnvelopeFactory pageEnvelopeFactory = PageEnvelopeFactory.getInstance();
if (pageEnvelopeFactory != null) {
- PageEnvelope pageEnvelope = pageEnvelopeFactory
- .getPageEnvelope(map, objectModel);
+ PageEnvelope pageEnvelope = pageEnvelopeFactory.getPageEnvelope(map,
+ objectModel);
if (pageEnvelope != null) {
String publicationID = pageEnvelope.getPublication().getId();
@@ -125,10 +127,32 @@
}
}
- path = this.delegationScheme + this.delegationPrefix + path;
+ while (path.startsWith("/")) {
+ path = path.substring(1);
+ }
+
+ UnitOfWork unit = null;
+ IdentityMap map = null;
+ Session session = ContextHelper.getRequest(this.context).getSession(false);
+ if (session != null) {
+ unit = (UnitOfWork) session.getAttribute(UnitOfWork.class.getName());
+ if (unit != null) {
+ map = unit.getIdentityMap();
+ }
+ else {
+ map = new DocumentIdentityMap(this.manager, getLogger());
+ }
+ }
+
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Creating repository source for URI [" + location + "]");
+ }
+
+ // path = this.delegationScheme + this.delegationPrefix + path;
+ return new RepositorySource(this.manager, location, map, getLogger());
+
+ // return sourceResolver.resolveURI(path);
- return sourceResolver.resolveURI(path);
-
} catch (final ServiceException e) {
throw new SourceException(e.getMessage(), e);
} finally {
@@ -141,6 +165,6 @@
* @see org.apache.excalibur.source.SourceFactory#release(org.apache.excalibur.source.Source)
*/
public void release(Source source) {
- // do nothing
+ // do nothing
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java Thu Apr 7 02:30:55 2005
@@ -20,13 +20,27 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
import org.apache.commons.io.CopyUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.excalibur.source.ModifiableSource;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
+import org.apache.excalibur.source.SourceNotFoundException;
import org.apache.excalibur.source.SourceResolver;
+import org.apache.lenya.transaction.TransactionException;
+import org.apache.lenya.xml.DocumentHelper;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
/**
* @version $Id$
@@ -58,12 +72,15 @@
try {
sourceInputStream = source.getInputStream();
destOutputStream = destination.getOutputStream();
+
+ useBuffer = false;
if (useBuffer) {
final ByteArrayOutputStream sourceBos = new ByteArrayOutputStream();
CopyUtils.copy(sourceInputStream, sourceBos);
CopyUtils.copy(sourceBos.toByteArray(), destOutputStream);
- } else
+ } else {
CopyUtils.copy(sourceInputStream, destOutputStream);
+ }
} finally {
if (destOutputStream != null) {
destOutputStream.flush();
@@ -117,5 +134,292 @@
public static void copy(SourceResolver resolver, String sourceUri, String destUri)
throws IOException {
copy(resolver, sourceUri, destUri, false);
+ }
+
+ /**
+ * Reads a DOM from a source.
+ * @param sourceUri The source URI.
+ * @param manager The service manager.
+ * @return A document or <code>null</code> if the source does not exist.
+ * @throws ServiceException if an error occurs.
+ * @throws SourceNotFoundException if an error occurs.
+ * @throws ParserConfigurationException if an error occurs.
+ * @throws SAXException if an error occurs.
+ * @throws IOException if an error occurs.
+ */
+ public static Document readDOM(String sourceUri, ServiceManager manager)
+ throws ServiceException, SourceNotFoundException, ParserConfigurationException,
+ SAXException, IOException {
+ SourceResolver resolver = null;
+ Source source = null;
+ Document document = null;
+ try {
+
+ resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+ source = resolver.resolveURI(sourceUri);
+
+ if (source.exists()) {
+ if (source instanceof RepositorySource) {
+ document = ((RepositorySource) source).getDocument();
+ } else {
+ document = DocumentHelper.readDocument(source.getInputStream());
+ }
+ }
+ } finally {
+ if (resolver != null) {
+ if (source != null) {
+ resolver.release(source);
+ }
+ manager.release(resolver);
+ }
+ }
+ return document;
+ }
+
+ /**
+ * Writes a DOM to a source.
+ * @param document The document.
+ * @param sourceUri The source URI.
+ * @param manager The service manager.
+ * @throws TransformerConfigurationException if an error occurs.
+ * @throws TransformerException if an error occurs.
+ * @throws ServiceException if the source resolver could not be obtained.
+ * @throws MalformedURLException if the source URI is not valid.
+ * @throws IOException if an error occurs.
+ */
+ public static void writeDOM(Document document, String sourceUri, ServiceManager manager)
+ throws TransformerConfigurationException, TransformerException, ServiceException,
+ MalformedURLException, IOException {
+ SourceResolver resolver = null;
+ ModifiableSource source = null;
+ try {
+
+ resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+ source = (ModifiableSource) resolver.resolveURI(sourceUri);
+
+ if (source instanceof RepositorySource) {
+ ((RepositorySource) source).setDocument(document);
+ } else {
+ OutputStream oStream = source.getOutputStream();
+ Writer writer = new OutputStreamWriter(oStream);
+ DocumentHelper.writeDocument(document, writer);
+ if (oStream != null) {
+ oStream.flush();
+ try {
+ oStream.close();
+ } catch (Throwable t) {
+ throw new RuntimeException("Could not write document: ", t);
+ }
+ }
+ }
+ } finally {
+ if (resolver != null) {
+ if (source != null) {
+ resolver.release(source);
+ }
+ manager.release(resolver);
+ }
+ }
+ }
+
+ /**
+ * Deletes a source if it exists.
+ * @param sourceUri The source URI.
+ * @param manager The service manager.
+ * @throws ServiceException if an error occurs.
+ * @throws MalformedURLException if an error occurs.
+ * @throws IOException if an error occurs.
+ */
+ public static void delete(String sourceUri, ServiceManager manager) throws ServiceException,
+ MalformedURLException, IOException {
+ SourceResolver resolver = null;
+ ModifiableSource source = null;
+ try {
+
+ resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+ source = (ModifiableSource) resolver.resolveURI(sourceUri);
+ if (source.exists()) {
+ source.delete();
+ }
+ } finally {
+ if (resolver != null) {
+ if (source != null) {
+ resolver.release(source);
+ }
+ manager.release(resolver);
+ }
+ }
+ }
+
+ /**
+ * Checks if a source exists.
+ * @param sourceUri The source URI.
+ * @param manager The service manager.
+ * @return A boolean value.
+ * @throws ServiceException if an error occurs.
+ * @throws MalformedURLException if an error occurs.
+ * @throws IOException if an error occurs.
+ */
+ public static boolean exists(String sourceUri, ServiceManager manager) throws ServiceException,
+ MalformedURLException, IOException {
+ SourceResolver resolver = null;
+ Source source = null;
+ try {
+
+ resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+ source = resolver.resolveURI(sourceUri);
+
+ return source.exists();
+ } finally {
+ if (resolver != null) {
+ if (source != null) {
+ resolver.release(source);
+ }
+ manager.release(resolver);
+ }
+ }
+ }
+
+ /**
+ * Checks out a transactionable source.
+ * @param sourceUri The source URI.
+ * @param manager The service manager.
+ * @throws TransactionException If an error occurs.
+ * @throws ServiceException If an error occurs.
+ * @throws MalformedURLException If an error occurs.
+ * @throws IOException If an error occurs.
+ */
+ public static void checkout(String sourceUri, ServiceManager manager)
+ throws TransactionException, ServiceException, MalformedURLException, IOException {
+ SourceResolver resolver = null;
+ TransactionableSource source = null;
+ try {
+
+ resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+ source = (TransactionableSource) resolver.resolveURI(sourceUri);
+
+ source.checkout();
+
+ } finally {
+ if (resolver != null) {
+ if (source != null) {
+ resolver.release(source);
+ }
+ manager.release(resolver);
+ }
+ }
+ }
+
+ /**
+ * Checks in a transactionable source.
+ * @param sourceUri The source URI.
+ * @param manager The service manager.
+ * @throws TransactionException If an error occurs.
+ * @throws ServiceException If an error occurs.
+ * @throws MalformedURLException If an error occurs.
+ * @throws IOException If an error occurs.
+ */
+ public static void checkin(String sourceUri, ServiceManager manager)
+ throws TransactionException, ServiceException, MalformedURLException, IOException {
+ SourceResolver resolver = null;
+ TransactionableSource source = null;
+ try {
+
+ resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+ source = (TransactionableSource) resolver.resolveURI(sourceUri);
+
+ source.checkin();
+
+ } finally {
+ if (resolver != null) {
+ if (source != null) {
+ resolver.release(source);
+ }
+ manager.release(resolver);
+ }
+ }
+ }
+
+ /**
+ * Locks a transactionable source.
+ * @param sourceUri The source URI.
+ * @param manager The service manager.
+ * @throws TransactionException If an error occurs.
+ */
+ public static void lock(String sourceUri, ServiceManager manager) throws TransactionException {
+ SourceResolver resolver = null;
+ TransactionableSource source = null;
+ try {
+
+ resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+ source = (TransactionableSource) resolver.resolveURI(sourceUri);
+
+ source.lock();
+
+ } catch (Exception e) {
+ throw new TransactionException(e);
+ } finally {
+ if (resolver != null) {
+ if (source != null) {
+ resolver.release(source);
+ }
+ manager.release(resolver);
+ }
+ }
+ }
+
+ /**
+ * Unlocks a transactionable source.
+ * @param sourceUri The source URI.
+ * @param manager The service manager.
+ * @throws TransactionException If an error occurs.
+ */
+ public static void unlock(String sourceUri, ServiceManager manager) throws TransactionException {
+ SourceResolver resolver = null;
+ TransactionableSource source = null;
+ try {
+
+ resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+ source = (TransactionableSource) resolver.resolveURI(sourceUri);
+
+ source.unlock();
+
+ } catch (Exception e) {
+ throw new TransactionException(e);
+ } finally {
+ if (resolver != null) {
+ if (source != null) {
+ resolver.release(source);
+ }
+ manager.release(resolver);
+ }
+ }
+ }
+
+ /**
+ * Registers a source as dirty.
+ * @param sourceUri The source URI.
+ * @param manager The service manager.
+ */
+ public static void registerDirty(String sourceUri, ServiceManager manager) {
+ SourceResolver resolver = null;
+ RepositorySource source = null;
+ try {
+
+ resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+ source = (RepositorySource) resolver.resolveURI(sourceUri);
+
+ source.registerDirty();
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (resolver != null) {
+ if (source != null) {
+ resolver.release(source);
+ }
+ manager.release(resolver);
+ }
+ }
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/metadata/dublincore/DublinCoreImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/metadata/dublincore/DublinCoreImpl.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/metadata/dublincore/DublinCoreImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/metadata/dublincore/DublinCoreImpl.java Thu Apr 7 02:30:55 2005
@@ -19,9 +19,6 @@
package org.apache.lenya.cms.metadata.dublincore;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -29,10 +26,7 @@
import java.util.Map;
import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.cocoon.ProcessingException;
-import org.apache.excalibur.source.ModifiableSource;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceResolver;
+import org.apache.lenya.cms.cocoon.source.SourceUtil;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentException;
import org.apache.lenya.cms.publication.PageEnvelope;
@@ -119,13 +113,9 @@
*/
protected void loadValues() throws DocumentException {
- SourceResolver resolver = null;
- Source source = null;
try {
- resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
- source = resolver.resolveURI(this.sourceUri);
- if (source.exists()) {
- org.w3c.dom.Document doc = DocumentHelper.readDocument(source.getInputStream());
+ org.w3c.dom.Document doc = SourceUtil.readDOM(this.sourceUri, this.manager);
+ if (doc != null) {
// FIXME: what if "lenya:meta" element doesn't exist yet?
// Currently the element is inserted.
@@ -153,13 +143,6 @@
}
} catch (Exception e) {
throw new DocumentException(e);
- } finally {
- if (resolver != null) {
- if (source != null) {
- resolver.release(source);
- }
- this.manager.release(resolver);
- }
}
}
@@ -169,14 +152,9 @@
*/
public void save() throws DocumentException {
- SourceResolver resolver = null;
- ModifiableSource source = null;
try {
- resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
- source = (ModifiableSource) resolver.resolveURI(this.sourceUri);
-
- org.w3c.dom.Document doc = DocumentHelper.readDocument(source.getInputStream());
+ org.w3c.dom.Document doc = SourceUtil.readDOM(this.sourceUri, this.manager);
Element metaElement = getMetaElement(doc);
@@ -201,29 +179,11 @@
}
}
}
+ SourceUtil.writeDOM(doc, this.sourceUri, this.manager);
- OutputStream oStream = source.getOutputStream();
- Writer writer = new OutputStreamWriter(oStream);
- DocumentHelper.writeDocument(doc, writer);
- if (oStream != null) {
- oStream.flush();
- try {
- oStream.close();
- } catch (Throwable t) {
- throw new ProcessingException("Could not write document: ", t);
- }
- }
} catch (Exception e) {
throw new DocumentException(e);
- } finally {
- if (resolver != null) {
- if (source != null) {
- resolver.release(source);
- }
- this.manager.release(resolver);
- }
}
-
}
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/metadata/usecases/Metadata.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/metadata/usecases/Metadata.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/metadata/usecases/Metadata.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/metadata/usecases/Metadata.java Thu Apr 7 02:30:55 2005
@@ -19,6 +19,7 @@
import org.apache.lenya.cms.metadata.dublincore.DublinCore;
import org.apache.lenya.cms.site.usecases.SiteUsecase;
import org.apache.lenya.cms.usecase.UsecaseException;
+import org.apache.lenya.transaction.TransactionException;
/**
* Usecase to edit metadata for a resource.
@@ -35,6 +36,18 @@
super();
}
+ /**
+ * @see org.apache.lenya.cms.usecase.Usecase#lockInvolvedObjects()
+ */
+ public void lockInvolvedObjects() throws UsecaseException {
+ super.lockInvolvedObjects();
+ try {
+ getSourceDocument().lock();
+ } catch (TransactionException e) {
+ throw new UsecaseException(e);
+ }
+ }
+
/**
* @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
*/
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java Thu Apr 7 02:30:55 2005
@@ -20,31 +20,24 @@
package org.apache.lenya.cms.publication;
import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceSelector;
-import org.apache.excalibur.source.ModifiableSource;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceResolver;
-import org.apache.lenya.ac.User;
import org.apache.lenya.cms.cocoon.source.SourceUtil;
import org.apache.lenya.cms.metadata.dublincore.DublinCore;
import org.apache.lenya.cms.metadata.dublincore.DublinCoreProxy;
import org.apache.lenya.cms.publication.util.DocumentVisitor;
-import org.apache.lenya.cms.rc.RCEnvironment;
-import org.apache.lenya.cms.rc.RevisionController;
import org.apache.lenya.cms.site.SiteManager;
import org.apache.lenya.cms.workflow.CMSHistory;
import org.apache.lenya.cms.workflow.History;
import org.apache.lenya.transaction.Lock;
import org.apache.lenya.transaction.TransactionException;
+import org.apache.lenya.transaction.Transactionable;
import org.apache.lenya.workflow.Situation;
import org.apache.lenya.workflow.Version;
import org.apache.lenya.workflow.Workflow;
@@ -53,7 +46,7 @@
/**
* A typical CMS document.
*/
-public class DefaultDocument extends AbstractLogEnabled implements Document {
+public class DefaultDocument extends AbstractLogEnabled implements Document, Transactionable {
private String id;
private DublinCore dublincore;
@@ -72,22 +65,7 @@
*/
protected DefaultDocument(ServiceManager manager, DocumentIdentityMap map,
Publication publication, String _id, String _area) {
- if (_id == null) {
- throw new IllegalArgumentException("The document ID must not be null!");
- }
- if (!_id.startsWith("/")) {
- throw new IllegalArgumentException("The document ID must start with a slash!");
- }
- this.manager = manager;
- this.id = _id;
- this.publication = publication;
-
- this.identityMap = map;
-
- setArea(_area);
- setLanguage(getPublication().getDefaultLanguage());
-
- this.dublincore = new DublinCoreProxy(this, this.manager);
+ this(manager, map, publication, _id, _area, publication.getDefaultLanguage());
}
/**
@@ -101,13 +79,13 @@
*/
protected DefaultDocument(ServiceManager manager, DocumentIdentityMap map,
Publication publication, String _id, String _area, String _language) {
+ this.manager = manager;
if (_id == null) {
throw new IllegalArgumentException("The document ID must not be null!");
}
if (!_id.startsWith("/")) {
throw new IllegalArgumentException("The document ID must start with a slash!");
}
- this.manager = manager;
this.id = _id;
this.publication = publication;
@@ -306,7 +284,7 @@
if (siteManager != null) {
exists = siteManager.contains(this);
} else {
- exists = getFile().exists();
+ exists = SourceUtil.exists(getSourceURI(), this.manager);
}
} catch (Exception e) {
throw new DocumentException(e);
@@ -405,71 +383,6 @@
}
/**
- * If the document is involved in a unit of work, a temporary source is created to be used in
- * the transaction.
- * @see org.apache.lenya.cms.publication.Document#getSourceURI()
- */
- public String getSourceURI() {
- String uri = getRealSourceURI();
-
- if (getIdentityMap().getUnitOfWork() != null) {
- String workUri = getWorkSourceURI();
-
- SourceResolver resolver = null;
- ModifiableSource realSource = null;
- ModifiableSource workSource = null;
- try {
- resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
- realSource = (ModifiableSource) resolver.resolveURI(uri);
- workSource = (ModifiableSource) resolver.resolveURI(workUri);
- if (realSource.exists() && !workSource.exists()) {
- SourceUtil.copy(realSource, workSource, true);
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- if (resolver != null) {
- if (realSource != null) {
- resolver.release(realSource);
- }
- if (workSource != null) {
- resolver.release(workSource);
- }
- this.manager.release(resolver);
- }
- }
-
- uri = workUri;
- }
-
- return uri;
- }
-
- /**
- * @return The real source URI.
- */
- protected String getRealSourceURI() {
- try {
- return "file:/" + getFile().getCanonicalPath();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * @return A source URI to be used in a transaction.
- */
- protected String getWorkSourceURI() {
- String workUri = "file:/" + getPublication().getDirectory().getAbsolutePath() + "/work/";
- workUri += getUserId();
-
- String path = getPublication().getPathMapper().getPath(getId(), getLanguage());
- workUri += "/" + getArea() + "/" + path;
-
- return workUri;
- }
-
- /**
* @see org.apache.lenya.cms.publication.Document#accept(org.apache.lenya.cms.publication.util.DocumentVisitor)
*/
public void accept(DocumentVisitor visitor) throws PublicationException {
@@ -484,7 +397,11 @@
public History getHistory() {
if (this.history == null) {
try {
- this.history = new CMSHistory(this, getHistoryFile());
+ final String path = getPublication().getPathMapper()
+ .getPath(getId(), getLanguage());
+ final String uri = "lenya://lenya/pubs/" + getPublication().getId()
+ + "/content/workflow/history/" + path;
+ this.history = new CMSHistory(uri, this.manager);
} catch (WorkflowException e) {
throw new RuntimeException(e);
}
@@ -512,54 +429,6 @@
}
/**
- * Returns the history file inside the publication directory.
- * @return A string.
- */
- public File getHistoryFile() {
- if (getIdentityMap().getUnitOfWork() == null) {
- return getRealHistoryFile();
- } else {
- return getWorkHistoryFile();
- }
- }
-
- protected File getRealHistoryFile() {
- DocumentIdToPathMapper pathMapper = getPublication().getPathMapper();
- String documentPath = pathMapper.getPath(getId(), getLanguage());
-
- String area = getArea();
- if (!area.equals(Publication.ARCHIVE_AREA) && !area.equals(Publication.TRASH_AREA)) {
- area = Publication.AUTHORING_AREA;
- }
-
- String path = CMSHistory.HISTORY_PATH + "/" + area + "/" + documentPath;
- path = path.replace('/', File.separatorChar);
- return new File(getPublication().getDirectory(), path);
- }
-
- protected File getWorkHistoryFile() {
- DocumentIdToPathMapper pathMapper = getPublication().getPathMapper();
- String documentPath = pathMapper.getPath(getId(), getLanguage());
-
- String area = getArea();
- if (!area.equals(Publication.ARCHIVE_AREA) && !area.equals(Publication.TRASH_AREA)) {
- area = Publication.AUTHORING_AREA;
- }
-
- String path = "work/" + getUserId() + "/" + CMSHistory.HISTORY_PATH + "/" + area + "/"
- + documentPath;
- path = path.replace('/', File.separatorChar);
- return new File(getPublication().getDirectory(), path);
- }
-
- /**
- * @return The source URI of the history file.
- */
- public String getHistorySourceURI() {
- return getHistoryFile().toURI().toString();
- }
-
- /**
* @see org.apache.lenya.workflow.Workflowable#newVersion(org.apache.lenya.workflow.Workflow,
* org.apache.lenya.workflow.Version, org.apache.lenya.workflow.Situation)
*/
@@ -571,209 +440,95 @@
* @see org.apache.lenya.transaction.Transactionable#save()
*/
public void save() throws TransactionException {
-
- SourceResolver sourceResolver = null;
- ModifiableSource realSource = null;
- ModifiableSource workSource = null;
try {
getDublinCore().save();
- getHistory().save();
-
- if (getWorkHistoryFile().exists()) {
- FileUtil.copyFile(getWorkHistoryFile(), getRealHistoryFile());
- getWorkHistoryFile().delete();
- }
-
- sourceResolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
- realSource = (ModifiableSource) sourceResolver.resolveURI(getRealSourceURI());
- workSource = (ModifiableSource) sourceResolver.resolveURI(getWorkSourceURI());
- if (workSource.exists()) {
- SourceUtil.copy(workSource, realSource, true);
- workSource.delete();
- }
-
} catch (Exception e) {
throw new TransactionException(e);
- } finally {
- if (sourceResolver != null) {
- if (realSource != null) {
- sourceResolver.release(realSource);
- }
- if (workSource != null) {
- sourceResolver.release(workSource);
- }
- this.manager.release(sourceResolver);
- }
}
-
}
/**
- * @see org.apache.lenya.transaction.Transactionable#checkin()
+ * @see org.apache.lenya.transaction.Transactionable#delete()
*/
- public void checkin() throws TransactionException {
- checkin(true);
- }
-
- private boolean isCheckedOut = false;
-
- protected void checkin(boolean backup) throws TransactionException {
- try {
- String userName = getUserId();
- boolean newVersion = getIdentityMap().getUnitOfWork().isDirty(this);
- getRevisionController().reservedCheckIn(getRCPath(), userName, backup, newVersion);
- this.isCheckedOut = false;
- } catch (Exception e) {
- throw new TransactionException(e);
- }
+ public void delete() throws TransactionException {
}
/**
- * @return The username of the unit of work's identity.
+ * @see org.apache.lenya.transaction.Transactionable#create()
*/
- protected String getUserId() {
- String userName = null;
- User user = getIdentityMap().getUnitOfWork().getIdentity().getUser();
- if (user != null) {
- userName = user.getId();
- }
- return userName;
+ public void create() throws TransactionException {
}
- /**
- * @see org.apache.lenya.transaction.Transactionable#checkout()
- */
- public void checkout() throws TransactionException {
- try {
- String userName = getUserId();
- getRevisionController().reservedCheckOut(getRCPath(), userName);
- this.isCheckedOut = true;
- } catch (Exception e) {
- throw new TransactionException(e);
- }
- }
+ protected static final String TRANSACTIONABLE_TYPE = "document";
/**
- * @see org.apache.lenya.transaction.Transactionable#isCheckedOut()
+ * @see org.apache.lenya.transaction.Transactionable#getTransactionableType()
*/
- public boolean isCheckedOut() throws TransactionException {
- return this.isCheckedOut;
+ public String getTransactionableType() {
+ return TRANSACTIONABLE_TYPE;
}
/**
- * @see org.apache.lenya.transaction.Transactionable#lock()
+ * @see org.apache.lenya.cms.publication.Document#getSourceURI()
*/
- public void lock() throws TransactionException {
- this.lock = new Lock(getVersion());
+ public String getSourceURI() {
+ String path = publication.getPathMapper().getPath(getId(), getLanguage());
+ return "lenya://lenya/pubs/" + publication.getId() + "/content/" + getArea() + "/" + path;
}
/**
- * @see org.apache.lenya.transaction.Transactionable#unlock()
+ * @see org.apache.lenya.transaction.Transactionable#checkin()
*/
- public void unlock() throws TransactionException {
- this.lock = null;
+ public void checkin() throws TransactionException {
}
/**
- * @see org.apache.lenya.transaction.Transactionable#isLocked()
+ * @see org.apache.lenya.transaction.Transactionable#checkout()
*/
- public boolean isLocked() throws TransactionException {
- return this.lock != null;
+ public void checkout() throws TransactionException {
}
/**
- * @see org.apache.lenya.transaction.Transactionable#getTransactionableType()
+ * @see org.apache.lenya.transaction.Transactionable#isCheckedOut()
*/
- public String getTransactionableType() {
- return Document.TRANSACTIONABLE_TYPE;
+ public boolean isCheckedOut() throws TransactionException {
+ return false;
}
/**
- * @see org.apache.lenya.transaction.Transactionable#delete()
+ * @see org.apache.lenya.transaction.Transactionable#lock()
*/
- public void delete() throws TransactionException {
- SourceResolver sourceResolver = null;
- Source realSource = null;
- Source workSource = null;
- try {
- sourceResolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
- realSource = sourceResolver.resolveURI(getSourceURI());
- if (realSource.exists()) {
- ((ModifiableSource) realSource).delete();
- }
- workSource = sourceResolver.resolveURI(getWorkSourceURI());
- if (workSource.exists()) {
- ((ModifiableSource) workSource).delete();
- }
- } catch (Exception e) {
- throw new TransactionException(e);
- } finally {
- if (sourceResolver != null) {
- if (realSource != null) {
- sourceResolver.release(realSource);
- }
- if (workSource != null) {
- sourceResolver.release(workSource);
- }
- this.manager.release(sourceResolver);
- }
- }
+ public void lock() throws TransactionException {
+ SourceUtil.lock(getSourceURI(), this.manager);
+ SourceUtil.lock(getHistory().getSourceURI(), this.manager);
}
/**
- * @see org.apache.lenya.transaction.Transactionable#create()
+ * @see org.apache.lenya.transaction.Transactionable#getLock()
*/
- public void create() throws TransactionException {
- }
-
- private RevisionController revisionController;
-
- protected RevisionController getRevisionController() throws TransactionException {
- if (this.revisionController == null) {
- try {
- String publicationPath = getPublication().getDirectory().getCanonicalPath();
- RCEnvironment rcEnvironment = RCEnvironment.getInstance(getPublication()
- .getServletContext().getCanonicalPath());
- String rcmlDirectory = publicationPath + File.separator
- + rcEnvironment.getRCMLDirectory();
- String backupDirectory = publicationPath + File.separator
- + rcEnvironment.getBackupDirectory();
-
- this.revisionController = new RevisionController(rcmlDirectory, backupDirectory,
- publicationPath);
- } catch (IOException e) {
- throw new TransactionException(e);
- }
- }
- return this.revisionController;
+ public Lock getLock() {
+ return null;
}
- private Lock lock;
-
/**
- * @see org.apache.lenya.transaction.Transactionable#getLock()
+ * @see org.apache.lenya.transaction.Transactionable#unlock()
*/
- public Lock getLock() {
- return this.lock;
+ public void unlock() throws TransactionException {
+ SourceUtil.unlock(getSourceURI(), this.manager);
}
/**
- * @see org.apache.lenya.transaction.Transactionable#getVersion()
+ * @see org.apache.lenya.transaction.Transactionable#isLocked()
*/
- public int getVersion() throws TransactionException {
- try {
- return getRevisionController().getLatestVersion(getRCPath());
- } catch (Exception e) {
- throw new TransactionException(e);
- }
+ public boolean isLocked() throws TransactionException {
+ return false;
}
/**
- * @return The path to use for the revision controller.
- * @throws IOException if an error occurs.
+ * @see org.apache.lenya.transaction.Transactionable#hasChanged()
*/
- protected String getRCPath() throws IOException {
- return getArea() + "/" + getPublication().getPathMapper().getPath(getId(), getLanguage());
+ public boolean hasChanged() throws TransactionException {
+ return false;
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java Thu Apr 7 02:30:55 2005
@@ -434,7 +434,6 @@
destination = sourceResolver.resolveURI(destinationDocument.getSourceURI());
SourceUtil.copy(source, (ModifiableSource) destination, true);
destinationDocument.getDublinCore().replaceBy(sourceDocument.getDublinCore());
- destinationDocument.getIdentityMap().getUnitOfWork().registerDirty(destinationDocument);
} catch (Exception e) {
throw new PublicationException(e);
} finally {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java Thu Apr 7 02:30:55 2005
@@ -317,7 +317,7 @@
NodeList versionElements = elem.getElementsByTagName("Version");
int version = 0;
if (versionElements.getLength() > 0) {
- String versionString = elem.getFirstChild().getNodeValue();
+ String versionString = versionElements.item(0).getFirstChild().getNodeValue();
version = new Integer(versionString).intValue();
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/rc/RevisionController.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/rc/RevisionController.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/rc/RevisionController.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/rc/RevisionController.java Thu Apr 7 02:30:55 2005
@@ -160,6 +160,27 @@
return !checkedOutByOther;
}
+
+ /**
+ * @param source A source.
+ * @return If the source is checked out.
+ * @throws Exception if an error occurs.
+ */
+ public boolean isCheckedOut(String source) throws Exception {
+ RCML rcml = new RCML(this.rcmlDir, source, this.rootDir);
+
+ RCMLEntry entry = rcml.getLatestEntry();
+
+ // The same user is allowed to check out repeatedly without
+ // having to check back in first.
+ //
+ if (entry != null) {
+ log.debug("entry: " + entry);
+ log.debug("entry.type:" + entry.getType());
+ log.debug("entry.identity" + entry.getIdentity());
+ }
+ return entry != null && entry.getType() == RCML.co;
+ }
/**
* Try to make a reserved check in of the file destination for a user with identity. A backup
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java Thu Apr 7 02:30:55 2005
@@ -28,16 +28,14 @@
* </p>
*
* <p>
- * Dependence on a set of resources must be a strict partial order <strong><
- * </strong>:
+ * Dependence on a set of resources must be a strict partial order <strong>< </strong>:
* </p>
* <ul>
- * <li><em>irreflexive:</em> d <strong>< </strong>d does not hold for any
- * resource d</li>
- * <li><em>antisymmetric:</em> d <strong>< </strong>e and e <strong><
- * </strong>d implies d=e</li>
- * <li><em>transitive:</em> d <strong>< </strong>e and e <strong><
- * </strong>f implies d <strong>< </strong>f</li>
+ * <li><em>irreflexive:</em> d <strong>< </strong>d does not hold for any resource d</li>
+ * <li><em>antisymmetric:</em> d <strong>< </strong>e and e <strong>< </strong>d implies
+ * d=e</li>
+ * <li><em>transitive:</em> d <strong>< </strong>e and e <strong>< </strong>f implies d
+ * <strong>< </strong>f</li>
* </ul>*
* @version $Id$
*/
@@ -81,8 +79,7 @@
void add(Document document) throws SiteException;
/**
- * Checks if the site structure contains a certain resource in a certain
- * area.
+ * Checks if the site structure contains a certain resource in a certain area.
* @param resource The resource.
* @return A boolean value.
* @throws SiteException if an error occurs.
@@ -90,8 +87,8 @@
boolean contains(Document resource) throws SiteException;
/**
- * Checks if the site structure contains any language version of a certain
- * resource in a certain area.
+ * Checks if the site structure contains any language version of a certain resource in a certain
+ * area.
* @param resource The resource.
* @return A boolean value.
* @throws SiteException if an error occurs.
@@ -139,12 +136,21 @@
*/
Document[] getDocuments(DocumentIdentityMap identityMap, Publication publication, String area)
throws SiteException;
-
+
/**
* Sorts a set of documents using the "requires" relation.
* @param set The set.
* @throws SiteException if an error occurs.
*/
void sortAscending(DocumentSet set) throws SiteException;
-
+
+ /**
+ * @param map The identity map.
+ * @param publiation The publication.
+ * @param area The area.
+ * @return The object that holds the site structure information.
+ * @throws SiteException if an error occurs.
+ */
+ SiteStructure getSiteStructure(DocumentIdentityMap map, Publication publiation, String area)
+ throws SiteException;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java Thu Apr 7 02:30:55 2005
@@ -21,6 +21,7 @@
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.site.AbstractSiteManager;
import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.SiteStructure;
/**
* Site manager to support topic maps.
@@ -117,6 +118,14 @@
*/
public Document[] getDocuments(DocumentIdentityMap map, Publication publication, String area)
throws SiteException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @see org.apache.lenya.cms.site.SiteManager#getSiteStructure(org.apache.lenya.cms.publication.DocumentIdentityMap, org.apache.lenya.cms.publication.Publication, java.lang.String)
+ */
+ public SiteStructure getSiteStructure(DocumentIdentityMap map, Publication publiation, String area) throws SiteException {
// TODO Auto-generated method stub
return null;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java Thu Apr 7 02:30:55 2005
@@ -17,8 +17,6 @@
package org.apache.lenya.cms.site.tree;
-import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
@@ -28,17 +26,14 @@
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.lenya.ac.Identity;
-import org.apache.lenya.ac.User;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.lenya.cms.cocoon.source.SourceUtil;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.rc.RCEnvironment;
-import org.apache.lenya.cms.rc.RevisionController;
import org.apache.lenya.cms.site.Label;
import org.apache.lenya.cms.site.SiteException;
import org.apache.lenya.transaction.IdentityMap;
import org.apache.lenya.transaction.Lock;
import org.apache.lenya.transaction.TransactionException;
-import org.apache.lenya.transaction.UnitOfWork;
import org.apache.lenya.xml.DocumentHelper;
import org.apache.lenya.xml.NamespaceHelper;
import org.apache.xpath.XPathAPI;
@@ -47,7 +42,6 @@
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
/**
* Default sitetree implementation.
@@ -66,13 +60,13 @@
*/
public static final String SITE_TREE_FILENAME = "sitetree.xml";
- private Document document = null;
- private File treefile = null;
+ private String sourceUri;
// the area is only retained to provide some more info when raising an
// exception.
private String area = "";
private IdentityMap identityMap;
private Publication publication;
+ protected ServiceManager manager;
protected void setup(IdentityMap map, Publication publication) {
this.identityMap = map;
@@ -85,71 +79,41 @@
* @param _area the area
* @throws SiteException if an error occurs
*/
- protected DefaultSiteTree(File pubDir, String _area) throws SiteException {
- this(new File(pubDir, Publication.CONTENT_PATH + File.separator + _area + File.separator
- + SITE_TREE_FILENAME));
+ protected DefaultSiteTree(Publication publication, String _area, ServiceManager manager)
+ throws SiteException {
+ this.sourceUri = "lenya://lenya/pubs/" + publication.getId() + "/content/" + _area + "/"
+ + SITE_TREE_FILENAME;
this.area = _area;
+ this.manager = manager;
}
- /**
- * Create a DefaultSiteTree from a filename.
- * @param treefilename file name of the tree
- * @throws SiteException if an error occurs
- * @deprecated use the DefaultSiteTree(File pubDir, String area) constructor instead.
- */
- protected DefaultSiteTree(String treefilename) throws SiteException {
- this(new File(treefilename));
- }
-
- /**
- * Create a DefaultSiteTree from a file.
- * @param _treefile the file containing the tree
- * @throws SiteException if an error occurs
- * @deprecated this constructor will be private in the future
- */
- protected DefaultSiteTree(File _treefile) throws SiteException {
- this.treefile = _treefile;
+ private long lastModified = 0;
+ protected Document load() throws SiteException {
try {
- if (!_treefile.isFile()) {
- //the treefile doesn't exist, so create it
-
- this.document = createDocument();
- } else {
- // Read tree
- this.document = DocumentHelper.readDocument(_treefile);
+ Document document = SourceUtil.readDOM(this.sourceUri, this.manager);
+ if (document == null) {
+ document = createDocument();
+ SourceUtil.writeDOM(document, this.sourceUri, this.manager);
}
- } catch (ParserConfigurationException e) {
- throw new SiteException(e);
- } catch (SAXException e) {
- throw new SiteException(e);
- } catch (IOException e) {
+ return document;
+ } catch (Exception e) {
throw new SiteException(e);
}
-
}
- private long lastModified = 0;
-
/**
- * Checks if the tree file has been modified externally and reloads the site tree.
+ * Checks if the tree file has been modified externally and reloads the site tree. protected
+ * synchronized void checkModified() { if (this.area.equals(Publication.LIVE_AREA) &&
+ * this.treefile.lastModified() > this.lastModified) {
+ *
+ * if (getLogger().isDebugEnabled()) { getLogger().debug("Sitetree [" + this.treefile + "] has
+ * changed: reloading."); }
+ *
+ * try { this.document = DocumentHelper.readDocument(this.treefile); } catch (Exception e) {
+ * throw new IllegalStateException(e.getMessage()); } this.lastModified =
+ * this.treefile.lastModified(); } }
*/
- protected synchronized void checkModified() {
- if (this.area.equals(Publication.LIVE_AREA) && this.treefile.isFile()
- && this.treefile.lastModified() > this.lastModified) {
-
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Sitetree [" + this.treefile + "] has changed: reloading.");
- }
-
- try {
- this.document = DocumentHelper.readDocument(this.treefile);
- } catch (Exception e) {
- throw new IllegalStateException(e.getMessage());
- }
- this.lastModified = this.treefile.lastModified();
- }
- }
/**
* Create a new DefaultSiteTree xml document.
@@ -157,15 +121,15 @@
* @throws ParserConfigurationException if an error occurs
*/
public synchronized Document createDocument() throws ParserConfigurationException {
- this.document = DocumentHelper.createDocument(NAMESPACE_URI, "site", null);
+ Document document = DocumentHelper.createDocument(NAMESPACE_URI, "site", null);
- Element root = this.document.getDocumentElement();
+ Element root = document.getDocumentElement();
root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
root
.setAttribute("xsi:schemaLocation",
"http://apache.org/cocoon/lenya/sitetree/1.0 ../../../../resources/entities/sitetree.xsd");
- return this.document;
+ return document;
}
/**
@@ -177,8 +141,6 @@
*/
protected synchronized Node findNode(Node node, List ids) {
- checkModified();
-
if (ids.size() < 1) {
return node;
}
@@ -206,7 +168,7 @@
* java.lang.String)
*/
public synchronized void addNode(SiteTreeNode node, String refDocumentId) throws SiteException {
- this.addNode(node.getParent().getAbsoluteId(), node.getId(), node.getLabels(), node
+ addNode(node.getParent().getAbsoluteId(), node.getId(), node.getLabels(), node
.getHref(), node.getSuffix(), node.hasLink(), refDocumentId);
}
@@ -223,7 +185,7 @@
* @see org.apache.lenya.cms.site.tree.SiteTree#addNode(org.apache.lenya.cms.site.tree.SiteTreeNode)
*/
public synchronized void addNode(SiteTreeNode node) throws SiteException {
- this.addNode(node, null);
+ addNode(node, null);
}
/**
@@ -242,7 +204,7 @@
}
String parentid = buf.toString();
String id = st.nextToken();
- this.addNode(parentid, id, labels, href, suffix, link, refDocumentId);
+ addNode(parentid, id, labels, href, suffix, link, refDocumentId);
}
/**
@@ -251,7 +213,7 @@
*/
public synchronized void addNode(String documentid, Label[] labels, String href, String suffix,
boolean link) throws SiteException {
- this.addNode(documentid, labels, href, suffix, link, null);
+ addNode(documentid, labels, href, suffix, link, null);
}
/**
@@ -260,7 +222,7 @@
*/
public synchronized void addNode(String parentid, String id, Label[] labels, String href,
String suffix, boolean link) throws SiteException {
- this.addNode(parentid, id, labels, href, suffix, link, null);
+ addNode(parentid, id, labels, href, suffix, link, null);
}
/**
@@ -290,7 +252,8 @@
}
// Create node
- NamespaceHelper helper = new NamespaceHelper(NAMESPACE_URI, "", this.document);
+ Document document = load();
+ NamespaceHelper helper = new NamespaceHelper(NAMESPACE_URI, "", document);
Element child = helper.createElement(SiteTreeNodeImpl.NODE_NAME);
child.setAttribute(SiteTreeNodeImpl.ID_ATTRIBUTE_NAME, id);
@@ -329,7 +292,8 @@
} else {
parentNode.appendChild(child);
}
- getLogger().debug("Tree has been modified: " + this.document.getDocumentElement());
+ getLogger().debug("Tree has been modified: " + document.getDocumentElement());
+ SourceUtil.registerDirty(this.sourceUri, this.manager);
}
@@ -342,6 +306,7 @@
if (node != null) {
node.addLabel(label);
}
+ SourceUtil.registerDirty(this.sourceUri, this.manager);
}
/**
@@ -353,6 +318,7 @@
if (node != null) {
node.removeLabel(label);
}
+ SourceUtil.registerDirty(this.sourceUri, this.manager);
}
/**
@@ -361,8 +327,12 @@
public synchronized SiteTreeNode removeNode(String documentId) {
assert documentId != null;
- Node node = removeNodeInternal(documentId);
-
+ Node node;
+ try {
+ node = removeNodeInternal(documentId);
+ } catch (SiteException e) {
+ throw new RuntimeException(e);
+ }
if (node == null) {
return null;
}
@@ -376,12 +346,13 @@
* removes the node corresponding to the given document-id and returns it
* @param documentId the document-id of the Node to be removed
* @return the <code>Node</code> that was removed
+ * @throws SiteException
*/
- private synchronized Node removeNodeInternal(String documentId) {
+ private synchronized Node removeNodeInternal(String documentId) throws SiteException {
Node node = this.getNodeInternal(documentId);
Node parentNode = node.getParentNode();
Node newNode = parentNode.removeChild(node);
-
+ SourceUtil.registerDirty(this.sourceUri, this.manager);
return newNode;
}
@@ -391,8 +362,9 @@
* @param documentId the document-id of the Node that we're trying to get
*
* @return the Node if there is a Node for the given document-id, null otherwise
+ * @throws SiteException
*/
- private synchronized Node getNodeInternal(String documentId) {
+ private synchronized Node getNodeInternal(String documentId) throws SiteException {
StringTokenizer st = new StringTokenizer(documentId, "/");
ArrayList ids = new ArrayList();
@@ -400,7 +372,7 @@
ids.add(st.nextToken());
}
- Node node = findNode(this.document.getDocumentElement(), ids);
+ Node node = findNode(load().getDocumentElement(), ids);
return node;
}
@@ -412,7 +384,12 @@
SiteTreeNode treeNode = null;
- Node node = getNodeInternal(documentId);
+ Node node;
+ try {
+ node = getNodeInternal(documentId);
+ } catch (SiteException e) {
+ throw new RuntimeException(e);
+ }
if (node != null) {
treeNode = new SiteTreeNodeImpl(node);
ContainerUtil.enableLogging(treeNode, getLogger());
@@ -427,9 +404,15 @@
public SiteTreeNode[] getTopNodes() {
List childElements = new ArrayList();
- NamespaceHelper helper = new NamespaceHelper(NAMESPACE_URI, "", this.document);
+ Document doc;
+ try {
+ doc = load();
+ } catch (SiteException e) {
+ throw new RuntimeException(e);
+ }
+ NamespaceHelper helper = new NamespaceHelper(NAMESPACE_URI, "", doc);
- Element[] elements = helper.getChildren(this.document.getDocumentElement(),
+ Element[] elements = helper.getChildren(doc.getDocumentElement(),
SiteTreeNodeImpl.NODE_NAME);
for (int i = 0; i < elements.length; i++) {
@@ -470,6 +453,7 @@
}
Node insertNode = parentNode.removeChild(node);
parentNode.insertBefore(insertNode, previousNode);
+ SourceUtil.registerDirty(this.sourceUri, this.manager);
}
/**
@@ -504,6 +488,7 @@
} else {
parentNode.insertBefore(insertNode, nextNode);
}
+ SourceUtil.registerDirty(this.sourceUri, this.manager);
}
/**
@@ -531,21 +516,13 @@
for (int i = 0; i < children.length; i++) {
importSubtree(newParent, children[i], children[i].getId(), null);
}
+ SourceUtil.registerDirty(this.sourceUri, this.manager);
}
/**
* @see org.apache.lenya.cms.site.tree.SiteTree#save()
*/
public synchronized void save() throws TransactionException {
- try {
- DocumentHelper.writeDocument(this.document, this.treefile);
- } catch (TransformerException e) {
- throw new TransactionException("The document [" + this.document.getLocalName()
- + "] could not be transformed");
- } catch (IOException e) {
- throw new TransactionException("The saving of document ["
- + this.document.getLocalName() + "] failed");
- }
}
/**
@@ -557,87 +534,40 @@
if (node != null) {
node.setLabel(label);
}
+ SourceUtil.registerDirty(this.sourceUri, this.manager);
}
/**
* @see org.apache.lenya.transaction.Transactionable#checkin()
*/
public void checkin() throws TransactionException {
- checkin(true);
- }
-
- protected void checkin(boolean backup) throws TransactionException {
- try {
- String userName = getUserID();
- boolean newVersion = this.identityMap.getUnitOfWork().isDirty(this);
- getRevisionController().reservedCheckIn(getRCPath(), userName, backup, newVersion);
- isCheckedOut = false;
- } catch (Exception e) {
- throw new TransactionException(e);
- }
- }
-
- /**
- * @return The username of the unit of work's identity.
- */
- protected String getUserID() {
- String userName = null;
- UnitOfWork unit = this.identityMap.getUnitOfWork();
- Identity identity = unit.getIdentity();
- User user = identity.getUser();
- if (user != null) {
- userName = user.getId();
- }
- return userName;
}
/**
* @see org.apache.lenya.transaction.Transactionable#checkout()
*/
public void checkout() throws TransactionException {
- try {
- String userName = getUserID();
- getRevisionController().reservedCheckOut(getRCPath(), userName);
- isCheckedOut = true;
- } catch (Exception e) {
- throw new TransactionException(e);
- }
}
-
- protected String getRCPath() {
- return this.area + "/" + SITE_TREE_FILENAME;
- }
-
- private boolean isCheckedOut = false;
-
- /**
- * @see org.apache.lenya.transaction.Transactionable#isCheckedOut()
- */
- public boolean isCheckedOut() throws TransactionException {
- return isCheckedOut;
- }
-
- private Lock lock;
/**
* @see org.apache.lenya.transaction.Transactionable#lock()
*/
public void lock() throws TransactionException {
- this.lock = new Lock(getVersion());
+ SourceUtil.lock(this.sourceUri, this.manager);
}
/**
* @see org.apache.lenya.transaction.Transactionable#unlock()
*/
public void unlock() throws TransactionException {
- this.lock = null;
+ SourceUtil.unlock(this.sourceUri, this.manager);
}
/**
* @see org.apache.lenya.transaction.Transactionable#isLocked()
*/
public boolean isLocked() throws TransactionException {
- return this.lock != null;
+ return false;
}
/**
@@ -659,43 +589,25 @@
public void create() throws TransactionException {
}
- private RevisionController revisionController;
-
- protected RevisionController getRevisionController() throws TransactionException {
- if (this.revisionController == null) {
- try {
- String publicationPath = this.publication.getDirectory().getCanonicalPath();
- RCEnvironment rcEnvironment = RCEnvironment.getInstance(this.publication
- .getServletContext().getCanonicalPath());
- String rcmlDirectory = publicationPath + File.separator
- + rcEnvironment.getRCMLDirectory();
- String backupDirectory = publicationPath + File.separator
- + rcEnvironment.getBackupDirectory();
-
- this.revisionController = new RevisionController(rcmlDirectory, backupDirectory,
- publicationPath);
- } catch (IOException e) {
- throw new TransactionException(e);
- }
- }
- return this.revisionController;
- }
-
/**
* @see org.apache.lenya.transaction.Transactionable#getLock()
*/
public Lock getLock() {
- return this.lock;
+ return null;
}
/**
- * @see org.apache.lenya.transaction.Transactionable#getVersion()
+ * @see org.apache.lenya.transaction.Transactionable#hasChanged()
*/
- public int getVersion() throws TransactionException {
- try {
- return getRevisionController().getLatestVersion(getRCPath());
- } catch (Exception e) {
- throw new TransactionException(e);
- }
+ public boolean hasChanged() throws TransactionException {
+ return false;
}
+
+ /**
+ * @see org.apache.lenya.transaction.Transactionable#isCheckedOut()
+ */
+ public boolean isCheckedOut() throws TransactionException {
+ return false;
+ }
+
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTree.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTree.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTree.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTree.java Thu Apr 7 02:30:55 2005
@@ -19,14 +19,14 @@
import org.apache.lenya.cms.site.Label;
import org.apache.lenya.cms.site.SiteException;
-import org.apache.lenya.transaction.Transactionable;
+import org.apache.lenya.cms.site.SiteStructure;
/**
* A sitetree.
*
* @version $Id$
*/
-public interface SiteTree extends Transactionable {
+public interface SiteTree extends SiteStructure {
/**
* The type of sitetree transactionable objects.
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeFactory.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeFactory.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeFactory.java Thu Apr 7 02:30:55 2005
@@ -68,7 +68,7 @@
Publication publication = factory.getPublication(publicationId, servletContext
.getAbsolutePath());
- tree = new DefaultSiteTree(publication.getDirectory(), area);
+ tree = new DefaultSiteTree(publication, area, this.manager);
tree.setup(map, publication);
ContainerUtil.enableLogging(tree, getLogger());
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java Thu Apr 7 02:30:55 2005
@@ -32,6 +32,7 @@
import org.apache.lenya.cms.site.AbstractSiteManager;
import org.apache.lenya.cms.site.Label;
import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.SiteStructure;
import org.apache.lenya.transaction.TransactionException;
import org.apache.lenya.transaction.TransactionableFactory;
@@ -154,8 +155,7 @@
if (getLogger().isDebugEnabled()) {
getLogger().debug("Obtaining requiring resources completed.");
}
- }
- else {
+ } else {
resources = new Document[0];
}
@@ -248,11 +248,6 @@
destinationTree.setLabel(destinationDocument.getId(), label);
}
- try {
- sourceDocument.getIdentityMap().getUnitOfWork().registerDirty(destinationTree);
- } catch (TransactionException e) {
- throw new SiteException(e);
- }
}
/**
@@ -285,11 +280,6 @@
if (node.getLabels().length == 0) {
tree.removeNode(document.getId());
}
- try {
- document.getIdentityMap().getUnitOfWork().registerDirty(tree);
- } catch (TransactionException e) {
- throw new SiteException(e);
- }
}
/**
@@ -310,11 +300,6 @@
SiteTree tree = getTree(document);
tree.setLabel(document.getId(), labelObject);
- try {
- document.getIdentityMap().getUnitOfWork().registerDirty(tree);
- } catch (TransactionException e) {
- throw new SiteException(e);
- }
}
/**
@@ -376,11 +361,6 @@
if (node == null) {
Label[] labels = { label };
tree.addNode(document.getId(), labels, null, null, false);
- try {
- document.getIdentityMap().getUnitOfWork().registerDirty(tree);
- } catch (TransactionException e) {
- throw new SiteException(e);
- }
} else {
tree.addLabel(document.getId(), label);
}
@@ -403,6 +383,15 @@
*/
public void service(ServiceManager manager) throws ServiceException {
this.manager = manager;
+ }
+
+ /**
+ * @see org.apache.lenya.cms.site.SiteManager#getSiteStructure(org.apache.lenya.cms.publication.DocumentIdentityMap,
+ * org.apache.lenya.cms.publication.Publication, java.lang.String)
+ */
+ public SiteStructure getSiteStructure(DocumentIdentityMap map, Publication publiation,
+ String area) throws SiteException {
+ return getTree(map, publiation, area);
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java Thu Apr 7 02:30:55 2005
@@ -27,8 +27,6 @@
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.cocoon.components.ContextHelper;
import org.apache.cocoon.environment.Request;
@@ -44,8 +42,7 @@
*
* @version $Id$
*/
-public class AbstractUsecase extends AbstractOperation implements Usecase, Contextualizable,
- Configurable {
+public class AbstractUsecase extends AbstractOperation implements Usecase, Configurable {
/**
* Ctor.
@@ -400,15 +397,6 @@
return (Part) getParameter(name);
}
- private Context context;
-
- /**
- * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
- */
- public void contextualize(Context _context) throws ContextException {
- this.context = _context;
- }
-
protected DocumentIdentityMap getDocumentIdentityMap() {
try {
return (DocumentIdentityMap) getUnitOfWork().getIdentityMap();
@@ -508,6 +496,12 @@
*/
public void setView(UsecaseView view) {
this.view = view;
+ }
+
+ /**
+ * @see org.apache.lenya.cms.usecase.Usecase#lockInvolvedObjects()
+ */
+ public void lockInvolvedObjects() throws UsecaseException {
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/usecase/Usecase.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/usecase/Usecase.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/usecase/Usecase.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/usecase/Usecase.java Thu Apr 7 02:30:55 2005
@@ -105,6 +105,12 @@
* system.
*/
void checkExecutionConditions() throws UsecaseException;
+
+ /**
+ * Locks all objects that are involved in the transaction.
+ * @throws UsecaseException if an error occurs.
+ */
+ void lockInvolvedObjects() throws UsecaseException;
/**
* Returns the error messages from the previous operation. Error messages
Modified: lenya/trunk/src/java/org/apache/lenya/cms/usecase/scheduling/UsecaseCronJob.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/usecase/scheduling/UsecaseCronJob.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/usecase/scheduling/UsecaseCronJob.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/usecase/scheduling/UsecaseCronJob.java Thu Apr 7 02:30:55 2005
@@ -119,6 +119,7 @@
if (!errorMessages.isEmpty()) {
logErrorMessages("Pre condition messages:", errorMessages);
} else {
+ usecase.lockInvolvedObjects();
usecase.checkExecutionConditions();
errorMessages = usecase.getErrorMessages();
if (!errorMessages.isEmpty()) {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/workflow/CMSHistory.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/workflow/CMSHistory.java?view=diff&r1=160395&r2=160396
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/workflow/CMSHistory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/workflow/CMSHistory.java Thu Apr 7 02:30:55 2005
@@ -19,9 +19,7 @@
package org.apache.lenya.cms.workflow;
-import java.io.File;
-
-import org.apache.lenya.cms.publication.Document;
+import org.apache.avalon.framework.service.ServiceManager;
import org.apache.lenya.workflow.Situation;
import org.apache.lenya.workflow.Version;
import org.apache.lenya.workflow.Workflow;
@@ -33,45 +31,22 @@
* The CMS history
*/
public class CMSHistory extends History {
- private Document document;
+ // private Document document;
/**
* <code>HISTORY_PATH</code> The path to the workflow history
*/
public static final String HISTORY_PATH = "content/workflow/history";
-
+
/**
* Ctor.
- * @param document The document.
- * @param file The history file.
+ * @param sourceUri The source URI.
+ * @param manager The service manager.
* @throws WorkflowException if an error occurs.
*/
- public CMSHistory(Document document, File file) throws WorkflowException {
- super(file);
- this.document = document;
- }
-
- /**
- * Additionally to deleting the workflow history, the parent directories are
- * deleted up to the workflow history directory.
- * @see org.apache.lenya.cms.workflow.History#delete()
- */
- public void delete() throws WorkflowException {
- super.delete();
-
- File stopDirectory = new File(document.getPublication().getDirectory(), HISTORY_PATH);
- if (!stopDirectory.isDirectory())
- throw new WorkflowException("Stop dir '" + stopDirectory.getAbsolutePath()
- + "' is not a directory");
- if (!getHistoryFile().getAbsolutePath().startsWith(stopDirectory.getAbsolutePath()))
- throw new WorkflowException("Start dir '" + getHistoryFile().getAbsolutePath()
- + "' is not a descending sibling of stop directory '"
- + stopDirectory.getAbsolutePath() + "'.");
-
- File parent = getHistoryFile().getParentFile();
-
- while (!parent.equals(stopDirectory) && parent.delete())
- parent = parent.getParentFile();
+ public CMSHistory(String sourceUri, ServiceManager manager) throws WorkflowException {
+ super(sourceUri, manager);
+ // this.document = document;
}
/**
@@ -120,8 +95,7 @@
/**
* @see org.apache.lenya.cms.workflow.History.VersionWrapper#initialize(org.apache.lenya.workflow.Workflow,
- * org.apache.lenya.workflow.Version,
- * org.apache.lenya.workflow.Situation)
+ * org.apache.lenya.workflow.Version, org.apache.lenya.workflow.Situation)
*/
public void initialize(Workflow workflow, Version version, Situation situation) {
super.initialize(workflow, version, situation);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org