mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-4126 - F85 Target transfer log in XML
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22161 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -30,6 +30,7 @@ import org.alfresco.repo.transfer.manifest.TransferManifestNormalNode;
|
||||
import org.alfresco.repo.transfer.manifest.TransferManifestProcessor;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.transfer.TransferException;
|
||||
import org.alfresco.service.cmr.transfer.TransferProgress;
|
||||
import org.alfresco.service.cmr.transfer.TransferReceiver;
|
||||
@@ -187,7 +188,7 @@ public abstract class AbstractManifestProcessorBase implements TransferManifestP
|
||||
String message = (node != null) ? "Error while processing incoming node " + node.getNodeRef() :
|
||||
"Error processing commit";
|
||||
|
||||
monitor.log(transferId, message, ex);
|
||||
monitor.logException(transferId, message, ex);
|
||||
//Any non-fatal transfer exception is logged and then skipped - the transfer continues
|
||||
//(albeit with a guaranteed rollback at the end).
|
||||
//A fatal transfer exception is rethrown and causes the transfer to end immediately.
|
||||
@@ -203,8 +204,24 @@ public abstract class AbstractManifestProcessorBase implements TransferManifestP
|
||||
}
|
||||
}
|
||||
|
||||
protected void logProgress(String message)
|
||||
protected void logComment(String message)
|
||||
{
|
||||
receiver.getProgressMonitor().log(transferId, message);
|
||||
receiver.getProgressMonitor().logComment(transferId, message);
|
||||
}
|
||||
protected void logCreated(NodeRef sourceNode, NodeRef destNode, NodeRef newParentNode, Path parentPath, boolean orphan)
|
||||
{
|
||||
receiver.getProgressMonitor().logCreated(transferId, sourceNode, destNode, newParentNode, parentPath, orphan);
|
||||
}
|
||||
protected void logDeleted(NodeRef sourceNode, NodeRef destNode, Path parentPath)
|
||||
{
|
||||
receiver.getProgressMonitor().logDeleted(transferId, sourceNode, destNode, parentPath);
|
||||
}
|
||||
protected void logUpdated(NodeRef sourceNode, NodeRef destNode, Path newPath)
|
||||
{
|
||||
receiver.getProgressMonitor().logUpdated(transferId, sourceNode, destNode, newPath);
|
||||
}
|
||||
protected void logMoved(NodeRef sourceNode, NodeRef destNode, Path oldPath, NodeRef newParent, Path newPath)
|
||||
{
|
||||
receiver.getProgressMonitor().logMoved(transferId, sourceNode, destNode, oldPath, newParent, newPath);
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,8 @@ package org.alfresco.repo.transfer;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.transfer.TransferException;
|
||||
import org.alfresco.service.cmr.transfer.TransferProgress;
|
||||
import org.alfresco.service.cmr.transfer.TransferProgress.Status;
|
||||
@@ -61,10 +63,10 @@ public class LoggingTransferProgressMonitorImpl implements TransferProgressMonit
|
||||
* @throws TransferException
|
||||
* @see org.alfresco.repo.transfer.TransferProgressMonitor#log(java.lang.String, java.lang.Object, java.lang.Throwable)
|
||||
*/
|
||||
public void log(String transferId, Object obj, Throwable ex) throws TransferException
|
||||
public void logException(String transferId, Object obj, Throwable ex) throws TransferException
|
||||
{
|
||||
localLog(transferId, obj, ex);
|
||||
delegate.log(transferId, obj, ex);
|
||||
delegate.logException(transferId, obj, ex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,10 +75,39 @@ public class LoggingTransferProgressMonitorImpl implements TransferProgressMonit
|
||||
* @throws TransferException
|
||||
* @see org.alfresco.repo.transfer.TransferProgressMonitor#log(java.lang.String, java.lang.Object)
|
||||
*/
|
||||
public void log(String transferId, Object obj) throws TransferException
|
||||
public void logComment(String transferId, Object obj) throws TransferException
|
||||
{
|
||||
localLog(transferId, obj, null);
|
||||
delegate.log(transferId, obj);
|
||||
delegate.logComment(transferId, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logCreated(String transferId, NodeRef sourceNode,
|
||||
NodeRef destNode, NodeRef parentNode, Path parentPath, boolean orphan)
|
||||
{
|
||||
delegate.logCreated(transferId, sourceNode, destNode, parentNode, parentPath, orphan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logUpdated(String transferId, NodeRef sourceNode,
|
||||
NodeRef destNode, Path parentPath)
|
||||
{
|
||||
delegate.logUpdated(transferId, sourceNode, destNode, parentPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logMoved(String transferId, NodeRef sourceNode,
|
||||
NodeRef destNode, Path oldPath, NodeRef parentNodeRef, Path parentPath)
|
||||
{
|
||||
delegate.logMoved(transferId, sourceNode, destNode, oldPath, parentNodeRef, parentPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logDeleted(String transferId, NodeRef sourceNode,
|
||||
NodeRef destNode, Path parentPath)
|
||||
{
|
||||
delegate.logDeleted(transferId, sourceNode, destNode, parentPath);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,4 +182,10 @@ public class LoggingTransferProgressMonitorImpl implements TransferProgressMonit
|
||||
{
|
||||
return delegate.getLogInputStream(transferId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -46,6 +46,7 @@ import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
@@ -135,7 +136,7 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
||||
// store in which its old parent lives.
|
||||
// If we can find a corresponding node then we'll delete it.
|
||||
// If we can't find a corresponding node then we'll do nothing.
|
||||
logProgress("Processing incoming deleted node: " + node.getNodeRef());
|
||||
logComment("Primary Processing incoming deleted node: " + node.getNodeRef());
|
||||
|
||||
ChildAssociationRef origPrimaryParent = node.getPrimaryParentAssoc();
|
||||
NodeRef origNodeRef = new NodeRef(origPrimaryParent.getParentRef().getStoreRef(), node.getNodeRef().getId());
|
||||
@@ -154,12 +155,14 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
||||
+ " has been resolved to existing local noderef " + exNode
|
||||
+ " - deleting");
|
||||
}
|
||||
|
||||
delete(exNode);
|
||||
|
||||
logDeleted(node.getNodeRef(), exNode, nodeService.getPath(exNode));
|
||||
|
||||
delete(node, exNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
logProgress("Unable to find corresponding node for incoming deleted node: " + node.getNodeRef());
|
||||
logComment("Unable to find corresponding node for incoming deleted node: " + node.getNodeRef());
|
||||
if (log.isDebugEnabled())
|
||||
{
|
||||
log.debug("Incoming deleted noderef has no corresponding local noderef: " + node.getNodeRef()
|
||||
@@ -180,7 +183,7 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
||||
{
|
||||
log.debug("Processing node with incoming noderef of " + node.getNodeRef());
|
||||
}
|
||||
logProgress("Processing incoming node: " + node.getNodeRef() + " -- Source path = " + node.getParentPath() + "/" + node.getPrimaryParentAssoc().getQName());
|
||||
logComment("Primary Processing incoming node: " + node.getNodeRef() + " -- Source path = " + node.getParentPath() + "/" + node.getPrimaryParentAssoc().getQName());
|
||||
|
||||
ChildAssociationRef primaryParentAssoc = node.getPrimaryParentAssoc();
|
||||
if (primaryParentAssoc == null)
|
||||
@@ -216,7 +219,7 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
||||
log.info("Located an archived node with UUID matching transferred node: " + archiveNodeRef);
|
||||
log.info("Attempting to restore " + archiveNodeRef);
|
||||
}
|
||||
logProgress("Delete node from archive: " + archiveNodeRef);
|
||||
logComment("Delete node from archive: " + archiveNodeRef);
|
||||
nodeService.deleteNode(archiveNodeRef);
|
||||
}
|
||||
|
||||
@@ -239,7 +242,8 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
||||
ChildAssociationRef primaryParentAssoc)
|
||||
{
|
||||
log.info("Creating new node with noderef " + node.getNodeRef());
|
||||
logProgress("Creating new node to correspond to incoming node: " + node.getNodeRef());
|
||||
|
||||
|
||||
|
||||
QName parentAssocType = primaryParentAssoc.getTypeQName();
|
||||
QName parentAssocName = primaryParentAssoc.getQName();
|
||||
@@ -260,7 +264,7 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
||||
parentAssocType = tempLocation.getTypeQName();
|
||||
parentAssocName = tempLocation.getQName();
|
||||
log.info("Recording orphaned transfer node: " + node.getNodeRef());
|
||||
logProgress("Unable to resolve parent for new incoming node. Storing it in temp folder: " + node.getNodeRef());
|
||||
logComment("Unable to resolve parent for new incoming node. Storing it in temp folder: " + node.getNodeRef());
|
||||
storeOrphanNode(primaryParentAssoc);
|
||||
}
|
||||
// We now know that this is a new node, and we have found the
|
||||
@@ -299,6 +303,8 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
||||
log.debug("Created new node (" + newNode.getChildRef() + ") parented by node " + newNode.getParentRef());
|
||||
}
|
||||
|
||||
logCreated(node.getNodeRef(), newNode.getChildRef(), newNode.getParentRef(), nodeService.getPath(newNode.getChildRef()), false);
|
||||
|
||||
// Deal with the content properties
|
||||
writeContent(newNode.getChildRef(), contentProps);
|
||||
|
||||
@@ -350,11 +356,11 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
||||
* Delete this node
|
||||
* @param exNode
|
||||
*/
|
||||
protected void delete(NodeRef nodeToDelete)
|
||||
protected void delete(TransferManifestDeletedNode node, NodeRef nodeToDelete)
|
||||
{
|
||||
if(alienProcessor.isAlien(nodeToDelete))
|
||||
{
|
||||
logProgress("Pruning local node: " + nodeToDelete);
|
||||
logComment("Node contains alien content and can't be deleted: " + nodeToDelete);
|
||||
if (log.isDebugEnabled())
|
||||
{
|
||||
log.debug("Node to be deleted is alien prune rather than delete: " + nodeToDelete);
|
||||
@@ -375,14 +381,15 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
||||
{
|
||||
if(!fromRepository.equalsIgnoreCase(transferringRepo))
|
||||
{
|
||||
logProgress("Not deleting local node (not from the transferring repository): " + nodeToDelete);
|
||||
logComment("Not deleting local node (not from the transferring repository): " + nodeToDelete);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not alien or from another repo - delete it.
|
||||
logProgress("Deleting local node: " + nodeToDelete);
|
||||
logDeleted(node.getNodeRef(), nodeToDelete, nodeService.getPath(nodeToDelete));
|
||||
|
||||
nodeService.deleteNode(nodeToDelete);
|
||||
if (log.isDebugEnabled())
|
||||
{
|
||||
@@ -399,7 +406,7 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
||||
// Yes, it is...
|
||||
for (ChildAssociationRef orphan : orphansToClaim)
|
||||
{
|
||||
logProgress("Re-parenting previously orphaned node (" + orphan.getChildRef() + ") with found parent " + orphan.getParentRef());
|
||||
logComment("Re-parenting previously orphaned node (" + orphan.getChildRef() + ") with found parent " + orphan.getParentRef());
|
||||
ChildAssociationRef newRef = nodeService.moveNode(orphan.getChildRef(), orphan.getParentRef(), orphan.getTypeQName(), orphan
|
||||
.getQName());
|
||||
|
||||
@@ -441,13 +448,12 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
||||
{
|
||||
if(!fromRepository.equalsIgnoreCase(transferringRepo))
|
||||
{
|
||||
logProgress("Not updating local node (not from the transferring repository): " + node.getNodeRef());
|
||||
logComment("Not updating local node (not from the transferring repository): " + node.getNodeRef());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logProgress("Updating local node: " + node.getNodeRef());
|
||||
QName parentAssocType = primaryParentAssoc.getTypeQName();
|
||||
QName parentAssocName = primaryParentAssoc.getQName();
|
||||
NodeRef parentNodeRef = resolvedNodes.resolvedParent;
|
||||
@@ -483,7 +489,7 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
||||
|
||||
// Yes, we need to move the node
|
||||
ChildAssociationRef newNode = nodeService.moveNode(nodeToUpdate, parentNodeRef, parentAssocType, parentAssocName);
|
||||
logProgress("Moved node " + nodeToUpdate + " to be under parent node " + parentNodeRef);
|
||||
logMoved(node.getNodeRef(), nodeToUpdate, node.getParentPath(), newNode.getParentRef(), nodeService.getPath(newNode.getChildRef()));
|
||||
|
||||
alienProcessor.afterMoveAlien(newNode);
|
||||
|
||||
@@ -494,6 +500,8 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
||||
if (updateNeeded(node, nodeToUpdate))
|
||||
{
|
||||
|
||||
logUpdated(node.getNodeRef(), nodeToUpdate, nodeService.getPath(nodeToUpdate));
|
||||
|
||||
// We need to process content properties separately.
|
||||
// First, create a shallow copy of the supplied property map...
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(node.getProperties());
|
||||
|
@@ -90,7 +90,7 @@ public class RepoRequsiteManifestProcessorImpl extends AbstractManifestProcessor
|
||||
{
|
||||
log.debug("Processing node with incoming noderef of " + node.getNodeRef());
|
||||
}
|
||||
logProgress("Processing incoming node: " + node.getNodeRef() + " -- Source path = " + node.getParentPath() + "/" + node.getPrimaryParentAssoc().getQName());
|
||||
logComment("Primary Processing incoming node: " + node.getNodeRef() + " -- Source path = " + node.getParentPath() + "/" + node.getPrimaryParentAssoc().getQName());
|
||||
|
||||
ChildAssociationRef primaryParentAssoc = node.getPrimaryParentAssoc();
|
||||
|
||||
|
@@ -82,8 +82,7 @@ public class RepoTertiaryManifestProcessorImpl extends AbstractManifestProcessor
|
||||
{
|
||||
log.debug("Processing node with incoming noderef of " + node.getNodeRef());
|
||||
}
|
||||
logProgress("Processing incoming node: " + node.getNodeRef() + " -- Source path = " + node.getParentPath() + "/" + node.getPrimaryParentAssoc().getQName());
|
||||
|
||||
logComment("Tertiary Processing incoming node: " + node.getNodeRef() + " -- Source path = " + node.getParentPath() + "/" + node.getPrimaryParentAssoc().getQName());
|
||||
|
||||
/**
|
||||
* This processor only does processes sync requests.
|
||||
@@ -143,6 +142,7 @@ public class RepoTertiaryManifestProcessorImpl extends AbstractManifestProcessor
|
||||
if(nodeService.hasAspect(childNodeRef, TransferModel.ASPECT_TRANSFERRED))
|
||||
{
|
||||
log.debug("an unexpected transferred child node:" + child);
|
||||
logComment("Transfer sync mode - checking unexpected child node:" + child);
|
||||
String fromRepositoryId = (String)nodeService.getProperty(childNodeRef, TransferModel.PROP_FROM_REPOSITORY_ID);
|
||||
|
||||
// Yes this is a transferred node. When syncing we only delete nodes that are "from"
|
||||
@@ -156,6 +156,7 @@ public class RepoTertiaryManifestProcessorImpl extends AbstractManifestProcessor
|
||||
* it needs to be "pruned" of the transferring repo's content instead.
|
||||
*/
|
||||
log.debug("node to be deleted contains alien content so needs to be pruned." + childNodeRef);
|
||||
logComment("Transfer sync mode - node contains alien content so can't be deleted. " + childNodeRef);
|
||||
alienProcessor.pruneNode(childNodeRef, fromRepositoryId);
|
||||
}
|
||||
else
|
||||
@@ -165,7 +166,8 @@ public class RepoTertiaryManifestProcessorImpl extends AbstractManifestProcessor
|
||||
if(manifestRepositoryId.equalsIgnoreCase(fromRepositoryId))
|
||||
{
|
||||
// Yes the manifest repository Id and the from repository Id match.
|
||||
// Destination node if from the transferring repo and needs to be deleted.
|
||||
// Destination node if from the transferring repo and needs to be deleted.
|
||||
logDeleted(node.getNodeRef(), childNodeRef, nodeService.getPath(childNodeRef));
|
||||
nodeService.deleteNode(childNodeRef);
|
||||
log.debug("deleted node:" + childNodeRef);
|
||||
}
|
||||
|
@@ -20,22 +20,21 @@
|
||||
package org.alfresco.repo.transfer;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.nio.channels.Channels;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transfer.reportd.XMLTransferDestinationReportWriter;
|
||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.transfer.TransferException;
|
||||
import org.alfresco.service.cmr.transfer.TransferProgress;
|
||||
import org.alfresco.service.cmr.transfer.TransferProgress.Status;
|
||||
@@ -57,7 +56,8 @@ public class RepoTransferProgressMonitorImpl implements TransferProgressMonitor
|
||||
private NodeService nodeService;
|
||||
private ContentService contentService;
|
||||
private TransactionService transactionService;
|
||||
private Map<String, WritableByteChannel> transferLogWriters = new TreeMap<String, WritableByteChannel>();
|
||||
//private Map<String, WritableByteChannel> transferLogWriters = new TreeMap<String, WritableByteChannel>();
|
||||
private Map<String, TransferDestinationReportWriter> transferLogWriters = new TreeMap<String, TransferDestinationReportWriter>();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -92,51 +92,72 @@ public class RepoTransferProgressMonitorImpl implements TransferProgressMonitor
|
||||
*
|
||||
* @see org.alfresco.repo.transfer.TransferProgressMonitor#log(java.lang.String, java.lang.Object)
|
||||
*/
|
||||
public void log(final String transferId, final Object obj)
|
||||
public void logComment(final String transferId, final Object obj)
|
||||
{
|
||||
log(transferId, obj, null);
|
||||
TransferDestinationReportWriter writer = getLogWriter(transferId);
|
||||
writer.writeComment(obj.toString());
|
||||
}
|
||||
|
||||
public void log(final String transferId, final Object obj, final Throwable ex)
|
||||
public void logException(final String transferId, final Object obj, final Throwable ex)
|
||||
{
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(
|
||||
new RetryingTransactionHelper.RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public NodeRef execute() throws Throwable
|
||||
{
|
||||
TransferDestinationReportWriter writer = getLogWriter(transferId);
|
||||
|
||||
writer.writeComment(obj.toString());
|
||||
|
||||
if (ex != null)
|
||||
{
|
||||
NodeRef nodeRef = getTransferRecord(transferId);
|
||||
// Write the exception onto the transfer record
|
||||
nodeService.setProperty(nodeRef, TransferModel.PROP_TRANSFER_ERROR, ex);
|
||||
writer.writeException(ex);
|
||||
}
|
||||
WritableByteChannel writer = getLogWriter(transferId);
|
||||
Date now = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
String text = format.format(now) + " - " + obj.toString() + "\n";
|
||||
if (ex != null)
|
||||
{
|
||||
text += ex.getMessage() + "\n";
|
||||
StringWriter stringWriter = new StringWriter(1024);
|
||||
PrintWriter errorWriter = new PrintWriter(stringWriter);
|
||||
ex.printStackTrace(errorWriter);
|
||||
text += stringWriter.toString();
|
||||
}
|
||||
try
|
||||
{
|
||||
writer.write(ByteBuffer.wrap(text.getBytes("UTF-8")));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (log.isWarnEnabled())
|
||||
{
|
||||
log.warn("Unable to record transfer log information:\n " + text, ex);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}, false, true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logCreated(String transferId,
|
||||
NodeRef sourceNode,
|
||||
NodeRef destNode,
|
||||
NodeRef parentNodeRef,
|
||||
Path parentPath,
|
||||
boolean orphan)
|
||||
{
|
||||
TransferDestinationReportWriter writer = getLogWriter(transferId);
|
||||
writer.writeCreated(sourceNode, destNode, parentNodeRef, parentPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logUpdated(String transferId, NodeRef sourceNodeRef,
|
||||
NodeRef destNodeRef, Path path)
|
||||
{
|
||||
TransferDestinationReportWriter writer = getLogWriter(transferId);
|
||||
writer.writeUpdated(sourceNodeRef, destNodeRef, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logMoved(String transferId, NodeRef sourceNodeRef,
|
||||
NodeRef destNodeRef, Path oldPath, NodeRef newParentNodeRef, Path newPath)
|
||||
{
|
||||
TransferDestinationReportWriter writer = getLogWriter(transferId);
|
||||
writer.writeMoved(sourceNodeRef, destNodeRef, oldPath, newParentNodeRef, newPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logDeleted(String transferId,
|
||||
NodeRef sourceNodeRef,
|
||||
NodeRef destNodeRef,
|
||||
Path oldPath)
|
||||
{
|
||||
TransferDestinationReportWriter writer = getLogWriter(transferId);
|
||||
writer.writeDeleted(sourceNodeRef, destNodeRef, oldPath);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -197,20 +218,21 @@ public class RepoTransferProgressMonitorImpl implements TransferProgressMonitor
|
||||
testCancelled(nodeRef);
|
||||
String currentStatusString = (String)nodeService.getProperty(nodeRef, TransferModel.PROP_TRANSFER_STATUS);
|
||||
Status currentStatus = Status.valueOf(currentStatusString);
|
||||
|
||||
TransferDestinationReportWriter writer = getLogWriter(transferId);
|
||||
writer.writeChangeState(status.toString());
|
||||
|
||||
//If the transfer has already reached a terminal state then we don't allow any further change
|
||||
if (!TransferProgress.getTerminalStatuses().contains(currentStatus))
|
||||
{
|
||||
log(transferId, "Status update: " + status);
|
||||
nodeService.setProperty(nodeRef, TransferModel.PROP_TRANSFER_STATUS, status.toString());
|
||||
//If the transfer has now reached a terminal state then the make sure that the log channel is
|
||||
//closed for it (if one was open).
|
||||
if (TransferProgress.getTerminalStatuses().contains(status))
|
||||
{
|
||||
WritableByteChannel logChannel = transferLogWriters.remove(transferId);
|
||||
if (logChannel != null)
|
||||
{
|
||||
logChannel.close();
|
||||
}
|
||||
log.debug("closing destination transfer report");
|
||||
writer.endTransferReport();
|
||||
transferLogWriters.remove(transferId);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -237,18 +259,29 @@ public class RepoTransferProgressMonitorImpl implements TransferProgressMonitor
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
private WritableByteChannel getLogWriter(String transferId)
|
||||
private TransferDestinationReportWriter getLogWriter(String transferId)
|
||||
{
|
||||
WritableByteChannel channel = this.transferLogWriters.get(transferId);
|
||||
if (channel == null)
|
||||
TransferDestinationReportWriter writer = this.transferLogWriters.get(transferId);
|
||||
if (writer == null)
|
||||
{
|
||||
NodeRef node = new NodeRef(transferId);
|
||||
ContentWriter writer = contentService.getWriter(node, ContentModel.PROP_CONTENT, true);
|
||||
writer.setMimetype("text/plain");
|
||||
channel = writer.getWritableChannel();
|
||||
transferLogWriters.put(transferId, channel);
|
||||
ContentWriter contentWriter = contentService.getWriter(node, ContentModel.PROP_CONTENT, true);
|
||||
contentWriter.setMimetype(MimetypeMap.MIMETYPE_XML);
|
||||
contentWriter.setEncoding("UTF-8");
|
||||
|
||||
writer = new XMLTransferDestinationReportWriter();
|
||||
try
|
||||
{
|
||||
writer.startTransferReport("UTF-8", Channels.newWriter(contentWriter.getWritableChannel(), "UTF-8"));
|
||||
}
|
||||
catch (ContentIOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
transferLogWriters.put(transferId, writer);
|
||||
}
|
||||
return channel;
|
||||
return writer;
|
||||
}
|
||||
|
||||
public InputStream getLogInputStream(String transferId)
|
||||
@@ -258,7 +291,14 @@ public class RepoTransferProgressMonitorImpl implements TransferProgressMonitor
|
||||
|
||||
ContentReader reader = contentService.getReader(transferRecord, ContentModel.PROP_CONTENT);
|
||||
|
||||
return reader.getContentInputStream();
|
||||
if(reader != null)
|
||||
{
|
||||
return reader.getContentInputStream();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,5 +327,4 @@ public class RepoTransferProgressMonitorImpl implements TransferProgressMonitor
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -738,7 +738,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
|
||||
}
|
||||
else
|
||||
{
|
||||
progressMonitor.log(transferId, "Unable to start commit. No snapshot file received",
|
||||
progressMonitor.logException(transferId, "Unable to start commit. No snapshot file received",
|
||||
new TransferException(MSG_NO_SNAPSHOT_RECEIVED, new Object[]{transferId}));
|
||||
}
|
||||
return null;
|
||||
|
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.transfer;
|
||||
|
||||
import java.io.Writer;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author mrogers
|
||||
*/
|
||||
public interface TransferDestinationReportWriter
|
||||
{
|
||||
|
||||
/**
|
||||
* Called at the start of the destination transfer report.
|
||||
*
|
||||
* @param encoding the encoding to use, utf-8.
|
||||
* @param writer where to write the transfer report
|
||||
*/
|
||||
public void startTransferReport(String encoding, Writer writer);
|
||||
|
||||
/**
|
||||
* Called at the end of the destination transfer report.
|
||||
*/
|
||||
public void endTransferReport();
|
||||
|
||||
/**
|
||||
* a change of state
|
||||
*/
|
||||
public void writeChangeState(String state);
|
||||
|
||||
/**
|
||||
* An ad-hoc comment
|
||||
*/
|
||||
public void writeComment(String comment);
|
||||
|
||||
/**
|
||||
* Reporting creation of a new node
|
||||
*/
|
||||
public void writeCreated(NodeRef sourceNodeRef, NodeRef newNodeRef, NodeRef newParentNodeRef, Path newPath);
|
||||
|
||||
/**
|
||||
* Reporting update of an existing node
|
||||
*/
|
||||
public void writeUpdated(NodeRef sourceNodeRef, NodeRef updatedNode, Path updatedPath);
|
||||
|
||||
/**
|
||||
* Reporting a node moved
|
||||
*/
|
||||
public void writeMoved(NodeRef sourceNodeRef, NodeRef movedNodeRef, Path oldPath, NodeRef newParentNodeRef, Path newPath);
|
||||
|
||||
/**
|
||||
* Reporting a node deleted
|
||||
*/
|
||||
public void writeDeleted(NodeRef sourceNodeRef, NodeRef deletedNode, Path oldPath);
|
||||
|
||||
/**
|
||||
* Reporting an exception
|
||||
*/
|
||||
public void writeException(Throwable t);
|
||||
}
|
@@ -21,6 +21,8 @@ package org.alfresco.repo.transfer;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.transfer.TransferException;
|
||||
import org.alfresco.service.cmr.transfer.TransferProgress;
|
||||
|
||||
@@ -36,20 +38,60 @@ import org.alfresco.service.cmr.transfer.TransferProgress;
|
||||
public interface TransferProgressMonitor
|
||||
{
|
||||
/**
|
||||
* log a message
|
||||
* log an ad-hoc message
|
||||
* @param transferId
|
||||
* @param obj
|
||||
* @throws TransferException
|
||||
*/
|
||||
void log(String transferId, Object obj) throws TransferException;
|
||||
void logComment(String transferId, Object obj) throws TransferException;
|
||||
/**
|
||||
* log a message and an exception
|
||||
* log an ad-hoc message and an exception
|
||||
* @param transferId
|
||||
* @param obj
|
||||
* @param ex
|
||||
* @throws TransferException
|
||||
*/
|
||||
void log(String transferId, Object obj, Throwable ex) throws TransferException;
|
||||
void logException(String transferId, Object obj, Throwable ex) throws TransferException;
|
||||
|
||||
/**
|
||||
* Log the creation of a new node
|
||||
* @param transferId
|
||||
* @param sourceNode
|
||||
* @param destNode
|
||||
* @param newPath
|
||||
* @param orphan
|
||||
*/
|
||||
void logCreated(String transferId, NodeRef sourceNode, NodeRef destNode, NodeRef newParent, Path newPath, boolean orphan);
|
||||
|
||||
/**
|
||||
* Log the creation of a new node
|
||||
* @param transferId
|
||||
* @param sourceNode
|
||||
* @param destNode
|
||||
* @param parentPath
|
||||
* @param orphan
|
||||
*/
|
||||
void logUpdated(String transferId, NodeRef sourceNode, NodeRef destNode, Path parentPath);
|
||||
|
||||
|
||||
/**
|
||||
* Log the deletion of a node
|
||||
* @param transferId
|
||||
* @param sourceNode
|
||||
* @param destNode
|
||||
* @param parentPath
|
||||
* @param orphan
|
||||
*/
|
||||
void logDeleted(String transferId, NodeRef sourceNode, NodeRef destNode, Path parentPath);
|
||||
|
||||
/**
|
||||
* After the transfer has completed this method reads the log.
|
||||
* @param transferId
|
||||
* @return the log
|
||||
*/
|
||||
|
||||
void logMoved(String transferId, NodeRef sourceNodeRef,
|
||||
NodeRef destNodeRef, Path oldPath, NodeRef newParent, Path newPath);
|
||||
|
||||
/**
|
||||
* update the progress of the specified transfer
|
||||
@@ -84,10 +126,7 @@ public interface TransferProgressMonitor
|
||||
*/
|
||||
TransferProgress getProgress(String transferId) throws TransferException;
|
||||
|
||||
/**
|
||||
* After the transfer has completed this method reads the log.
|
||||
* @param transferId
|
||||
* @return the log
|
||||
*/
|
||||
InputStream getLogInputStream(String transferId) throws TransferException;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -55,6 +55,7 @@ import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.ResultSetRow;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||
@@ -1911,6 +1912,8 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest
|
||||
}
|
||||
|
||||
NodeRef transferReport = null;
|
||||
NodeRef transferDestReport = null;
|
||||
|
||||
startNewTransaction();
|
||||
try
|
||||
{
|
||||
@@ -1943,11 +1946,14 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest
|
||||
{
|
||||
case DESTINATION:
|
||||
foundDestReport = true;
|
||||
assertNotNull("dest transfer nodeId null", reportEvent.getNodeRef());
|
||||
assertFalse("dest transfer nodeId not correct", transferReport.equals(reportEvent.getNodeRef()));
|
||||
transferDestReport = reportEvent.getNodeRef();
|
||||
assertNotNull("dest transfer nodeId null", transferDestReport);
|
||||
assertFalse("dest transfer nodeId not correct", transferReport.equals(transferDestReport));
|
||||
break;
|
||||
|
||||
case SOURCE:
|
||||
foundSourceReport = true;
|
||||
|
||||
assertEquals("source transfer nodeId not correct", transferReport, reportEvent.getNodeRef());
|
||||
break;
|
||||
}
|
||||
@@ -1962,18 +1968,22 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest
|
||||
{
|
||||
endTransaction();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Now validate the client side transfer report against the xsd file
|
||||
*/
|
||||
startNewTransaction();
|
||||
try
|
||||
{
|
||||
ContentReader reader = contentService.getReader(transferReport, ContentModel.PROP_CONTENT);
|
||||
assertNotNull("transfer reader is null", reader);
|
||||
|
||||
ContentReader reader2 = contentService.getReader(transferReport, ContentModel.PROP_CONTENT);
|
||||
assertNotNull("transfer reader is null", reader);
|
||||
|
||||
logger.debug("now show the contents of the transfer report");
|
||||
reader2.getContent(System.out);
|
||||
// ContentReader reader2 = contentService.getReader(transferReport, ContentModel.PROP_CONTENT);
|
||||
// assertNotNull("transfer reader is null", reader2);
|
||||
//
|
||||
// logger.debug("now show the contents of the transfer report");
|
||||
// System.out.println("Client side transfer report");
|
||||
// reader2.getContent(System.out);
|
||||
|
||||
// Now validate the client side transfer report against the XSD
|
||||
Source transferReportSource = new StreamSource(reader.getContentInputStream());
|
||||
@@ -1989,19 +1999,94 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest
|
||||
{
|
||||
fail(e.getMessage() );
|
||||
}
|
||||
|
||||
logger.debug("now delete the target:" + targetName);
|
||||
|
||||
transferService.deleteTransferTarget(targetName);
|
||||
}
|
||||
finally
|
||||
{
|
||||
endTransaction();
|
||||
}
|
||||
} // test transfer report
|
||||
}
|
||||
|
||||
/**
|
||||
* Now validate the destination side transfer report against its xsd file
|
||||
*/
|
||||
startNewTransaction();
|
||||
try
|
||||
{
|
||||
ContentReader reader = contentService.getReader(transferDestReport, ContentModel.PROP_CONTENT);
|
||||
assertNotNull("transfer reader is null", reader);
|
||||
|
||||
// Now validate the destination side transfer report against the XSD
|
||||
Source transferReportSource = new StreamSource(reader.getContentInputStream());
|
||||
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||
final String TRANSFER_REPORT_SCHEMA_LOCATION = "classpath:org/alfresco/repo/transfer/reportd/TransferDestinationReport.xsd";
|
||||
Schema schema = sf.newSchema(ResourceUtils.getURL(TRANSFER_REPORT_SCHEMA_LOCATION));
|
||||
Validator validator = schema.newValidator();
|
||||
try
|
||||
{
|
||||
validator.validate(transferReportSource);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
fail("Destination Transfer Report " + e.getMessage() );
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
endTransaction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Now validate all transfer reports.
|
||||
*/
|
||||
startNewTransaction();
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
|
||||
String query = "TYPE:\"trx:transferReportDest\"";
|
||||
ResultSet results = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_LUCENE, query);
|
||||
|
||||
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||
final String TRANSFER_REPORT_SCHEMA_LOCATION = "classpath:org/alfresco/repo/transfer/reportd/TransferDestinationReport.xsd";
|
||||
Schema schema = sf.newSchema(ResourceUtils.getURL(TRANSFER_REPORT_SCHEMA_LOCATION));
|
||||
Validator validator = schema.newValidator();
|
||||
|
||||
for(ResultSetRow result : results)
|
||||
{
|
||||
NodeRef reportNode = result.getNodeRef();
|
||||
|
||||
logger.debug("validating reportNode " + reportNode);
|
||||
// Now validate the destination side transfer report against the XSD
|
||||
ContentReader reader = contentService.getReader(reportNode, ContentModel.PROP_CONTENT);
|
||||
assertNotNull("transfer reader is null", reader);
|
||||
|
||||
Source transferReportSource = new StreamSource(reader.getContentInputStream());
|
||||
try
|
||||
{
|
||||
validator.validate(transferReportSource);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
fail("Destination Transfer Report reportNode:" + reportNode + " message :" + e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
endTransaction();
|
||||
}
|
||||
|
||||
startNewTransaction();
|
||||
try
|
||||
{
|
||||
|
||||
logger.debug("now delete the target:" + targetName);
|
||||
|
||||
transferService.deleteTransferTarget(targetName);
|
||||
}
|
||||
finally
|
||||
{
|
||||
endTransaction();
|
||||
}
|
||||
} // test transfer report
|
||||
|
||||
// /**
|
||||
// * Test the transfer method with big content - commented out since it takes a long time to run.
|
||||
|
@@ -310,7 +310,7 @@ public class TransferReporterImpl implements TransferReporter
|
||||
ContentWriter writer = contentService.getWriter(ref.getChildRef(),
|
||||
ContentModel.PROP_CONTENT, true);
|
||||
writer.setLocale(Locale.getDefault());
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_XML);
|
||||
writer.setEncoding(DEFAULT_ENCODING);
|
||||
writer.putContent(tempFile);
|
||||
|
||||
|
@@ -0,0 +1,102 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<xs:schema targetNamespace="http://www.alfresco.org/model/transferDestinationReport/1.0"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:report="http://www.alfresco.org/model/transferDestinationReport/1.0"
|
||||
xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
elementFormDefault="qualified">
|
||||
|
||||
<!-- XML Schema for the client side transferReport owned by the
|
||||
alfresco transferService -->
|
||||
|
||||
<xs:element name="transferDestinationReport" type="report:transferDestinationReport">
|
||||
<xs:annotation>
|
||||
<xs:documentation>This is an Alfresco destination side transfer report</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
|
||||
<xs:complexType name="transferDestinationReport">
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
The Alfresco destination side transfer report
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
|
||||
<xs:sequence maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:choice>
|
||||
<xs:element name="state" type="report:state"></xs:element>
|
||||
<xs:element name="comment" type="report:comment"></xs:element>
|
||||
<xs:element name="created" type="report:created"></xs:element>
|
||||
<xs:element name="updated" type="report:updated"></xs:element>
|
||||
<xs:element name="moved" type="report:moved"></xs:element>
|
||||
<xs:element name="deleted" type="report:deleted"></xs:element>
|
||||
<xs:element name="exception" type="report:exception"></xs:element>
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="state">
|
||||
<xs:attribute name="date" type="dateTime"></xs:attribute>
|
||||
<xs:attribute name="state" type="string"></xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="comment" mixed="true">
|
||||
<xs:attribute name="date" type="dateTime"></xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="created">
|
||||
<xs:sequence maxOccurs="1" minOccurs="0">
|
||||
<xs:element name="destinationPath" type="report:destinationPath"></xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="sourceNodeRef" type="string"></xs:attribute>
|
||||
<xs:attribute name="parentNodeRef" type="string"></xs:attribute>
|
||||
<xs:attribute name="destinationNodeRef" type="string"></xs:attribute>
|
||||
<xs:attribute name="date" type="dateTime"></xs:attribute>
|
||||
<xs:attribute name="orphan" type="boolean"></xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="updated">
|
||||
<xs:sequence maxOccurs="1" minOccurs="0">
|
||||
<xs:element name="destinationPath" type="report:destinationPath"></xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="sourceNodeRef" type="string"></xs:attribute>
|
||||
<xs:attribute name="destinationNodeRef" type="string"></xs:attribute>
|
||||
<xs:attribute name="date" type="dateTime"></xs:attribute>
|
||||
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="deleted">
|
||||
<xs:sequence maxOccurs="1" minOccurs="0">
|
||||
<xs:element name="destinationPath" type="report:destinationPath"></xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="sourceNodeRef" type="string"></xs:attribute>
|
||||
<xs:attribute name="destinationNodeRef" type="string"></xs:attribute>
|
||||
<xs:attribute name="date" type="dateTime"></xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="moved">
|
||||
<xs:sequence maxOccurs="1" minOccurs="0">
|
||||
<xs:element name="destinationPath" type="report:destinationPath"></xs:element>
|
||||
<xs:element name="oldPath" type="report:oldPath"></xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="sourceNodeRef" type="string"></xs:attribute>
|
||||
<xs:attribute name="destinationNodeRef" type="string"></xs:attribute>
|
||||
<xs:attribute name="newParentNodeRef" type="string"></xs:attribute>
|
||||
<xs:attribute name="date" type="dateTime"></xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="destinationPath" mixed="true">
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="oldPath" mixed="true">
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="sourcePath" mixed="true">
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="exception" mixed="true">
|
||||
<xs:attribute name="type" type="string"></xs:attribute>
|
||||
<xs:attribute name="message" type="string"></xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
</xs:schema>
|
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.transfer.reportd;
|
||||
|
||||
import org.alfresco.repo.transfer.TransferModel;
|
||||
|
||||
/**
|
||||
* The transfer report model - extended for XML Manifest Model
|
||||
*/
|
||||
public interface TransferDestinationReportModel extends TransferModel
|
||||
{
|
||||
static final String LOCALNAME_TRANSFER_DEST_REPORT = "transferDestinationReport";
|
||||
//static final String LOCALNAME_TRANSFER_DEFINITION = "definition";
|
||||
static final String LOCALNAME_EXCEPTION = "exception";
|
||||
|
||||
static final String LOCALNAME_TRANSFER_NODE = "node";
|
||||
|
||||
static final String LOCALNAME_TRANSFER_STATE = "state";
|
||||
static final String LOCALNAME_TRANSFER_COMMENT = "comment";
|
||||
static final String LOCALNAME_TRANSFER_CREATED = "created";
|
||||
static final String LOCALNAME_TRANSFER_UPDATED = "updated";
|
||||
static final String LOCALNAME_TRANSFER_MOVED = "moved";
|
||||
static final String LOCALNAME_TRANSFER_DELETED = "deleted";
|
||||
|
||||
static final String LOCALNAME_TRANSFER_OLD_PATH = "oldPath";
|
||||
static final String LOCALNAME_TRANSFER_DEST_PATH = "destinationPath";
|
||||
|
||||
static final String LOCALNAME_TRANSFER_PRIMARY_PATH = "primaryPath";
|
||||
static final String LOCALNAME_TRANSFER_PRIMARY_PARENT = "primaryParent";
|
||||
|
||||
static final String REPORT_PREFIX = "report";
|
||||
|
||||
static final String TRANSFER_REPORT_MODEL_1_0_URI = "http://www.alfresco.org/model/transferDestinationReport/1.0";
|
||||
}
|
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.transfer.reportd;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.transfer.TransferDestinationReportWriter;
|
||||
import org.alfresco.repo.transfer.TransferModel;
|
||||
import org.alfresco.repo.transfer.manifest.ManifestModel;
|
||||
import org.alfresco.repo.transfer.manifest.TransferManifestNode;
|
||||
import org.alfresco.repo.transfer.report.TransferReportModel;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.transfer.TransferDefinition;
|
||||
import org.alfresco.service.cmr.transfer.TransferEvent;
|
||||
import org.alfresco.service.cmr.transfer.TransferTarget;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
import org.springframework.extensions.surf.util.ISO8601DateFormat;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
/**
|
||||
* Writes the Client Side Transfer Report out as XML.
|
||||
*
|
||||
* @author Mark Rogers
|
||||
*/
|
||||
public class XMLTransferDestinationReportWriter implements TransferDestinationReportWriter
|
||||
{
|
||||
public XMLTransferDestinationReportWriter()
|
||||
{
|
||||
}
|
||||
|
||||
private XMLWriter writer;
|
||||
|
||||
final AttributesImpl EMPTY_ATTRIBUTES = new AttributesImpl();
|
||||
|
||||
final String PREFIX = TransferDestinationReportModel.REPORT_PREFIX;
|
||||
|
||||
/**
|
||||
* Start the transfer report
|
||||
*/
|
||||
public void startTransferReport(String encoding, Writer writer)
|
||||
{
|
||||
OutputFormat format = OutputFormat.createPrettyPrint();
|
||||
format.setNewLineAfterDeclaration(false);
|
||||
format.setIndentSize(3);
|
||||
format.setEncoding(encoding);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
this.writer = new XMLWriter(writer, format);
|
||||
this.writer.startDocument();
|
||||
|
||||
this.writer.startPrefixMapping(PREFIX, TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI);
|
||||
|
||||
// Start Transfer Manifest // uri, name, prefix
|
||||
this.writer.startElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_DEST_REPORT, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_DEST_REPORT, EMPTY_ATTRIBUTES);
|
||||
|
||||
}
|
||||
catch (SAXException se)
|
||||
{
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End the transfer report
|
||||
*/
|
||||
public void endTransferReport()
|
||||
{
|
||||
try
|
||||
{
|
||||
// End Transfer Manifest
|
||||
writer.endElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_DEST_REPORT, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_DEST_REPORT);
|
||||
writer.endPrefixMapping(PREFIX);
|
||||
writer.endDocument();
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
catch (SAXException se)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
se.printStackTrace();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeChangeState(String state)
|
||||
{
|
||||
try
|
||||
{
|
||||
AttributesImpl attributes = new AttributesImpl();
|
||||
attributes.addAttribute(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "state", "state", "String", state);
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "date", "date", "dateTime", ISO8601DateFormat.format(new Date()));
|
||||
|
||||
writer.startElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_STATE, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_STATE, attributes);
|
||||
writer.endElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_STATE, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_STATE);
|
||||
}
|
||||
catch (SAXException se)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the exception to the report
|
||||
*/
|
||||
public void writeException(Throwable e)
|
||||
{
|
||||
try
|
||||
{
|
||||
AttributesImpl attributes = new AttributesImpl();
|
||||
attributes.addAttribute(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "type", "type", "String", e.getClass().getName());
|
||||
attributes.addAttribute(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "message", "message", "String", e.getMessage());
|
||||
writer.startElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_EXCEPTION, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_EXCEPTION, attributes);
|
||||
writer.endElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_EXCEPTION, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_EXCEPTION);
|
||||
}
|
||||
catch(SAXException se)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeComment(String comment)
|
||||
{
|
||||
try
|
||||
{
|
||||
AttributesImpl attributes = new AttributesImpl();
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "date", "date", "dateTime", ISO8601DateFormat.format(new Date()));
|
||||
writer.startElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_COMMENT, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_COMMENT, attributes);
|
||||
writer.characters(comment.toCharArray(), 0, comment.length());
|
||||
writer.endElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_COMMENT, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_COMMENT);
|
||||
}
|
||||
catch(SAXException se)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCreated(NodeRef sourceNodeRef, NodeRef newNode, NodeRef newParentNodeRef, Path newPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
AttributesImpl attributes = new AttributesImpl();
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "date", "date", "dateTime", ISO8601DateFormat.format(new Date()));
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "sourceNodeRef", "sourceNodeRef", "string", sourceNodeRef.toString());
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "destinationNodeRef", "destinationNodeRef", "string", newNode.toString());
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "parentNodeRef", "parentNodeRef", "string", newParentNodeRef.toString());
|
||||
|
||||
writer.startElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_CREATED, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_CREATED, attributes);
|
||||
writeDestinationPath(newPath);
|
||||
writer.endElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_CREATED, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_CREATED);
|
||||
}
|
||||
catch (SAXException se)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDeleted(NodeRef sourceNodeRef, NodeRef deletedNode, Path oldPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
AttributesImpl attributes = new AttributesImpl();
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "date", "date", "dateTime", ISO8601DateFormat.format(new Date()));
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "sourceNodeRef", "sourceNodeRef", "string", sourceNodeRef.toString());
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "destinationNodeRef", "destinationNodeRef", "string", deletedNode.toString());
|
||||
|
||||
writer.startElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_DELETED, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_DELETED, attributes);
|
||||
writeDestinationPath(oldPath);
|
||||
writer.endElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_DELETED, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_DELETED);
|
||||
}
|
||||
catch (SAXException se)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeMoved(NodeRef sourceNodeRef, NodeRef updatedNode, Path oldPath, NodeRef newParentNodeRef, Path newPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
AttributesImpl attributes = new AttributesImpl();
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "date", "date", "dateTime", ISO8601DateFormat.format(new Date()));
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "sourceNodeRef", "sourceNodeRef", "string", sourceNodeRef.toString());
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "destinationNodeRef", "destinationNodeRef", "string", updatedNode.toString());
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "newParentNodeRef", "newParentNodeRef", "string", newParentNodeRef.toString());
|
||||
writer.startElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_MOVED, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_MOVED, attributes);
|
||||
writeDestinationPath(newPath);
|
||||
writeOldPath(oldPath);
|
||||
writer.endElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_MOVED, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_MOVED);
|
||||
}
|
||||
catch (SAXException se)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeUpdated(NodeRef sourceNodeRef, NodeRef updatedNode, Path updatedPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
AttributesImpl attributes = new AttributesImpl();
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "date", "date", "dateTime", ISO8601DateFormat.format(new Date()));
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "sourceNodeRef", "sourceNodeRef", "string", sourceNodeRef.toString());
|
||||
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "destinationNodeRef", "destinationNodeRef", "string", updatedNode.toString());
|
||||
|
||||
writer.startElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_UPDATED, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_UPDATED, attributes);
|
||||
writeDestinationPath(updatedPath);
|
||||
writer.endElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_UPDATED, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_UPDATED);
|
||||
}
|
||||
catch (SAXException se)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void writeOldPath(Path path)
|
||||
{
|
||||
try
|
||||
{
|
||||
AttributesImpl attributes = new AttributesImpl();
|
||||
|
||||
writer.startElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_OLD_PATH, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_OLD_PATH, attributes);
|
||||
String sPath = path.toString();
|
||||
writer.characters(sPath.toCharArray(), 0, sPath.length());
|
||||
writer.endElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_OLD_PATH, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_OLD_PATH);
|
||||
}
|
||||
catch (SAXException se)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void writeDestinationPath(Path path)
|
||||
{
|
||||
try
|
||||
{
|
||||
AttributesImpl attributes = new AttributesImpl();
|
||||
|
||||
writer.startElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_DEST_PATH, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_DEST_PATH, attributes);
|
||||
String sPath = path.toString();
|
||||
writer.characters(sPath.toCharArray(), 0, sPath.length());
|
||||
writer.endElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_DEST_PATH, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_DEST_PATH);
|
||||
}
|
||||
catch (SAXException se)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Provides the implementation of the destination side transfer report which records details of a transfer.
|
||||
* @since 3.4
|
||||
*/
|
||||
package org.alfresco.repo.transfer.reportd;
|
Reference in New Issue
Block a user