mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Name duplicate detection is not done at the end of the transaction, so late setting of
cm:name has to be avoided. This fix makes the CopyService use the auto-assigned cm:name before doing the copy. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3621 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -34,8 +34,6 @@ import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
|||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.model.FileExistsException;
|
import org.alfresco.service.cmr.model.FileExistsException;
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
import org.alfresco.service.cmr.model.FileInfo;
|
|
||||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.CopyService;
|
import org.alfresco.service.cmr.repository.CopyService;
|
||||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||||
@@ -182,12 +180,8 @@ public class ClipboardBean
|
|||||||
*/
|
*/
|
||||||
private void performPasteItems(int index, int action)
|
private void performPasteItems(int index, int action)
|
||||||
{
|
{
|
||||||
UserTransaction tx = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
|
|
||||||
tx.begin();
|
|
||||||
|
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
{
|
{
|
||||||
// paste all
|
// paste all
|
||||||
@@ -219,16 +213,11 @@ public class ClipboardBean
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// commit the transaction
|
|
||||||
tx.commit();
|
|
||||||
|
|
||||||
// refresh UI on success
|
// refresh UI on success
|
||||||
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
|
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
|
||||||
}
|
}
|
||||||
catch (Throwable err)
|
catch (Throwable err)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
|
|
||||||
Utils.addErrorMessage(Application.getMessage(
|
Utils.addErrorMessage(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), MSG_ERROR_PASTE) + err.getMessage(), err);
|
FacesContext.getCurrentInstance(), MSG_ERROR_PASTE) + err.getMessage(), err);
|
||||||
}
|
}
|
||||||
@@ -241,7 +230,7 @@ public class ClipboardBean
|
|||||||
* @param action the clipboard action to perform (see UIClipboardShelfItem)
|
* @param action the clipboard action to perform (see UIClipboardShelfItem)
|
||||||
*/
|
*/
|
||||||
private void performClipboardOperation(ClipboardItem item, int action)
|
private void performClipboardOperation(ClipboardItem item, int action)
|
||||||
throws FileExistsException, FileNotFoundException
|
throws Throwable
|
||||||
{
|
{
|
||||||
NodeRef destRef = new NodeRef(Repository.getStoreRef(), this.navigator.getCurrentNodeId());
|
NodeRef destRef = new NodeRef(Repository.getStoreRef(), this.navigator.getCurrentNodeId());
|
||||||
|
|
||||||
@@ -267,8 +256,12 @@ public class ClipboardBean
|
|||||||
boolean operationComplete = false;
|
boolean operationComplete = false;
|
||||||
while (operationComplete == false)
|
while (operationComplete == false)
|
||||||
{
|
{
|
||||||
|
UserTransaction tx = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// attempt each copy/paste in its own transaction
|
||||||
|
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
|
||||||
|
tx.begin();
|
||||||
if (item.Mode == ClipboardStatus.COPY)
|
if (item.Mode == ClipboardStatus.COPY)
|
||||||
{
|
{
|
||||||
if (action == UIClipboardShelfItem.ACTION_PASTE_LINK)
|
if (action == UIClipboardShelfItem.ACTION_PASTE_LINK)
|
||||||
@@ -399,11 +392,26 @@ public class ClipboardBean
|
|||||||
throw fileExistsErr;
|
throw fileExistsErr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Throwable e)
|
||||||
|
{
|
||||||
|
// some other type of exception occured - rollback and exit
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// rollback if the operation didn't complete
|
||||||
if (operationComplete == false)
|
if (operationComplete == false)
|
||||||
{
|
{
|
||||||
|
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
|
||||||
String copyOf = Application.getMessage(FacesContext.getCurrentInstance(), MSG_COPY_OF);
|
String copyOf = Application.getMessage(FacesContext.getCurrentInstance(), MSG_COPY_OF);
|
||||||
name = copyOf + ' ' + name;
|
name = copyOf + ' ' + name;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// commit the transaction
|
||||||
|
tx.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user