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 2007/02/15 13:15:34 UTC
svn commit: r507914 [1/3] - in /lenya/trunk/src:
impl/java/org/apache/lenya/cms/publication/
impl/java/org/apache/lenya/cms/repository/
impl/test/org/apache/lenya/ac/impl/
impl/test/org/apache/lenya/cms/publication/
impl/test/org/apache/lenya/cms/publi...
Author: andreas
Date: Thu Feb 15 04:15:30 2007
New Revision: 507914
URL: http://svn.apache.org/viewvc?view=rev&rev=507914
Log:
Use isolated sessions for transactions to avoid 'hanging' modifications. Introduce SharedItemStore to improve performance.
Added:
lenya/trunk/src/impl/java/org/apache/lenya/cms/repository/SharedItemStoreImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySourceValidity.java
lenya/trunk/src/java/org/apache/lenya/cms/repository/SharedItemStore.java
lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/StateMachine.java
lenya/trunk/src/webapp/lenya/config/cocoon-xconf/misc/shared-item-store.xconf
Modified:
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationFactory.java
lenya/trunk/src/impl/test/org/apache/lenya/ac/impl/AbstractAccessControlTest.java
lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java
lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java
lenya/trunk/src/impl/test/org/apache/lenya/cms/site/SimpleSiteManagerTest.java
lenya/trunk/src/impl/test/org/apache/lenya/cms/usecase/AbstractUsecaseTest.java
lenya/trunk/src/impl/test/org/apache/lenya/cms/workflow/WorkflowTest.java
lenya/trunk/src/impl/test/org/apache/lenya/transaction/MockTransactionable.java
lenya/trunk/src/impl/test/org/apache/lenya/transaction/TransactionTest.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/MetaDataModule.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/LenyaMetaDataGenerator.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/util/XlinkCollection.java
lenya/trunk/src/java/org/apache/lenya/cms/repository/Node.java
lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItemFactory.java
lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryManager.java
lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryManagerImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryUtil.java
lenya/trunk/src/java/org/apache/lenya/cms/repository/Session.java
lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java
lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java
lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java
lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWork.java
lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWorkImpl.java
lenya/trunk/src/java/org/apache/lenya/xml/ValidationUtil.java
lenya/trunk/src/modules-core/ac/java/test/org/apache/lenya/ac/impl/IdentityTest.java
lenya/trunk/src/modules-core/acusecases/test/canoo/test.xml
lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/ContentLinkManager.java
lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkConverter.java
lenya/trunk/src/modules-core/observation/java/test/org/apache/lenya/cms/observation/ObservationTest.java
lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/AbstractUsecase.java
lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/DocumentUsecase.java
lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/Usecase.java
lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/UsecaseInvoker.java
lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/impl/TestUsecaseInvoker.java
lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/impl/UsecaseInvokerImpl.java
lenya/trunk/src/modules-optional/jcrsource/java/src/org/apache/lenya/cms/jcr/JCRNodeFactory.java
lenya/trunk/src/modules-optional/jcrsource/java/src/org/apache/lenya/cms/jcr/usecases/Import.java
lenya/trunk/src/modules/blog/java/src/org/apache/cocoon/generation/BlogOverviewGenerator.java
lenya/trunk/src/modules/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java
lenya/trunk/src/modules/blog/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java
lenya/trunk/src/modules/cforms/java/src/org/apache/lenya/cms/editors/cforms/CForms.java
lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/EditDocument.java
lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/forms/FormsEditor.java
lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/forms/OneFormEditor.java
lenya/trunk/src/modules/export/java/src/org/apache/lenya/cms/export/Importer.java
lenya/trunk/src/modules/export/java/test/org/apache/lenya/cms/export/ImportTest.java
lenya/trunk/src/modules/fckeditor/java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java
lenya/trunk/src/modules/lucene/java/test/org/apache/lenya/cms/lucene/IndexUpdaterTest.java
lenya/trunk/src/modules/migration/java/test/org/apache/lenya/cms/migration/MigrateUuidsTest.java
lenya/trunk/src/modules/opendocument/java/src/org/apache/lenya/cms/site/usecases/UploadOpenDocument.java
lenya/trunk/src/modules/repository/java/src/org/apache/lenya/cms/repo/adapter/RepoNode.java
lenya/trunk/src/modules/repository/java/src/org/apache/lenya/cms/repo/adapter/RepoNodeFactory.java
lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/publication/ResourceWrapper.java
lenya/trunk/src/modules/resource/java/test/org/apache/lenya/cms/publication/ResourceWrapperTest.java
lenya/trunk/src/modules/resource/java/test/org/apache/lenya/cms/site/usecases/ResourceLinkRewriterTest.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeFactory.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeNodeImpl.java
lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java
lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeFactory.java
lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java
lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java
lenya/trunk/src/modules/tinymce/java/src/org/apache/lenya/cms/editors/tinymce/TinyMce.java
lenya/trunk/src/modules/usecasedocument/java/src/org/apache/lenya/cms/cocoon/components/modules/input/UsecaseDocumentModule.java
lenya/trunk/src/modules/usecasedocument/java/src/org/apache/lenya/cms/site/usecases/CreateUsecaseDocument.java
lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java
Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java Thu Feb 15 04:15:30 2007
@@ -181,7 +181,7 @@
webappUrl);
if (publication.exists()) {
DocumentBuilder builder = publication.getDocumentBuilder();
- if (builder.isDocument(webappUrl)) {
+ if (builder.isDocument(this, webappUrl)) {
DocumentLocator locator = builder.getLocator(this, webappUrl);
String area = locator.getArea();
String path = locator.getPath();
@@ -346,6 +346,10 @@
manager.release(pubManager);
}
}
+ }
+
+ public boolean isSharable() {
+ return false;
}
}
Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java Thu Feb 15 04:15:30 2007
@@ -19,6 +19,8 @@
package org.apache.lenya.cms.publication;
import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -404,7 +406,7 @@
*/
public void delete() throws DocumentException {
try {
- SourceUtil.delete(getSourceURI(), this.manager);
+ getRepositoryNode().delete();
} catch (Exception e) {
throw new DocumentException(e);
}
@@ -525,11 +527,16 @@
}
}
+ private Node repositoryNode;
+
/**
* @see org.apache.lenya.cms.publication.Document#getRepositoryNode()
*/
public Node getRepositoryNode() {
- return getRepositoryNode(this.manager, getFactory(), getSourceURI());
+ if (this.repositoryNode == null) {
+ this.repositoryNode = getRepositoryNode(this.manager, getFactory(), getSourceURI());
+ }
+ return this.repositoryNode;
}
protected static Node getRepositoryNode(ServiceManager manager, DocumentFactory docFactory,
@@ -622,6 +629,22 @@
MetaData meta = getMetaData(DocumentImpl.METADATA_NAMESPACE);
meta.setValue(DocumentImpl.METADATA_EXTENSION, extension);
} catch (MetaDataException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public OutputStream getOutputStream() {
+ try {
+ return getRepositoryNode().getOutputStream();
+ } catch (RepositoryException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public InputStream getInputStream() {
+ try {
+ return getRepositoryNode().getInputStream();
+ } catch (RepositoryException e) {
throw new RuntimeException(e);
}
}
Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java Thu Feb 15 04:15:30 2007
@@ -17,6 +17,9 @@
*/
package org.apache.lenya.cms.publication;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
@@ -31,15 +34,16 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.avalon.framework.service.Serviceable;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+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.metadata.MetaData;
import org.apache.lenya.cms.metadata.MetaDataException;
import org.apache.lenya.cms.publication.util.DocumentSet;
import org.apache.lenya.cms.publication.util.DocumentVisitor;
import org.apache.lenya.cms.repository.Node;
import org.apache.lenya.cms.repository.RepositoryException;
-import org.apache.lenya.cms.repository.RepositoryManager;
import org.apache.lenya.cms.repository.UUIDGenerator;
import org.apache.lenya.cms.site.Link;
import org.apache.lenya.cms.site.NodeIterator;
@@ -61,23 +65,16 @@
/**
* @see org.apache.lenya.cms.publication.DocumentManager#add(org.apache.lenya.cms.publication.Document,
- * java.lang.String, java.lang.String, java.lang.String, java.lang.String,
- * java.lang.String, boolean)
+ * java.lang.String, java.lang.String, java.lang.String,
+ * java.lang.String, java.lang.String, boolean)
*/
public Document add(Document sourceDocument, String area, String path, String language,
String extension, String navigationTitle, boolean visibleInNav)
throws DocumentBuildException, PublicationException {
- Document document = add(sourceDocument.getFactory(),
- sourceDocument.getResourceType(),
- sourceDocument.getSourceURI(),
- sourceDocument.getPublication(),
- area,
- path,
- language,
- extension,
- navigationTitle,
- visibleInNav);
+ Document document = add(sourceDocument.getFactory(), sourceDocument.getResourceType(),
+ sourceDocument.getInputStream(), sourceDocument.getPublication(), area, path,
+ language, extension, navigationTitle, visibleInNav);
copyMetaData(sourceDocument, document);
return document;
@@ -89,8 +86,7 @@
* @param destination
* @throws PublicationException
*/
- protected void copyMetaData(Document source, Document destination)
- throws PublicationException {
+ protected void copyMetaData(Document source, Document destination) throws PublicationException {
try {
String[] uris = source.getMetaDataNamespaceUris();
for (int i = 0; i < uris.length; i++) {
@@ -102,15 +98,16 @@
}
/**
- * Copies meta data from one document to another, whereas both documents will have
- * completely identical meta data afterwards (including workflow etc.). This is only
- * useful if the source document will be deleted afterwards.
+ * Copies meta data from one document to another, whereas both documents
+ * will have completely identical meta data afterwards (including workflow
+ * etc.). This is only useful if the source document will be deleted
+ * afterwards.
* @param source
* @param destination
* @throws PublicationException
*/
protected void duplicateMetaData(Document source, Document destination)
- throws PublicationException {
+ throws PublicationException {
try {
String[] uris = source.getMetaDataNamespaceUris();
for (int i = 0; i < uris.length; i++) {
@@ -124,8 +121,9 @@
/**
* @see org.apache.lenya.cms.publication.DocumentManager#add(org.apache.lenya.cms.publication.DocumentFactory,
* org.apache.lenya.cms.publication.ResourceType, java.lang.String,
- * org.apache.lenya.cms.publication.Publication, java.lang.String, java.lang.String,
- * java.lang.String, java.lang.String, java.lang.String, boolean)
+ * org.apache.lenya.cms.publication.Publication, java.lang.String,
+ * java.lang.String, java.lang.String, java.lang.String,
+ * java.lang.String, boolean)
*/
public Document add(DocumentFactory factory, ResourceType documentType,
String initialContentsURI, Publication pub, String area, String path, String language,
@@ -139,12 +137,26 @@
+ "] is already contained in site [" + site + "]");
}
- Document document = add(factory,
- documentType,
- initialContentsURI,
- pub,
- area,
- language,
+ Document document = add(factory, documentType, initialContentsURI, pub, area, language,
+ extension);
+
+ addToSiteManager(path, document, navigationTitle, visibleInNav);
+ return document;
+ }
+
+ protected Document add(DocumentFactory factory, ResourceType documentType,
+ InputStream initialContentsStream, Publication pub, String area, String path,
+ String language, String extension, String navigationTitle, boolean visibleInNav)
+ throws DocumentBuildException, DocumentException, PublicationException {
+
+ Area areaObj = pub.getArea(area);
+ SiteStructure site = areaObj.getSite();
+ if (site.contains(path) && site.getNode(path).hasLink(language)) {
+ throw new DocumentException("The link [" + path + ":" + language
+ + "] is already contained in site [" + site + "]");
+ }
+
+ Document document = add(factory, documentType, initialContentsStream, pub, area, language,
extension);
addToSiteManager(path, document, navigationTitle, visibleInNav);
@@ -157,12 +169,38 @@
PublicationException {
String uuid = generateUUID();
- return add(factory, documentType, uuid, initialContentsURI, pub, area, language, extension);
+ SourceResolver resolver = null;
+ Source source = null;
+ try {
+ resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+ source = resolver.resolveURI(initialContentsURI);
+ return add(factory, documentType, uuid, source.getInputStream(), pub, area, language,
+ extension);
+ } catch (Exception e) {
+ throw new PublicationException(e);
+ } finally {
+ if (resolver != null) {
+ if (source != null) {
+ resolver.release(source);
+ }
+ this.manager.release(resolver);
+ }
+ }
+ }
+
+ protected Document add(DocumentFactory factory, ResourceType documentType,
+ InputStream initialContentsStream, Publication pub, String area, String language,
+ String extension) throws DocumentBuildException, DocumentException,
+ PublicationException {
+
+ String uuid = generateUUID();
+ return add(factory, documentType, uuid, initialContentsStream, pub, area, language,
+ extension);
}
protected Document add(DocumentFactory factory, ResourceType documentType, String uuid,
- String initialContentsURI, Publication pub, String area, String language,
- String extension) throws DocumentBuildException {
+ InputStream stream, Publication pub, String area, String language, String extension)
+ throws DocumentBuildException {
try {
if (exists(factory, pub, area, uuid, language)) {
@@ -184,10 +222,9 @@
if (getLogger().isDebugEnabled()) {
getLogger().debug("Create");
getLogger().debug(" document: [" + document + "]");
- getLogger().debug(" contents URI: [" + initialContentsURI + "]");
}
- create(initialContentsURI, document);
+ create(stream, document);
return document;
} catch (Exception e) {
throw new DocumentBuildException("call to creator for new document failed", e);
@@ -212,17 +249,18 @@
return uuid;
}
- protected void create(String initialContentsURI, Document document) throws Exception {
+ protected void create(InputStream stream, Document document) throws Exception {
// Read initial contents as DOM
if (getLogger().isDebugEnabled())
- getLogger().debug("DefaultCreator::create(), ready to read initial contents from URI ["
- + initialContentsURI + "]");
+ getLogger().debug(
+ "DefaultCreator::create(), ready to read initial contents from URI [" + stream
+ + "]");
SourceResolver resolver = null;
try {
resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
- SourceUtil.copy(resolver, initialContentsURI, document.getSourceURI());
+ copy(resolver, stream, document);
} finally {
if (resolver != null) {
this.manager.release(resolver);
@@ -230,11 +268,42 @@
}
}
+ protected void copy(SourceResolver resolver, InputStream sourceInputStream, Document destination)
+ throws IOException {
+
+ boolean useBuffer = true;
+
+ Source source = null;
+ OutputStream destOutputStream = null;
+ try {
+ destOutputStream = destination.getOutputStream();
+
+ if (useBuffer) {
+ final ByteArrayOutputStream sourceBos = new ByteArrayOutputStream();
+ IOUtils.copy(sourceInputStream, sourceBos);
+ IOUtils.write(sourceBos.toByteArray(), destOutputStream);
+ } else {
+ IOUtils.copy(sourceInputStream, destOutputStream);
+ }
+ } finally {
+ if (destOutputStream != null) {
+ destOutputStream.flush();
+ destOutputStream.close();
+ }
+ if (sourceInputStream != null) {
+ sourceInputStream.close();
+ }
+ if (source != null) {
+ resolver.release(source);
+ }
+ }
+ }
+
protected void addToSiteManager(String path, Document document, String navigationTitle,
boolean visibleInNav) throws PublicationException {
addToSiteManager(path, document, navigationTitle, visibleInNav, null);
}
-
+
protected void addToSiteManager(String path, Document document, String navigationTitle,
boolean visibleInNav, String followingSiblingPath) throws PublicationException {
SiteStructure site = document.area().getSite();
@@ -247,20 +316,25 @@
}
/**
- * Template method to copy a document. Override {@link #copyDocumentSource(Document, Document)}
- * to implement access to a custom repository.
+ * Template method to copy a document. Override
+ * {@link #copyDocumentSource(Document, Document)} to implement access to a
+ * custom repository.
* @see org.apache.lenya.cms.publication.DocumentManager#copy(org.apache.lenya.cms.publication.Document,
* org.apache.lenya.cms.publication.DocumentLocator)
*/
public void copy(Document sourceDocument, DocumentLocator destination)
throws PublicationException {
- add(sourceDocument,
- destination.getArea(),
- destination.getPath(),
- destination.getLanguage(),
- sourceDocument.getExtension(),
- sourceDocument.getLink().getLabel(),
- sourceDocument.getLink().getNode().isVisible());
+ SiteStructure destSite = sourceDocument.getPublication().getArea(destination.getArea())
+ .getSite();
+ if (destSite.contains(destination.getPath(), destination.getLanguage())) {
+ Document destDoc = destSite.getNode(destination.getPath()).getLink(
+ destination.getLanguage()).getDocument();
+ copyDocumentSource(sourceDocument, destDoc);
+ } else {
+ add(sourceDocument, destination.getArea(), destination.getPath(), destination
+ .getLanguage(), sourceDocument.getExtension(), sourceDocument.getLink()
+ .getLabel(), sourceDocument.getLink().getNode().isVisible());
+ }
}
/**
@@ -292,8 +366,8 @@
selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());
if (siteManager.getSiteStructure(sourceDocument.getFactory(),
- sourceDocument.getPublication(),
- destination.getArea()).contains(destination.getPath())) {
+ sourceDocument.getPublication(), destination.getArea()).contains(
+ destination.getPath())) {
throw new PublicationException("The path [" + destination
+ "] is already contained in this publication!");
}
@@ -332,11 +406,11 @@
Document destinationDoc;
if (sourceDoc.existsAreaVersion(destinationArea)) {
destinationDoc = sourceDoc.getAreaVersion(destinationArea);
- copyContent(sourceDoc, destinationDoc);
+ copyDocumentSource(sourceDoc, destinationDoc);
} else {
destinationDoc = addVersion(sourceDoc, destinationArea, language);
}
-
+
SiteStructure destSite = sourceDoc.getPublication().getArea(destinationArea).getSite();
if (sourceDoc.hasLink()) {
@@ -350,24 +424,22 @@
if (destSite.contains(sourceDoc.getLink().getNode().getPath())) {
addToSiteManager(path, destinationDoc, label, visible);
} else {
-
+
SiteStructure sourceSite = sourceDoc.area().getSite();
-
+
SiteNode[] sourceSiblings;
SiteNode sourceNode = sourceDoc.getLink().getNode();
if (sourceNode.isTopLevel()) {
sourceSiblings = sourceSite.getTopLevelNodes();
- }
- else if (sourceNode.getParent() != null) {
+ } else if (sourceNode.getParent() != null) {
sourceSiblings = sourceNode.getParent().getChildren();
- }
- else {
+ } else {
sourceSiblings = new SiteNode[1];
sourceSiblings[0] = sourceNode;
}
-
+
final int sourcePos = Arrays.asList(sourceSiblings).indexOf(sourceNode);
-
+
String followingSiblingPath = null;
int pos = sourcePos;
while (followingSiblingPath == null && pos < sourceSiblings.length) {
@@ -377,11 +449,10 @@
}
pos++;
}
-
+
if (followingSiblingPath == null) {
addToSiteManager(path, destinationDoc, label, visible);
- }
- else {
+ } else {
addToSiteManager(path, destinationDoc, label, visible, followingSiblingPath);
}
}
@@ -391,21 +462,6 @@
}
/**
- * Copies content, resources, and meta data.
- * @param sourceDoc The source document.
- * @param destinationDoc The destination document.
- * @throws PublicationException if an error occurs.
- */
- protected void copyContent(Document sourceDoc, Document destinationDoc) throws PublicationException {
- try {
- SourceUtil.copy(this.manager, sourceDoc.getSourceURI(), destinationDoc.getSourceURI());
- copyMetaData(sourceDoc, destinationDoc);
- } catch (Exception e) {
- throw new PublicationException(e);
- }
- }
-
- /**
* @see org.apache.lenya.cms.publication.DocumentManager#copyToArea(org.apache.lenya.cms.publication.util.DocumentSet,
* java.lang.String)
*/
@@ -471,16 +527,16 @@
Link sourceLink = sourceNode.getLink(languages[i]);
String label = sourceLink.getLabel();
Document sourceDoc = sourceLink.getDocument();
-
+
Document targetDoc;
if (sourceArea.getName().equals(targetArea.getName())) {
targetDoc = sourceDoc;
- }
- else {
- targetDoc = duplicateVersion(sourceDoc, targetArea.getName(), sourceDoc.getLanguage());
+ } else {
+ targetDoc = duplicateVersion(sourceDoc, targetArea.getName(), sourceDoc
+ .getLanguage());
sourceDoc.delete();
}
-
+
sourceLink.delete();
Link link = targetArea.getSite().add(targetPath, targetDoc);
link.setLabel(label);
@@ -517,26 +573,17 @@
for (int i = 0; i < languages.length; i++) {
Document sourceVersion = sourceNode.getLink(languages[i]).getDocument();
- DocumentLocator targetLocator = DocumentLocator.getLocator(pub.getId(),
- targetArea.getName(),
- targetPath,
- languages[i]);
+ DocumentLocator targetLocator = DocumentLocator.getLocator(pub.getId(), targetArea
+ .getName(), targetPath, languages[i]);
if (targetDoc == null) {
copy(sourceVersion, targetLocator.getLanguageVersion(languages[i]));
- targetDoc = targetArea.getSite()
- .getNode(targetPath)
- .getLink(languages[i])
+ targetDoc = targetArea.getSite().getNode(targetPath).getLink(languages[i])
.getDocument();
} else {
targetDoc = addVersion(targetDoc, targetLocator.getArea(), languages[i]);
addToSiteManager(targetLocator.getPath(), targetDoc, sourceVersion.getLink()
.getLabel(), sourceVersion.getLink().getNode().isVisible());
- try {
- SourceUtil.copy(manager, sourceVersion.getSourceURI(), targetDoc.getSourceURI());
- } catch (Exception e) {
- throw new PublicationException(e);
- }
- copyMetaData(sourceVersion, targetDoc);
+ copyDocumentSource(sourceVersion, targetDoc);
}
}
}
@@ -550,22 +597,42 @@
public void copyDocumentSource(Document sourceDocument, Document destinationDocument)
throws PublicationException {
- RepositoryManager repoManager = null;
+ boolean useBuffer = true;
+
+ OutputStream destOutputStream = null;
+ InputStream sourceInputStream = null;
try {
- repoManager = (RepositoryManager) this.manager.lookup(RepositoryManager.ROLE);
- repoManager.copy(sourceDocument.getRepositoryNode(),
- destinationDocument.getRepositoryNode());
+ try {
+ sourceInputStream = sourceDocument.getInputStream();
+ destOutputStream = destinationDocument.getOutputStream();
+
+ if (useBuffer) {
+ final ByteArrayOutputStream sourceBos = new ByteArrayOutputStream();
+ IOUtils.copy(sourceInputStream, sourceBos);
+ IOUtils.write(sourceBos.toByteArray(), destOutputStream);
+ } else {
+ IOUtils.copy(sourceInputStream, destOutputStream);
+ }
+ } finally {
+ if (destOutputStream != null) {
+ destOutputStream.flush();
+ destOutputStream.close();
+ }
+ if (sourceInputStream != null) {
+ sourceInputStream.close();
+ }
+ }
} catch (Exception e) {
throw new PublicationException(e);
- } finally {
- if (repoManager != null) {
- this.manager.release(repoManager);
- }
}
+
+ copyMetaData(sourceDocument, destinationDocument);
+
}
/**
- * Abstract base class for document visitors which operate on a source and target document.
+ * Abstract base class for document visitors which operate on a source and
+ * target document.
*/
public abstract class SourceTargetVisitor implements DocumentVisitor {
@@ -607,7 +674,8 @@
}
/**
- * Returns the target corresponding to a source relatively to the root target document.
+ * Returns the target corresponding to a source relatively to the root
+ * target document.
* @param source The source.
* @return A document.
* @throws DocumentBuildException if the target could not be built.
@@ -743,17 +811,20 @@
* Document[] sourceDocs = sources.getDocuments(); Document[] targetDocs =
* destinations.getDocuments();
*
- * if (sourceDocs.length != targetDocs.length) { throw new PublicationException( "The number
- * of source and destination documents must be equal!"); }
+ * if (sourceDocs.length != targetDocs.length) { throw new
+ * PublicationException( "The number of source and destination documents
+ * must be equal!"); }
*
- * Map source2target = new HashMap(); for (int i = 0; i < sourceDocs.length; i++) {
- * source2target.put(sourceDocs[i], targetDocs[i]); }
+ * Map source2target = new HashMap(); for (int i = 0; i <
+ * sourceDocs.length; i++) { source2target.put(sourceDocs[i],
+ * targetDocs[i]); }
*
* DocumentSet sortedSources = new DocumentSet(sourceDocs);
- * SiteUtil.sortAscending(this.manager, sortedSources); Document[] sortedSourceDocs =
- * sortedSources.getDocuments();
+ * SiteUtil.sortAscending(this.manager, sortedSources); Document[]
+ * sortedSourceDocs = sortedSources.getDocuments();
*
- * for (int i = 0; i < sortedSourceDocs.length; i++) { move(sortedSourceDocs[i], (Document)
+ * for (int i = 0; i < sortedSourceDocs.length; i++) {
+ * move(sortedSourceDocs[i], (Document)
* source2target.get(sortedSourceDocs[i])); }
*/
}
@@ -767,7 +838,8 @@
Document[] targetDocs = destinations.getDocuments();
if (sourceDocs.length != targetDocs.length) {
- throw new PublicationException("The number of source and destination documents must be equal!");
+ throw new PublicationException(
+ "The number of source and destination documents must be equal!");
}
Map source2target = new HashMap();
@@ -780,8 +852,8 @@
Document[] sortedSourceDocs = sortedSources.getDocuments();
for (int i = 0; i < sortedSourceDocs.length; i++) {
- copy(sortedSourceDocs[i],
- ((Document) source2target.get(sortedSourceDocs[i])).getLocator());
+ copy(sortedSourceDocs[i], ((Document) source2target.get(sortedSourceDocs[i]))
+ .getLocator());
}
}
@@ -804,7 +876,8 @@
nodes.add(docs[i].getLink().getNode());
}
- SiteNode[] ascending = siteManager.sortAscending((SiteNode[]) nodes.toArray(new SiteNode[nodes.size()]));
+ SiteNode[] ascending = siteManager.sortAscending((SiteNode[]) nodes
+ .toArray(new SiteNode[nodes.size()]));
set.clear();
for (int i = 0; i < ascending.length; i++) {
@@ -847,14 +920,9 @@
public Document addVersion(Document sourceDocument, String area, String language)
throws DocumentBuildException, DocumentException, PublicationException {
- Document document = add(sourceDocument.getFactory(),
- sourceDocument.getResourceType(),
- sourceDocument.getUUID(),
- sourceDocument.getSourceURI(),
- sourceDocument.getPublication(),
- area,
- language,
- sourceDocument.getSourceExtension());
+ Document document = add(sourceDocument.getFactory(), sourceDocument.getResourceType(),
+ sourceDocument.getUUID(), sourceDocument.getInputStream(), sourceDocument
+ .getPublication(), area, language, sourceDocument.getSourceExtension());
copyMetaData(sourceDocument, document);
return document;
@@ -862,14 +930,9 @@
protected Document duplicateVersion(Document sourceDocument, String area, String language)
throws DocumentBuildException, DocumentException, PublicationException {
- Document document = add(sourceDocument.getFactory(),
- sourceDocument.getResourceType(),
- sourceDocument.getUUID(),
- sourceDocument.getSourceURI(),
- sourceDocument.getPublication(),
- area,
- language,
- sourceDocument.getSourceExtension());
+ Document document = add(sourceDocument.getFactory(), sourceDocument.getResourceType(),
+ sourceDocument.getUUID(), sourceDocument.getInputStream(), sourceDocument
+ .getPublication(), area, language, sourceDocument.getSourceExtension());
duplicateMetaData(sourceDocument, document);
return document;
}
Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationFactory.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationFactory.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationFactory.java Thu Feb 15 04:15:30 2007
@@ -52,4 +52,8 @@
return Publication.ITEM_TYPE;
}
+ public boolean isSharable() {
+ return true;
+ }
+
}
Added: lenya/trunk/src/impl/java/org/apache/lenya/cms/repository/SharedItemStoreImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/repository/SharedItemStoreImpl.java?view=auto&rev=507914
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/repository/SharedItemStoreImpl.java (added)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/repository/SharedItemStoreImpl.java Thu Feb 15 04:15:30 2007
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.repository;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.lenya.ac.Identity;
+import org.apache.lenya.cms.observation.RepositoryEvent;
+import org.apache.lenya.cms.observation.RepositoryListener;
+import org.apache.lenya.transaction.IdentityMap;
+import org.apache.lenya.transaction.IdentityMapImpl;
+import org.apache.lenya.transaction.Lock;
+import org.apache.lenya.transaction.Lockable;
+import org.apache.lenya.transaction.TransactionException;
+import org.apache.lenya.transaction.Transactionable;
+
+/**
+ * Shared item store implementation.
+ */
+public class SharedItemStoreImpl extends AbstractLogEnabled implements SharedItemStore, ThreadSafe {
+
+ private IdentityMap map;
+
+ protected IdentityMap getIdentityMap() {
+ if (this.map == null) {
+ this.map = new IdentityMapImpl(getLogger());
+ }
+ return this.map;
+ }
+
+ public void addListener(RepositoryListener listener) throws RepositoryException {
+ throw new IllegalStateException("Operation not permitted.");
+ }
+
+ public void commit() throws RepositoryException {
+ throw new IllegalStateException("Operation not permitted.");
+ }
+
+ public void enqueueEvent(RepositoryEvent event) {
+ throw new IllegalStateException("Operation not permitted.");
+ }
+
+ public Identity getIdentity() {
+ throw new IllegalStateException("Operation not permitted.");
+ }
+
+ public RepositoryItem getRepositoryItem(RepositoryItemFactory factory, String key) throws RepositoryException {
+ RepositoryItemFactoryWrapper wrapper = new RepositoryItemFactoryWrapper(factory, this);
+ return (RepositoryItem) getIdentityMap().get(wrapper, key);
+ }
+
+ public boolean isListenerRegistered(RepositoryListener listener) {
+ return false;
+ }
+
+ public boolean isModifiable() {
+ return false;
+ }
+
+ public void rollback() throws RepositoryException {
+ throw new IllegalStateException("Operation not permitted.");
+ }
+
+ public void setIdentity(Identity identity) {
+ throw new IllegalStateException("Operation not permitted.");
+ }
+
+ public Lock createLock(Lockable lockable, int version) throws TransactionException {
+ throw new IllegalStateException("Operation not permitted.");
+ }
+
+ public boolean isDirty(Transactionable transactionable) {
+ return false;
+ }
+
+ public void registerDirty(Transactionable object) throws TransactionException {
+ throw new IllegalStateException("Operation not permitted.");
+ }
+
+ public void registerNew(Transactionable object) throws TransactionException {
+ throw new IllegalStateException("Operation not permitted.");
+ }
+
+ public void registerRemoved(Transactionable object) throws TransactionException {
+ throw new IllegalStateException("Operation not permitted.");
+ }
+
+ public void removeLock(Lockable lockable) throws TransactionException {
+ throw new IllegalStateException("Operation not permitted.");
+ }
+
+}
Modified: lenya/trunk/src/impl/test/org/apache/lenya/ac/impl/AbstractAccessControlTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/ac/impl/AbstractAccessControlTest.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/ac/impl/AbstractAccessControlTest.java (original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/ac/impl/AbstractAccessControlTest.java Thu Feb 15 04:15:30 2007
@@ -23,7 +23,6 @@
import java.io.File;
import org.apache.avalon.framework.service.ServiceSelector;
-import org.apache.cocoon.environment.Session;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.AccessControllerResolver;
import org.apache.lenya.ac.Accreditable;
@@ -38,7 +37,8 @@
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.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.Session;
+import org.apache.lenya.cms.repository.SessionImpl;
/**
* To change the template for this generated type comment go to
@@ -46,22 +46,28 @@
*/
public class AbstractAccessControlTest extends LenyaTestCase {
+ protected static final String TEST_PUB_ID = "test";
private ServiceSelector accessControllerResolverSelector;
private AccessControllerResolver accessControllerResolver;
private DefaultAccessController accessController;
- protected void login(String userId) throws AccessControlException {
+ protected org.apache.lenya.cms.repository.Session login(String userId)
+ throws AccessControlException {
- User user = getAccreditableManager().getUserManager().getUser(userId);
+ Session session = new SessionImpl(null, true, getManager(), getLogger());
+
+ DefaultAccessController ac = getAccessController(session, TEST_PUB_ID);
+ AccreditableManager acMgr = ac.getAccreditableManager();
+ User user = acMgr.getUserManager().getUser(userId);
if (user == null) {
throw new AccessControlException("The user [" + userId + "] does not exist!");
}
- getAccessController().setupIdentity(getRequest());
+ ac.setupIdentity(getRequest());
- Session session = getRequest().getSession();
- Identity identity = (Identity) session.getAttribute(Identity.class.getName());
+ org.apache.cocoon.environment.Session cocoonSession = getRequest().getSession();
+ Identity identity = (Identity) cocoonSession.getAttribute(Identity.class.getName());
if (!identity.contains(user)) {
User oldUser = identity.getUser();
@@ -74,29 +80,22 @@
identity.addIdentifiable(user);
}
- getAccessController().authorize(getRequest());
+ ac.authorize(getRequest());
Accreditable[] accrs = identity.getAccreditables();
for (int i = 0; i < accrs.length; i++) {
getLogger().info("Accreditable: " + accrs[i]);
}
+ session.setIdentity(identity);
+ return session;
}
- /**
- * Returns the access controller.
- * @return An access controller.
- */
- public DefaultAccessController getAccessController() {
- String pubId = "test";
- if (this.accessController == null) {
- DefaultAccessController controller = getAccessController(pubId);
- this.accessController = controller;
- }
- return this.accessController;
+ protected DefaultAccessController getAccessController() {
+ return getAccessController(getSession(), TEST_PUB_ID);
}
- protected DefaultAccessController getAccessController(String pubId) {
+ protected DefaultAccessController getAccessController(Session session, String pubId) {
DefaultAccessController controller;
try {
this.accessControllerResolverSelector = (ServiceSelector) getManager().lookup(
@@ -111,7 +110,7 @@
"Using access controller resolver: ["
+ this.accessControllerResolver.getClass() + "]");
- Publication pub = getPublication(pubId);
+ Publication pub = getPublication(session, pubId);
getLogger().info("Resolve access controller");
getLogger().info(
"Publication directory: [" + pub.getDirectory().getAbsolutePath() + "]");
@@ -149,22 +148,6 @@
protected static final String USERNAME = "lenya";
/**
- * Returns the identity.
- * @return The identity.
- * @throws AccessControlException when something went wrong.
- */
- protected Identity getIdentity() throws AccessControlException {
- DefaultAccessController controller = getAccessController();
- User user = controller.getAccreditableManager().getUserManager().getUser(USERNAME);
- assertNotNull(user);
-
- Identity identity = new Identity(getLogger());
- identity.addIdentifiable(user);
-
- return identity;
- }
-
- /**
* Returns the policy manager.
* @return A policy manager.
*/
@@ -185,36 +168,36 @@
return accrMgr.getConfigurationDirectory();
}
- private DocumentFactory factory;
-
protected DocumentFactory getFactory() {
+ return DocumentUtil.createDocumentFactory(getManager(), getSession());
+ }
- Session cocoonSession = getRequest().getSession();
- Identity identity = (Identity) cocoonSession.getAttribute(Identity.class.getName());
+ protected DocumentFactory getFactory(Session session) {
+ return DocumentUtil.createDocumentFactory(getManager(), session);
+ }
- if (identity == null) {
- org.apache.lenya.cms.repository.Session session;
- try {
- session = RepositoryUtil.getSession(getManager(), getRequest());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- return DocumentUtil.createDocumentFactory(getManager(), session);
- }
+ private Session session;
- if (this.factory == null) {
- org.apache.lenya.cms.repository.Session session;
+ protected Session getSession() {
+ if (this.session == null) {
try {
- session = RepositoryUtil.getSession(getManager(), getRequest());
- } catch (Exception e) {
+ this.session = login("lenya");
+ } catch (AccessControlException e) {
throw new RuntimeException(e);
}
- this.factory = DocumentUtil.createDocumentFactory(getManager(), session);
}
- return this.factory;
+ return this.session;
+ }
+
+ protected Publication getPublication(Session session, String pubId) throws PublicationException {
+ return getFactory(session).getPublication(pubId);
}
protected Publication getPublication(String id) throws PublicationException {
return getFactory().getPublication(id);
+ }
+
+ protected Identity getIdentity() {
+ return getSession().getIdentity();
}
}
Modified: lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java (original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/TestPageEnvelope.java Thu Feb 15 04:15:30 2007
@@ -42,7 +42,7 @@
setContext("");
try {
- Session session = RepositoryUtil.createSession(manager, null);
+ Session session = RepositoryUtil.createSession(manager, null, false);
DocumentFactory map = DocumentUtil.createDocumentFactory(manager, session);
setDocument(map.getFromURL(url));
} catch (Exception e) {
Modified: lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java (original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java Thu Feb 15 04:15:30 2007
@@ -29,7 +29,6 @@
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
import org.apache.lenya.cms.publication.ResourceType;
-import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.cms.site.SiteManager;
import org.apache.lenya.cms.site.SiteStructure;
@@ -49,7 +48,7 @@
public void testXLinkCollection() throws PublicationException, AccessControlException,
TransactionException, ServiceException {
- Session session = RepositoryUtil.createSession(getManager(), getIdentity());
+ Session session = login("lenya");
DocumentFactory map = DocumentUtil.createDocumentFactory(getManager(), session);
Publication pub = getPublication("test");
@@ -90,7 +89,6 @@
assertSame(collection.getDelegate().getRepositoryNode(), coll2.getDelegate()
.getRepositoryNode());
- assertEquals(collection.getDelegate().getSourceURI(), coll2.getDelegate().getSourceURI());
assertEquals(coll2.size(), 1);
assertTrue(coll2.contains(doc));
Modified: lenya/trunk/src/impl/test/org/apache/lenya/cms/site/SimpleSiteManagerTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/cms/site/SimpleSiteManagerTest.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/cms/site/SimpleSiteManagerTest.java (original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/cms/site/SimpleSiteManagerTest.java Thu Feb 15 04:15:30 2007
@@ -46,9 +46,8 @@
public void testSimpleSiteManager() throws Exception {
- login("lenya");
+ Session session = login("lenya");
- Session session = RepositoryUtil.getSession(getManager(), getRequest());
DocumentFactory factory = DocumentUtil.createDocumentFactory(getManager(), session);
Publication[] pubs = factory.getPublications();
@@ -78,7 +77,7 @@
ResourceType type = (ResourceType) resourceTypeSelector.select("entry");
String contentSourceUri = "context://sitemap.xmap";
- Document doc = docManager.add(getFactory(), type, contentSourceUri, pub,
+ Document doc = docManager.add(factory, type, contentSourceUri, pub,
Publication.AUTHORING_AREA, "en", "xml");
structure.add(PATH, doc);
Modified: lenya/trunk/src/impl/test/org/apache/lenya/cms/usecase/AbstractUsecaseTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/cms/usecase/AbstractUsecaseTest.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/cms/usecase/AbstractUsecaseTest.java (original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/cms/usecase/AbstractUsecaseTest.java Thu Feb 15 04:15:30 2007
@@ -22,8 +22,8 @@
import java.util.List;
import java.util.Map;
-import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.impl.AbstractAccessControlTest;
+import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.cms.usecase.impl.TestUsecaseInvoker;
/**
@@ -37,12 +37,13 @@
*/
public void testUsecase() throws Exception {
- login();
+ Session session = getSession();
prepareUsecase();
UsecaseInvoker invoker = null;
try {
invoker = (UsecaseInvoker) getManager().lookup(TestUsecaseInvoker.ROLE);
+ invoker.setTestSession(session);
invoker.invoke(getRequest().getPathInfo(), getUsecaseName(), getParameters());
this.targetUrl = invoker.getTargetUrl();
@@ -79,10 +80,6 @@
throw new IllegalStateException("The usecase has not yet been executed.");
}
return this.targetUrl;
- }
-
- protected void login() throws AccessControlException {
- login("lenya");
}
protected void prepareUsecase() throws Exception {
Modified: lenya/trunk/src/impl/test/org/apache/lenya/cms/workflow/WorkflowTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/cms/workflow/WorkflowTest.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/cms/workflow/WorkflowTest.java (original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/cms/workflow/WorkflowTest.java Thu Feb 15 04:15:30 2007
@@ -21,14 +21,11 @@
package org.apache.lenya.cms.workflow;
import org.apache.lenya.ac.AccessControlException;
-import org.apache.lenya.ac.Identity;
-import org.apache.lenya.ac.User;
import org.apache.lenya.ac.impl.AbstractAccessControlTest;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentFactory;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.repository.RepositoryException;
-import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.workflow.Version;
import org.apache.lenya.workflow.WorkflowException;
@@ -108,14 +105,8 @@
protected Session getSession(TestSituation situation) throws AccessControlException,
RepositoryException {
- login(situation.getUser());
-
- Identity identity = (Identity) getRequest().getSession()
- .getAttribute(Identity.class.getName());
- User user = identity.getUser();
- getLogger().info("User: [" + user + "]");
-
- Session session = RepositoryUtil.createSession(getManager(), identity);
+ Session session = login(situation.getUser());
+ getLogger().info("User: [" + session.getIdentity().getUser() + "]");
return session;
}
Modified: lenya/trunk/src/impl/test/org/apache/lenya/transaction/MockTransactionable.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/transaction/MockTransactionable.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/transaction/MockTransactionable.java (original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/transaction/MockTransactionable.java Thu Feb 15 04:15:30 2007
@@ -80,7 +80,7 @@
}
private String getUserId() {
- return this.unit.getIdentity().getUser().getId();
+ return ((UnitOfWorkImpl) this.unit).getIdentity().getUser().getId();
}
private Lock lock;
Modified: lenya/trunk/src/impl/test/org/apache/lenya/transaction/TransactionTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/transaction/TransactionTest.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/transaction/TransactionTest.java (original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/transaction/TransactionTest.java Thu Feb 15 04:15:30 2007
@@ -32,12 +32,10 @@
IdentityMap lenyaMap = new IdentityMapImpl(getLogger());
UnitOfWork lenyaUnit = new UnitOfWorkImpl(lenyaMap, lenya, getLogger());
- lenyaUnit.setIdentity(lenya);
IdentifiableFactory lenyaFactory = new MockFactory(lenyaUnit);
IdentityMap aliceMap = new IdentityMapImpl(getLogger());
UnitOfWork aliceUnit = new UnitOfWorkImpl(aliceMap, alice, getLogger());
- lenyaUnit.setIdentity(alice);
IdentifiableFactory aliceFactory = new MockFactory(aliceUnit);
MockTransactionable lenyaT1 = (MockTransactionable) lenyaMap.get(lenyaFactory, "t1");
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/MetaDataModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/MetaDataModule.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/MetaDataModule.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/MetaDataModule.java Thu Feb 15 04:15:30 2007
@@ -133,7 +133,7 @@
metaData = document.getMetaData(this.namespaceUri);
} catch (MetaDataException e) {
throw new ConfigurationException("Obtaining custom meta data value for ["
- + document.getSourceURI() + "] failed: ", e);
+ + document + "] failed: ", e);
}
return metaData;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/LenyaMetaDataGenerator.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/LenyaMetaDataGenerator.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/LenyaMetaDataGenerator.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/LenyaMetaDataGenerator.java Thu Feb 15 04:15:30 2007
@@ -297,7 +297,7 @@
metaData = this.document.getMetaData(namespaceUri);
} catch (Exception e1) {
throw new ProcessingException("Obtaining custom meta data value for ["
- + document.getSourceURI() + "] failed: ", e1);
+ + document + "] failed: ", e1);
}
return metaData;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java Thu Feb 15 04:15:30 2007
@@ -37,12 +37,12 @@
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.SourceNotFoundException;
+import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.AbstractSource;
import org.apache.lenya.cms.repository.ContentHolder;
import org.apache.lenya.cms.repository.Node;
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.Session;
import org.apache.lenya.util.Query;
@@ -168,16 +168,10 @@
* @see org.apache.excalibur.source.ModifiableSource#delete()
*/
public void delete() {
- RepositoryManager repoManager = null;
try {
- repoManager = (RepositoryManager) this.manager.lookup(RepositoryManager.ROLE);
- repoManager.delete(getNode());
- } catch (Exception e) {
+ getNode().delete();
+ } catch (RepositoryException e) {
throw new RuntimeException(e);
- } finally {
- if (repoManager != null) {
- this.manager.release(repoManager);
- }
}
}
@@ -368,4 +362,15 @@
throw new RuntimeException(e);
}
}
+
+ private SourceValidity validity;
+
+ public SourceValidity getValidity() {
+ if (this.validity == null) {
+ this.validity = new RepositorySourceValidity(this);
+ }
+ return this.validity;
+ }
+
+
}
Added: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySourceValidity.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySourceValidity.java?view=auto&rev=507914
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySourceValidity.java (added)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySourceValidity.java Thu Feb 15 04:15:30 2007
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.cocoon.source;
+
+import org.apache.excalibur.source.SourceValidity;
+import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.repository.RepositoryException;
+
+/**
+ * Validity for repository sources.
+ */
+public class RepositorySourceValidity implements SourceValidity {
+
+ private static final long serialVersionUID = 1L;
+
+ private Node node;
+
+ private long lastModified = -1;
+
+ /**
+ * @param source The source this validity is for.
+ */
+ public RepositorySourceValidity(RepositorySource source) {
+ this.node = source.getNode();
+ try {
+ this.lastModified = this.node.getLastModified();
+ } catch (RepositoryException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public int isValid() {
+ try {
+ if (getNode().getLastModified() == this.lastModified) {
+ return SourceValidity.VALID;
+ }
+ else {
+ return SourceValidity.INVALID;
+ }
+ } catch (RepositoryException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected Node getNode() {
+ return this.node;
+ }
+
+ public int isValid(SourceValidity validity) {
+ if (validity instanceof RepositorySourceValidity) {
+ RepositorySourceValidity repoValidity = (RepositorySourceValidity) validity;
+
+ if (!repoValidity.getNode().getSourceURI().equals(getNode().getSourceURI())) {
+ throw new RuntimeException("Wrong source URI!");
+ }
+
+ try {
+ if (getNode().getLastModified() >= repoValidity.getNode().getLastModified()) {
+ return SourceValidity.VALID;
+ }
+ else {
+ return SourceValidity.INVALID;
+ }
+ } catch (RepositoryException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ return SourceValidity.INVALID;
+ }
+ }
+
+}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- 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 Feb 15 04:15:30 2007
@@ -218,15 +218,7 @@
source = (ModifiableSource) resolver.resolveURI(sourceUri);
OutputStream oStream = source.getOutputStream();
- DocumentHelper.writeDocument(document, oStream);
- if (oStream != null) {
- oStream.flush();
- try {
- oStream.close();
- } catch (Throwable t) {
- throw new RuntimeException("Could not write document: ", t);
- }
- }
+ writeDOM(document, oStream);
} finally {
if (resolver != null) {
if (source != null) {
@@ -238,6 +230,26 @@
}
/**
+ * @param document The XML document.
+ * @param oStream The output stream.
+ * @throws TransformerConfigurationException if an error occurs.
+ * @throws TransformerException if an error occurs.
+ * @throws IOException if an error occurs.
+ */
+ public static void writeDOM(Document document, OutputStream oStream)
+ throws TransformerConfigurationException, TransformerException, IOException {
+ DocumentHelper.writeDocument(document, oStream);
+ if (oStream != null) {
+ oStream.flush();
+ try {
+ oStream.close();
+ } catch (Throwable t) {
+ throw new RuntimeException("Could not write document: ", t);
+ }
+ }
+ }
+
+ /**
* Deletes a source if it exists.
* @param sourceUri The source URI.
* @param manager The service manager.
@@ -557,6 +569,42 @@
resolver.release(source);
}
manager.release(resolver);
+ }
+ }
+ }
+
+ /**
+ * @param resolver
+ * @param sourceUri
+ * @param destOutputStream
+ * @throws MalformedURLException
+ * @throws IOException
+ */
+ public static void copy(SourceResolver resolver, String sourceUri, OutputStream destOutputStream) throws MalformedURLException, IOException {
+ boolean useBuffer = true;
+ InputStream sourceInputStream = null;
+ Source source = null;
+ try {
+ source = resolver.resolveURI(sourceUri);
+ sourceInputStream = source.getInputStream();
+
+ if (useBuffer) {
+ final ByteArrayOutputStream sourceBos = new ByteArrayOutputStream();
+ IOUtils.copy(sourceInputStream, sourceBos);
+ IOUtils.write(sourceBos.toByteArray(), destOutputStream);
+ } else {
+ IOUtils.copy(sourceInputStream, destOutputStream);
+ }
+ } finally {
+ if (destOutputStream != null) {
+ destOutputStream.flush();
+ destOutputStream.close();
+ }
+ if (sourceInputStream != null) {
+ sourceInputStream.close();
+ }
+ if (source != null) {
+ resolver.release(source);
}
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java Thu Feb 15 04:15:30 2007
@@ -22,8 +22,6 @@
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.environment.Request;
-import org.apache.lenya.cms.cocoon.components.context.ContextUtility;
import org.apache.lenya.cms.site.SiteNode;
/**
@@ -50,8 +48,8 @@
protected ServiceManager manager;
/**
- * Removes all "."-separated extensions from a URL (e.g., <code>/foo.print.html</code> is
- * transformed to <code>/foo</code>).
+ * Removes all "."-separated extensions from a URL (e.g.,
+ * <code>/foo.print.html</code> is transformed to <code>/foo</code>).
* @param url The URL to trim.
* @return A URL string.
*/
@@ -100,15 +98,11 @@
}
/**
- * @see org.apache.lenya.cms.publication.DocumentBuilder#isDocument(java.lang.String)
+ * @see org.apache.lenya.cms.publication.DocumentBuilder#isDocument(DocumentFactory,
+ * String)
*/
- public boolean isDocument(String url) throws DocumentBuildException {
-
- ContextUtility util = null;
+ public boolean isDocument(DocumentFactory factory, String url) throws DocumentBuildException {
try {
- util = (ContextUtility) this.manager.lookup(ContextUtility.ROLE);
- Request request = util.getRequest();
- DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
DocumentLocator locator = getLocatorWithoutCheck(factory, url);
if (locator != null) {
Publication pub = factory.getPublication(locator.getPublicationId());
@@ -123,10 +117,6 @@
}
} catch (Exception e) {
throw new DocumentBuildException(e);
- } finally {
- if (util != null) {
- this.manager.release(util);
- }
}
return false;
@@ -177,23 +167,24 @@
}
/**
- * Creates a document locator for a webapp URL without checking if the webapp URL refers to a
- * locator first.
+ * Creates a document locator for a webapp URL without checking if the
+ * webapp URL refers to a locator first.
* @param factory The document factory.
* @param webappUrl The webapp URL.
- * @return A document locator or <code>null</code> if the URL doesn't refer to a locator.
+ * @return A document locator or <code>null</code> if the URL doesn't
+ * refer to a locator.
* @throws DocumentBuildException if an error occurs.
*/
protected DocumentLocator getLocatorWithoutCheck(DocumentFactory factory, String webappUrl)
throws DocumentBuildException {
-
+
if (!webappUrl.startsWith("/")) {
return null;
}
if (webappUrl.substring(1).split("/").length < 3) {
return null;
}
-
+
URLInformation info = new URLInformation(webappUrl);
Publication publication;
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java Thu Feb 15 04:15:30 2007
@@ -19,6 +19,8 @@
package org.apache.lenya.cms.publication;
import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.util.Date;
import org.apache.lenya.cms.metadata.MetaDataOwner;
@@ -170,11 +172,18 @@
/**
* Returns the URI to resolve the document's source.
+ * The source can only be used for read-only access.
+ * For write access, use {@link #getOutputStream()}.
* @return A string.
*/
String getSourceURI();
/**
+ * @return The output stream to write the document content to.
+ */
+ OutputStream getOutputStream();
+
+ /**
* Accepts a document visitor.
* @param visitor The visitor.
* @throws PublicationException if an error occurs.
@@ -311,5 +320,10 @@
* @return if the document is linked in the site structure.
*/
boolean hasLink();
+
+ /**
+ * @return The input stream to obtain the document's content.
+ */
+ InputStream getInputStream();
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java Thu Feb 15 04:15:30 2007
@@ -41,11 +41,12 @@
/**
* Checks if an URL corresponds to a CMS document.
+ * @param factory The document factory.
* @param url The URL of the form /{publication-id}/...
* @return A boolean value.
* @throws DocumentBuildException when something went wrong.
*/
- boolean isDocument(String url) throws DocumentBuildException;
+ boolean isDocument(DocumentFactory factory, String url) throws DocumentBuildException;
/**
* Builds an URL corresponding to a CMS document.
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java Thu Feb 15 04:15:30 2007
@@ -28,14 +28,13 @@
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.lenya.cms.cocoon.source.SourceUtil;
-import org.apache.lenya.cms.metadata.MetaData;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentException;
-import org.apache.lenya.cms.publication.DocumentIdentifier;
import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.DocumentIdentifier;
import org.apache.lenya.transaction.TransactionException;
+import org.apache.lenya.xml.DocumentHelper;
import org.apache.lenya.xml.NamespaceHelper;
import org.apache.xpath.XPathAPI;
import org.w3c.dom.DOMException;
@@ -216,7 +215,7 @@
Element documentElement = createDocumentElement(documents[i], helper);
collectionElement.appendChild(documentElement);
}
- SourceUtil.writeDOM(helper.getDocument(), getDelegate().getSourceURI(), this.manager);
+ DocumentHelper.writeDocument(helper.getDocument(), getDelegate().getOutputStream());
} catch (Exception e) {
throw new TransactionException(e);
@@ -255,9 +254,8 @@
NamespaceHelper helper;
- if (SourceUtil.exists(getDelegate().getSourceURI(), this.manager)) {
- org.w3c.dom.Document document = SourceUtil.readDOM(getDelegate().getSourceURI(),
- this.manager);
+ if (getDelegate().exists()) {
+ org.w3c.dom.Document document = DocumentHelper.readDocument(getDelegate().getInputStream());
helper = new NamespaceHelper(Collection.NAMESPACE, Collection.DEFAULT_PREFIX, document);
} else {
helper = new NamespaceHelper(Collection.NAMESPACE,
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/XlinkCollection.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/XlinkCollection.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/XlinkCollection.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/XlinkCollection.java Thu Feb 15 04:15:30 2007
@@ -25,11 +25,10 @@
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
-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.DocumentIdentifier;
import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.DocumentIdentifier;
import org.apache.lenya.xml.NamespaceHelper;
import org.apache.lenya.xml.XLink;
import org.w3c.dom.Element;
@@ -75,7 +74,7 @@
* @throws DocumentException when something went wrong.
*/
protected String getXlinkHref(Document document) throws DocumentException {
- return document.getSourceURI();
+ return "lenya-document:" + document.getUUID();
}
/**
@@ -86,7 +85,7 @@
protected NamespaceHelper getNamespaceHelper() throws DocumentException,
ParserConfigurationException, SAXException, IOException, ServiceException {
NamespaceHelper helper = super.getNamespaceHelper();
- if (!SourceUtil.exists(getDelegate().getSourceURI(), this.manager)) {
+ if (!getDelegate().exists()) {
Element collectionElement = helper.getDocument().getDocumentElement();
String namespaceDeclaration = collectionElement.getAttributeNS("http://www.w3.org/2000/xmlns/",
"xlink");
Modified: lenya/trunk/src/java/org/apache/lenya/cms/repository/Node.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/repository/Node.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/repository/Node.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/repository/Node.java Thu Feb 15 04:15:30 2007
@@ -20,7 +20,6 @@
import java.io.OutputStream;
import java.util.Collection;
-import org.apache.lenya.cms.observation.RepositoryEvent;
import org.apache.lenya.cms.rc.RCML;
/**
@@ -133,5 +132,11 @@
* @return The revision history.
*/
History getHistory();
-
+
+ /**
+ * Delete this node.
+ * @throws RepositoryException if an error occurs.
+ */
+ void delete() throws RepositoryException;
+
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItemFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItemFactory.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItemFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItemFactory.java Thu Feb 15 04:15:30 2007
@@ -35,4 +35,9 @@
*/
RepositoryItem buildItem(Session session, String key) throws RepositoryException;
+ /**
+ * @return if the items can be shared by different read-only sessions.
+ */
+ boolean isSharable();
+
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryManager.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryManager.java Thu Feb 15 04:15:30 2007
@@ -31,25 +31,11 @@
String ROLE = RepositoryManager.class.getName();
/**
- * Copies a node.
- * @param source The source node.
- * @param destination The destination node.
- * @throws RepositoryException if an error occurs.
- */
- void copy(Node source, Node destination) throws RepositoryException;
-
- /**
- * Deletes a node.
- * @param node The node to delete.
- * @throws RepositoryException if an error occurs.
- */
- void delete(Node node) throws RepositoryException;
-
- /**
* @param identity The identity the session belongs to.
+ * @param modifiable Determines if the repository items in this session should be modifiable.
* @return A session.
* @throws RepositoryException if an error occurs.
*/
- Session createSession(Identity identity) throws RepositoryException;
+ Session createSession(Identity identity, boolean modifiable) throws RepositoryException;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryManagerImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryManagerImpl.java?view=diff&rev=507914&r1=507913&r2=507914
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryManagerImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryManagerImpl.java Thu Feb 15 04:15:30 2007
@@ -21,10 +21,7 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
-import org.apache.excalibur.source.SourceResolver;
import org.apache.lenya.ac.Identity;
-import org.apache.lenya.cms.cocoon.source.SourceUtil;
-import org.apache.lenya.transaction.IdentityMapImpl;
/**
* Repository manager implementation.
@@ -33,25 +30,6 @@
public class RepositoryManagerImpl extends AbstractLogEnabled implements RepositoryManager,
Serviceable {
- public void copy(Node source, Node destination) throws RepositoryException {
-
- SourceResolver resolver = null;
- try {
- resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
- String[] namespaces = source.getMetaDataNamespaceUris();
- for (int i = 0; i < namespaces.length; i++) {
- destination.getMetaData(namespaces[i]).replaceBy(source.getMetaData(namespaces[i]));
- }
- SourceUtil.copy(resolver, source.getSourceURI(), destination.getSourceURI());
- } catch (Exception e) {
- throw new RepositoryException(e);
- } finally {
- if (resolver != null) {
- this.manager.release(resolver);
- }
- }
- }
-
protected ServiceManager manager;
/**
@@ -61,15 +39,8 @@
this.manager = manager;
}
- /**
- * @see org.apache.lenya.cms.repository.RepositoryManager#delete(org.apache.lenya.cms.repository.Node)
- */
- public void delete(Node node) throws RepositoryException {
- node.registerRemoved();
- }
-
- public Session createSession(Identity identity) throws RepositoryException {
- return new SessionImpl(new IdentityMapImpl(getLogger()), identity, this.manager, getLogger());
+ public Session createSession(Identity identity, boolean modifiable) throws RepositoryException {
+ return new SessionImpl(identity, modifiable, this.manager, getLogger());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org