Document doc = getSourceDocument();
Document[] sources = SiteUtil.getSubSite(this.manager, doc.getLink().getNode())
.getDocuments();
Area targetArea = doc.getPublication().getArea(targetAreaName);
DocumentLocator targetLoc = doc.getLocator().getAreaVersion(targetAreaName);
targetLoc = SiteUtil.getAvailableLocator(this.manager, getDocumentFactory(), targetLoc);
for (int i = 0; i < sources.length; i++) {
WorkflowUtil.invoke(this.manager, getSession(), getLogger(), sources[i], getEvent(),
true);
if (this.getClass().getName().equals(Restore.class.getName())) {
Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager, getSession(),
getLogger(), sources[i]);
String state = workflowable.getLatestVersion().getState();
if (!state.equals("authoring")) {
addErrorMessage("The state is [" + state + "] instead of [authoring]!");
}
}
}
DocumentManager docManager = null;
try {
docManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
docManager.moveAll(doc.area(), doc.getPath(), targetArea, targetLoc.getPath());
} finally {
if (docManager != null) {
this.manager.release(docManager);
}