Author: andreas
Date: Fri Jul 29 09:42:59 2005
New Revision: 226394
URL: http://svn.apache.org/viewcvs?rev=226394&view=rev
Log:
Lock assets when documents are manipulated.
Added:
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/AssetUtil.java
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/MoveSubsite.java
lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
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?rev=226394&r1=226393&r2=226394&view=diff
==============================================================================
---
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
(original)
+++
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
Fri Jul 29 09:42:59 2005
@@ -595,6 +595,9 @@
* org.apache.lenya.cms.publication.util.DocumentSet)
*/
public void move(DocumentSet sources, DocumentSet destinations) throws
PublicationException {
+ copy(sources,destinations);
+ delete(sources);
+ /*
Document[] sourceDocs = sources.getDocuments();
Document[] targetDocs = destinations.getDocuments();
@@ -615,6 +618,7 @@
for (int i = 0; i < sortedSourceDocs.length; i++) {
move(sortedSourceDocs[i], (Document)
source2target.get(sortedSourceDocs[i]));
}
+ */
}
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java
URL:
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java?rev=226394&r1=226393&r2=226394&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java Fri Jul 29
09:42:59 2005
@@ -16,6 +16,9 @@
*/
package org.apache.lenya.cms.site;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.lenya.cms.publication.Document;
@@ -78,10 +81,8 @@
*/
public static SiteStructure getSiteStructure(ServiceManager manager,
Document document)
throws SiteException {
- return SiteUtil.getSiteStructure(manager,
- document.getIdentityMap(),
- document.getPublication(),
- document.getArea());
+ return SiteUtil.getSiteStructure(manager, document.getIdentityMap(),
document
+ .getPublication(), document.getArea());
}
/**
@@ -204,19 +205,89 @@
public static final int MODE_CHANGE_ID = 2;
/**
+ * Returns a document set that represents the transfer of a sub-site to
another location.
+ *
+ * @param manager The service manager.
+ * @param source The source document.
+ * @param target The target document.
+ * @param mode The mode: {@link #MODE_REPLACE},{@link #MODE_CANCEL},{@link
#MODE_CHANGE_ID}.
+ * @return A map which maps source to target documents.
+ * @throws SiteException if an error occurs.
+ */
+ public static Map getTransferedSubSite(ServiceManager manager, Document
source,
+ Document target, int mode) throws SiteException {
+ Map map = new HashMap();
+ ServiceSelector selector = null;
+ SiteManager siteManager = null;
+ try {
+ selector = (ServiceSelector) manager.lookup(SiteManager.ROLE +
"Selector");
+ siteManager = (SiteManager) selector.select(source.getPublication()
+ .getSiteManagerHint());
+
+ DocumentSet subSite = SiteUtil.getSubSite(manager, source);
+ Document[] docs = subSite.getDocuments();
+ for (int i = 0; i < docs.length; i++) {
+ Document targetDoc =
SiteUtil.getTransferedDocument(siteManager, docs[i], source,
+ target, mode);
+ if (targetDoc != null) {
+ map.put(docs[i], targetDoc);
+ }
+ }
+
+ } catch (Exception e) {
+ throw new SiteException(e);
+ } finally {
+ if (selector != null) {
+ if (siteManager != null) {
+ selector.release(siteManager);
+ }
+ manager.release(selector);
+ }
+ }
+ return map;
+ }
+
+ public static Document getTransferedDocument(SiteManager siteManager,
Document source,
+ Document baseSource, Document baseTarget, int mode) throws
SiteException,
+ DocumentException, DocumentBuildException {
+
+ String targetArea = baseTarget.getArea();
+ String sourceId = baseSource.getId();
+
+ String suffix = source.getId().substring(sourceId.length());
+ String targetId = baseTarget.getId() + suffix;
+
+ Document target =
source.getIdentityMap().get(baseTarget.getPublication(), targetArea,
+ targetId, source.getLanguage());
+ switch (mode) {
+ case MODE_REPLACE:
+ break;
+ case MODE_CANCEL:
+ if (target.exists()) {
+ target = null;
+ }
+ break;
+ case MODE_CHANGE_ID:
+ target = siteManager.getAvailableDocument(target);
+ break;
+ }
+ return target;
+ }
+
+ /**
* Returns a document set that represents the transfer of a sub-site to
another area.
*
* @param manager The service manager.
* @param source The source document.
* @param targetArea The target area.
* @param mode The mode: {@link #MODE_REPLACE},{@link #MODE_CANCEL},{@link
#MODE_CHANGE_ID}.
- * @return A document set.
+ * @return A map which maps sources to targets.
* @throws SiteException if an error occurs.
*/
- public static DocumentSet getTransferedSubSite(ServiceManager manager,
Document source,
+ public static Map getTransferedSubSite(ServiceManager manager, Document
source,
String targetArea, int mode) throws SiteException {
- DocumentSet set = new DocumentSet();
+ Map map = new HashMap();
ServiceSelector selector = null;
SiteManager siteManager = null;
try {
@@ -227,9 +298,10 @@
DocumentSet subSite = SiteUtil.getSubSite(manager, source);
Document[] docs = subSite.getDocuments();
for (int i = 0; i < docs.length; i++) {
- Document target = SiteUtil.getTransferedDocument(siteManager,
docs[i], targetArea, mode);
+ Document target = SiteUtil.getTransferedDocument(siteManager,
docs[i], targetArea,
+ mode);
if (target != null) {
- set.add(target);
+ map.put(docs[i], target);
}
}
@@ -243,7 +315,7 @@
manager.release(selector);
}
}
- return set;
+ return map;
}
public static Document getTransferedDocument(SiteManager siteManager,
Document source,
Added: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/AssetUtil.java
URL:
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/AssetUtil.java?rev=226394&view=auto
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/AssetUtil.java
(added)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/AssetUtil.java Fri
Jul 29 09:42:59 2005
@@ -0,0 +1,73 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation
+ *
+ * Licensed 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.site.usecases;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+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.publication.Document;
+import org.apache.lenya.cms.publication.Resource;
+import org.apache.lenya.cms.publication.ResourcesManager;
+
+/**
+ * Utility methods for asset handling.
+ */
+public final class AssetUtil {
+
+ public static List getAssetNodes(Document document, ServiceManager
manager, Logger logger)
+ throws ServiceException {
+ ResourcesManager resMgr = null;
+ List nodes = new ArrayList();
+ try {
+ resMgr = (ResourcesManager) manager.lookup(ResourcesManager.ROLE);
+ Resource[] resources = resMgr.getResources(document);
+ for (int i = 0; i < resources.length; i++) {
+ nodes.addAll(Arrays.asList(resources[i].getRepositoryNodes()));
+ }
+ } finally {
+ if (resMgr != null) {
+ manager.release(resMgr);
+ }
+ }
+ return nodes;
+ }
+
+ public static List getCopiedAssetNodes(Document sourceDocument, Document
targetDocument,
+ ServiceManager manager, Logger logger) throws ServiceException {
+ ResourcesManager resMgr = null;
+ List nodes = new ArrayList();
+ try {
+ resMgr = (ResourcesManager) manager.lookup(ResourcesManager.ROLE);
+ Resource[] resources = resMgr.getResources(sourceDocument);
+ for (int i = 0; i < resources.length; i++) {
+ Resource targetResource = new Resource(targetDocument,
resources[i].getName(),
+ manager, logger);
+
nodes.addAll(Arrays.asList(targetResource.getRepositoryNodes()));
+ }
+ } finally {
+ if (resMgr != null) {
+ manager.release(resMgr);
+ }
+ }
+ return nodes;
+ }
+
+}
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java
URL:
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java?rev=226394&r1=226393&r2=226394&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeNodeID.java
Fri Jul 29 09:42:59 2005
@@ -18,7 +18,9 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceSelector;
@@ -29,8 +31,11 @@
import org.apache.lenya.cms.publication.DocumentManager;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
+import org.apache.lenya.cms.publication.util.DocumentSet;
+import org.apache.lenya.cms.repository.Node;
import org.apache.lenya.cms.site.SiteManager;
import org.apache.lenya.cms.site.SiteStructure;
+import org.apache.lenya.cms.site.SiteUtil;
import org.apache.lenya.cms.usecase.DocumentUsecase;
import org.apache.lenya.cms.usecase.UsecaseException;
import org.apache.lenya.transaction.TransactionException;
@@ -61,29 +66,27 @@
*/
protected Transactionable[] getObjectsToLock() throws UsecaseException {
- SiteManager siteManager = null;
- ServiceSelector selector = null;
+ List nodes = new ArrayList();
+
try {
- Document doc = getSourceDocument();
- selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE
+ "Selector");
- siteManager = (SiteManager)
selector.select(doc.getPublication().getSiteManagerHint());
- SiteStructure structure =
siteManager.getSiteStructure(doc.getIdentityMap(), doc
- .getPublication(), doc.getArea());
-
- List objects = new ArrayList();
- objects.add(structure.getRepositoryNode());
- objects.addAll(getAllLanguageVersionNodes(doc));
- return (Transactionable[]) objects.toArray(new
Transactionable[objects.size()]);
+ Node siteNode = SiteUtil.getSiteStructure(this.manager,
getSourceDocument())
+ .getRepositoryNode();
+ nodes.add(siteNode);
+
+ Document sourceDocument = getSourceDocument();
+
+ DocumentSet subsite = SiteUtil.getSubSite(this.manager,
sourceDocument);
+ Document[] subsiteDocs = subsite.getDocuments();
+ for (int i = 0; i < subsiteDocs.length; i++) {
+
nodes.addAll(Arrays.asList(subsiteDocs[i].getRepositoryNodes()));
+ nodes.addAll(AssetUtil.getAssetNodes(subsiteDocs[i],
this.manager, getLogger()));
+ }
+
} catch (Exception e) {
throw new UsecaseException(e);
- } finally {
- if (selector != null) {
- if (siteManager != null) {
- selector.release(siteManager);
- }
- this.manager.release(selector);
- }
}
+
+ return (Transactionable[]) nodes.toArray(new
Transactionable[nodes.size()]);
}
protected List getAllLanguageVersionNodes(Document doc) throws
DocumentException,
@@ -123,8 +126,6 @@
protected void doCheckExecutionConditions() throws Exception {
super.doCheckExecutionConditions();
- DocumentIdentityMap identityMap = getSourceDocument().getIdentityMap();
-
String nodeId = getParameterAsString(NODE_ID);
DocumentManager documentManager = null;
try {
@@ -132,15 +133,7 @@
if (!documentManager.isValidDocumentName(nodeId)) {
addErrorMessage("The document ID is not valid.");
} else {
- Document parent = identityMap.getParent(getSourceDocument());
- String parentId = "";
- // if the document is at the top level, the parent is null
- if (parent != null) parentId = parent.getId();
- Publication publication = getSourceDocument().getPublication();
- Document document = identityMap.get(publication,
- getSourceDocument().getArea(),
- parentId + "/" + nodeId,
- getSourceDocument().getLanguage());
+ Document document = getTargetDocument();
if (document.exists()) {
addErrorMessage("The document does already exist.");
}
@@ -152,75 +145,63 @@
}
}
+ protected Document getTargetDocument() throws DocumentBuildException {
+ DocumentIdentityMap identityMap = getDocumentIdentityMap();
+ String nodeId = getParameterAsString(NODE_ID);
+ Document parent = identityMap.getParent(getSourceDocument());
+ String parentId = "";
+ // if the document is at the top level, the parent is null
+ if (parent != null)
+ parentId = parent.getId();
+ Publication publication = getSourceDocument().getPublication();
+ Document document = identityMap.get(publication,
getSourceDocument().getArea(), parentId
+ + "/" + nodeId, getSourceDocument().getLanguage());
+ return document;
+ }
+
/**
* @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
*/
protected void doExecute() throws Exception {
super.doExecute();
- Document document = getSourceDocument();
- Document newDocument = moveAllLanguageVersions(document);
-
+ Document source = getSourceDocument();
+ Document target = getTargetDocument();
+ DocumentManager documentManager = null;
LinkRewriter rewriter = null;
try {
- rewriter = (LinkRewriter) this.manager.lookup(LinkRewriter.ROLE);
- rewriter.rewriteLinks(document, newDocument);
- } finally {
- if (rewriter != null) {
- this.manager.release(rewriter);
- }
- }
-
- setTargetDocument(newDocument);
- }
-
- /**
- * Moves all language versions of a document.
- * @param document The document.
- * @return The moved version of the document.
- * @throws DocumentException if an error occurs.
- * @throws DocumentBuildException if an error occurs.
- * @throws PublicationException if an error occurs.
- * @throws ServiceException if an access error to a an Avalon service
occurs
- */
- protected Document moveAllLanguageVersions(Document document) throws
DocumentException,
- DocumentBuildException, PublicationException, ServiceException {
- Document newDocument = null;
-
- DocumentIdentityMap identityMap = document.getIdentityMap();
- String newDocumentId = getNewDocumentId();
- String[] availableLanguages = document.getLanguages();
+ DocumentSet subsite = SiteUtil.getSubSite(this.manager, source);
+ Map targets = SiteUtil.getTransferedSubSite(this.manager, source,
getTargetDocument(),
+ SiteUtil.MODE_CANCEL);
+ Document[] subsiteDocs = subsite.getDocuments();
+ List nodes = new ArrayList();
+ for (int i = 0; i < subsiteDocs.length; i++) {
+
+ Document targetSubsiteDoc = (Document)
targets.get(subsiteDocs[i]);
+
nodes.addAll(Arrays.asList(targetSubsiteDoc.getRepositoryNodes()));
+ nodes.addAll(AssetUtil.getCopiedAssetNodes(subsiteDocs[i],
targetSubsiteDoc,
+ this.manager, getLogger()));
+ }
+ for (Iterator i = nodes.iterator(); i.hasNext();) {
+ ((Node) i.next()).lock();
+ }
- DocumentManager documentManager = null;
- try {
documentManager = (DocumentManager)
this.manager.lookup(DocumentManager.ROLE);
- for (int i = 0; i < availableLanguages.length; i++) {
- Document languageVersion =
identityMap.get(document.getPublication(), document
- .getArea(), document.getId(), availableLanguages[i]);
-
- Document newLanguageVersion =
identityMap.get(document.getPublication(), document
- .getArea(), newDocumentId, availableLanguages[i]);
-
- Transactionable[] nodes =
newLanguageVersion.getRepositoryNodes();
- for (int j = 0; j < nodes.length; j++) {
- nodes[j].lock();
- }
- documentManager.move(languageVersion, newLanguageVersion);
+ documentManager.moveAll(source, target);
- if (availableLanguages[i].equals(document.getLanguage())) {
- newDocument = newLanguageVersion;
- }
- }
- } catch (TransactionException e) {
- throw new PublicationException(e);
+ rewriter = (LinkRewriter) this.manager.lookup(LinkRewriter.ROLE);
+ rewriter.rewriteLinks(source, target);
} finally {
if (documentManager != null) {
this.manager.release(documentManager);
}
+ if (rewriter != null) {
+ this.manager.release(rewriter);
+ }
}
- return newDocument;
+ setTargetDocument(getTargetDocument());
}
/**
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/MoveSubsite.java
URL:
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/MoveSubsite.java?rev=226394&r1=226393&r2=226394&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/MoveSubsite.java
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/MoveSubsite.java
Fri Jul 29 09:42:59 2005
@@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceSelector;
@@ -100,9 +101,9 @@
* Lock the following objects:
* <ul>
* <li>all involved documents in the document's area</li>
- * <li>the trash versions of these documents</li>
+ * <li>the target versions of these documents</li>
* <li>the document area's site structure</li>
- * <li>the trash site structure</li>
+ * <li>the target site structure</li>
* </ul>
* @see org.apache.lenya.cms.usecase.AbstractUsecase#getObjectsToLock()
*/
@@ -111,25 +112,31 @@
Document doc = getSourceDocument();
try {
DocumentSet sources = SiteUtil.getSubSite(this.manager, doc);
+ Map targets = SiteUtil.getTransferedSubSite(this.manager, doc,
getTargetArea(),
+ SiteUtil.MODE_CHANGE_ID);
+
Document[] docs = sources.getDocuments();
for (int i = 0; i < docs.length; i++) {
nodes.addAll(Arrays.asList(docs[i].getRepositoryNodes()));
+ nodes.addAll(AssetUtil.getAssetNodes(docs[i], this.manager,
getLogger()));
+
+ Document target = (Document) targets.get(docs[i]);
+ nodes.addAll(Arrays.asList(target.getRepositoryNodes()));
+ nodes.addAll(AssetUtil.getCopiedAssetNodes(docs[i], target,
this.manager,
+ getLogger()));
}
- DocumentSet targets = SiteUtil.getTransferedSubSite(this.manager,
- doc,
- getTargetArea(),
- SiteUtil.MODE_CHANGE_ID);
- targets.addAll(getTargetDocsToCopy());
- targets.addAll(getSourceDocsToDelete(sources));
- docs = targets.getDocuments();
+ DocumentSet furtherDocs = new DocumentSet();
+ furtherDocs.addAll(getTargetDocsToCopy());
+ furtherDocs.addAll(getSourceDocsToDelete(sources));
+ docs = furtherDocs.getDocuments();
for (int i = 0; i < docs.length; i++) {
nodes.addAll(Arrays.asList(docs[i].getRepositoryNodes()));
}
nodes.add(SiteUtil.getSiteStructure(this.manager,
doc).getRepositoryNode());
- nodes.add(SiteUtil.getSiteStructure(this.manager,
targets.getDocuments()[0])
- .getRepositoryNode());
+ nodes.add(SiteUtil.getSiteStructure(this.manager,
getDocumentIdentityMap(),
+ doc.getPublication(),
getTargetArea()).getRepositoryNode());
} catch (Exception e) {
throw new UsecaseException(e);
}
@@ -173,10 +180,13 @@
}
}
- DocumentSet targets = SiteUtil.getTransferedSubSite(this.manager,
- doc,
- getTargetArea(),
+ Map targetMap = SiteUtil.getTransferedSubSite(this.manager, doc,
getTargetArea(),
SiteUtil.MODE_CHANGE_ID);
+ DocumentSet targets = new DocumentSet();
+ Document[] docs = sources.getDocuments();
+ for (int i = 0; i < docs.length; i++) {
+ targets.add((Document) targetMap.get(docs[i]));
+ }
documentManager.move(sources, targets);
selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE
+ "Selector");
@@ -221,10 +231,8 @@
Node node = NodeFactory.getNode(doc);
Node[] requiredNodes = siteManager.getRequiredResources(map, node);
for (int i = 0; i < requiredNodes.length; i++) {
- Document targetDoc =
map.get(getSourceDocument().getPublication(),
- getTargetArea(),
- requiredNodes[i].getDocumentId(),
- doc.getLanguage());
+ Document targetDoc =
map.get(getSourceDocument().getPublication(), getTargetArea(),
+ requiredNodes[i].getDocumentId(), doc.getLanguage());
if (!siteManager.containsInAnyLanguage(targetDoc)) {
docsToCopy.add(targetDoc);
}
@@ -277,7 +285,8 @@
if (!sources.contains(langVersion)) {
LenyaMetaData meta =
langVersion.getMetaDataManager()
.getLenyaMetaData();
- String placeholder =
meta.getFirstValue(LenyaMetaData.ELEMENT_PLACEHOLDER);
+ String placeholder = meta
+
.getFirstValue(LenyaMetaData.ELEMENT_PLACEHOLDER);
if (placeholder == null ||
!placeholder.equals("true")) {
delete = false;
}
Modified:
lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
URL:
http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java?rev=226394&r1=226393&r2=226394&view=diff
==============================================================================
---
lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
(original)
+++
lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
Fri Jul 29 09:42:59 2005
@@ -24,6 +24,7 @@
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
+import java.util.Map;
import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.lenya.cms.publication.Document;
@@ -37,6 +38,7 @@
import org.apache.lenya.cms.site.NodeFactory;
import org.apache.lenya.cms.site.SiteManager;
import org.apache.lenya.cms.site.SiteUtil;
+import org.apache.lenya.cms.site.usecases.AssetUtil;
import org.apache.lenya.cms.usecase.DocumentUsecase;
import org.apache.lenya.cms.usecase.UsecaseException;
import org.apache.lenya.cms.usecase.scheduling.UsecaseScheduler;
@@ -75,23 +77,22 @@
try {
List nodes = new ArrayList();
DocumentSet set = new DocumentSet();
-
+
Document doc = getSourceDocument();
set.addAll(SiteUtil.getSubSite(this.manager, doc));
-
- Document liveDoc = doc.getIdentityMap().getAreaVersion(doc,
Publication.LIVE_AREA);
- if(liveDoc.exists())
- set.addAll(SiteUtil.getSubSite(this.manager, liveDoc));
- else
- set.add(liveDoc);
-
-
- Document[] documents = set.getDocuments();
- for (int i = 0; i < documents.length; i++) {
- nodes.addAll(Arrays.asList(documents[i].getRepositoryNodes()));
+ Map targets = SiteUtil.getTransferedSubSite(this.manager, doc,
Publication.LIVE_AREA,
+ SiteUtil.MODE_REPLACE);
+ Document[] docs = set.getDocuments();
+ for (int i = 0; i < docs.length; i++) {
+ nodes.addAll(Arrays.asList(docs[i].getRepositoryNodes()));
+ Document target = (Document) targets.get(docs[i]);
+ nodes.addAll(Arrays.asList(target.getRepositoryNodes()));
+ nodes.addAll(AssetUtil.getCopiedAssetNodes(docs[i], target,
this.manager,
+ getLogger()));
}
- nodes.add(SiteUtil.getSiteStructure(this.manager,
liveDoc).getRepositoryNode());
+ nodes.add(SiteUtil.getSiteStructure(this.manager,
getDocumentIdentityMap(),
+ doc.getPublication(),
Publication.LIVE_AREA).getRepositoryNode());
return (Transactionable[]) nodes.toArray(new
Transactionable[nodes.size()]);
} catch (Exception e) {
@@ -145,13 +146,12 @@
DocumentSet liveDocs = SiteUtil.getExistingDocuments(map,
requiredNodes[i]);
if (liveDocs.isEmpty()) {
Document authoringDoc =
map.get(requiredNodes[i].getPublication(),
- Publication.AUTHORING_AREA,
- requiredNodes[i].getDocumentId());
+ Publication.AUTHORING_AREA,
requiredNodes[i].getDocumentId());
if (authoringDoc.exists()) {
missingDocuments.add(authoringDoc);
} else {
-
missingDocuments.add(map.getLanguageVersion(authoringDoc,
-
authoringDoc.getPublication().getDefaultLanguage()));
+
missingDocuments.add(map.getLanguageVersion(authoringDoc, authoringDoc
+ .getPublication().getDefaultLanguage()));
}
}
|