Lines 960-968
Link Here
|
960 |
|
960 |
|
961 |
public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException |
961 |
public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException |
962 |
{ |
962 |
{ |
963 |
String remotePath = remoteParent + getSeparator(remoteParent) + oldName; |
963 |
String oldPath, newPath = null; |
964 |
DataElement de = getElementFor(remotePath); |
964 |
// if remoteParent is null or empty then we are doing a move |
965 |
de.setAttribute(DE.A_SOURCE, newName); |
965 |
if (remoteParent == null || remoteParent == "") //$NON-NLS-1$ |
|
|
966 |
{ |
967 |
oldPath = oldName; |
968 |
newPath = newName; |
969 |
} |
970 |
else |
971 |
{ |
972 |
oldPath = remoteParent + getSeparator(remoteParent) + oldName; |
973 |
newPath = remoteParent + getSeparator(remoteParent) + newName; |
974 |
} |
975 |
|
976 |
DataElement de = getElementFor(oldPath); |
977 |
de.setAttribute(DE.A_SOURCE, newPath); |
966 |
|
978 |
|
967 |
DataElement status = dsStatusCommand(de, IUniversalDataStoreConstants.C_RENAME, monitor); |
979 |
DataElement status = dsStatusCommand(de, IUniversalDataStoreConstants.C_RENAME, monitor); |
968 |
|
980 |
|
Lines 983-1008
Link Here
|
983 |
return retVal; |
995 |
return retVal; |
984 |
} |
996 |
} |
985 |
|
997 |
|
|
|
998 |
protected boolean moveByCopy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException |
999 |
{ |
1000 |
if (copy(srcParent, srcName, tgtParent, tgtName, monitor)) |
1001 |
{ |
1002 |
return delete(srcParent, srcName, monitor); |
1003 |
} |
1004 |
return false; |
1005 |
} |
1006 |
|
986 |
public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException |
1007 |
public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException |
987 |
{ |
1008 |
{ |
988 |
// String src = srcParent + getSeparator(srcParent) + srcName; |
1009 |
String src = srcParent + getSeparator(srcParent) + srcName; |
989 |
// String tgt = tgtParent + getSeparator(tgtParent) + tgtName; |
1010 |
String tgt = tgtParent + getSeparator(tgtParent) + tgtName; |
990 |
// boolean isVirtual = ArchiveHandlerManager.isVirtual(src) || ArchiveHandlerManager.isVirtual(tgt); |
1011 |
boolean isVirtual = ArchiveHandlerManager.isVirtual(src) || ArchiveHandlerManager.isVirtual(tgt); |
991 |
//if (isVirtual || isArchive) |
1012 |
boolean isArchive = ArchiveHandlerManager.getInstance().isRegisteredArchive(tgt); |
992 |
{ |
1013 |
if (isVirtual || isArchive) |
993 |
if (copy(srcParent, srcName, tgtParent, tgtName, monitor)) |
1014 |
{ |
994 |
{ |
1015 |
return moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor); |
995 |
try |
1016 |
} |
996 |
{ |
1017 |
else |
997 |
delete(srcParent, srcName, monitor); |
1018 |
{ |
998 |
} |
1019 |
boolean movedOk = false; |
999 |
catch (Exception e) |
1020 |
try |
1000 |
{ |
1021 |
{ |
1001 |
return false; |
1022 |
movedOk = rename("", src, tgt, monitor); //$NON-NLS-1$ |
1002 |
} |
|
|
1003 |
return true; |
1004 |
} |
1023 |
} |
1005 |
return false; |
1024 |
catch (SystemMessageException e) |
|
|
1025 |
{ |
1026 |
return moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor); |
1027 |
} |
1028 |
// movedOk should never be false otherwise the last DataElement status was null |
1029 |
if (!movedOk) |
1030 |
{ |
1031 |
movedOk = moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor); |
1032 |
} |
1033 |
return movedOk; |
1006 |
} |
1034 |
} |
1007 |
|
1035 |
|
1008 |
/* |
1036 |
/* |