+ if (isResultFolder) {\r
+ // Sanity check : we cannot move a folder to one of its sub\r
+ // folder or neither move an object in the same parent\r
+ // folder\r
+ Node source = session.getNodeByIdentifier((String) data);\r
+ if (targetParentNode.getPath().startsWith(source.getPath())\r
+ || source.getParent().getPath()\r
+ .equals(targetParentNode.getPath()))\r
+ return false;\r
+\r
+ // Move\r
+ String sourcePath = source.getPath();\r
+ String destPath = targetParentNode.getPath() + "/"\r
+ + source.getName();\r
+ session.move(sourcePath, destPath);\r
+ // Update passed status of the parent source Node\r
+ ResultParentUtils.updatePassedStatus(\r
+ session.getNode(JcrUtils.parentPath(sourcePath)),\r
+ true);\r
+ // Node target = session.getNode(destPath);\r
+ session.save();\r
+ return true;\r
+ }\r
+\r
+ String[] datas = ((String) data).split(";");\r
+ nodesToCopy: for (String id : datas) {\r
+\r
+ Node source = session.getNodeByIdentifier(id);\r
+ String name;\r
+ if (source.hasProperty(Property.JCR_TITLE))\r
+ name = source.getProperty(Property.JCR_TITLE)\r
+ .getString();\r
+ else if (source.hasProperty(SlcNames.SLC_TEST_CASE))\r
+ name = source.getProperty(SlcNames.SLC_TEST_CASE)\r
+ .getString();\r
+ else\r
+ name = source.getName();\r
+\r
+ // Check if another copy of the same test instance already\r
+ // exists at target\r
+ NodeIterator ni = targetParentNode.getNodes();\r
+ String slcUid = source.getProperty(SlcNames.SLC_UUID)\r
+ .getString();\r
+ while (ni.hasNext()) {\r
+ Node curr = ni.nextNode();\r
+ if (curr.hasProperty(SlcNames.SLC_UUID)\r
+ && slcUid.equals(curr.getProperty(\r
+ SlcNames.SLC_UUID).getString())) {\r
+ MessageDialog\r
+ .openWarning(\r
+ PlatformUI.getWorkbench()\r
+ .getDisplay()\r
+ .getActiveShell(),\r
+ "Duplicated instance.",\r
+ "An instance of the same test case ("\r
+ + name\r
+ + ") exists at destination.\n "\r
+ + "This item will not be neither copied nor moved.");\r
+ continue nodesToCopy;\r
+\r
+ }\r
+ }\r
+\r
+ Node target;\r
+ boolean passedStatus = source\r
+ .getNode(SlcNames.SLC_AGGREGATED_STATUS)\r
+ .getProperty(SlcNames.SLC_SUCCESS).getBoolean();\r
+\r
+ boolean isActionUnderMyResult = source.getPath()\r
+ .startsWith(\r
+ SlcJcrResultUtils\r
+ .getMyResultsBasePath(session));\r
+\r
+ if (!isActionUnderMyResult) {// Copy\r
+ target = targetParentNode.addNode(source.getName(),\r
+ source.getPrimaryNodeType().getName());\r
+ JcrUtils.copy(source, target);\r
+ } else {// move\r
+ String sourcePath = source.getPath();\r
+ String destPath = targetParentNode.getPath() + "/"\r
+ + name;\r
+ session.move(sourcePath, destPath);\r
+ // session.save();\r
+ // Update passed status of the parent source Node\r
+ ResultParentUtils\r
+ .updatePassedStatus(session.getNode(JcrUtils\r
+ .parentPath(sourcePath)), true);\r
+ target = session.getNode(destPath);\r
+\r
+ }\r
+ if (!target.isNodeType(NodeType.MIX_TITLE))\r
+ target.addMixin(NodeType.MIX_TITLE);\r
+ target.setProperty(Property.JCR_TITLE, name);\r
+ ResultParentUtils.updatePassedStatus(target.getParent(),\r
+ passedStatus);\r
+ session.save();\r
+\r
+ // try {\r
+ // Node source = session.getNodeByIdentifier(id);\r
+ // String name;\r
+ // if (source.hasProperty(Property.JCR_TITLE))\r
+ // name = source.getProperty(Property.JCR_TITLE)\r
+ // .getString();\r
+ // else if (source.hasProperty(SlcNames.SLC_TEST_CASE))\r
+ // name = source.getProperty(SlcNames.SLC_TEST_CASE)\r
+ // .getString();\r
+ // else\r
+ // name = source.getName();\r
+ //\r
+ // // Check if a user defined folder result with same name\r
+ // // exists\r
+ // // at target\r
+ // if (targetParentNode.hasNode(name)\r
+ // && targetParentNode.getNode(name).isNodeType(\r
+ // SlcTypes.SLC_RESULT_FOLDER)) {\r
+ // ConfirmOverwriteWizard wizard = new\r
+ // ConfirmOverwriteWizard(\r
+ // name, targetParentNode);\r
+ // WizardDialog dialog = new WizardDialog(Display\r
+ // .getDefault().getActiveShell(), wizard);\r
+ //\r
+ // if (dialog.open() == WizardDialog.CANCEL)\r
+ // return true;\r
+ //\r
+ // if (wizard.overwrite()) {\r
+ // targetParentNode.getNode(name).remove();\r
+ // // session.save();\r
+ // } else\r
+ // name = wizard.newName();\r
+ // }\r
+ //\r
+ // Node target;\r
+ // boolean passedStatus = source\r
+ // .getNode(SlcNames.SLC_AGGREGATED_STATUS)\r
+ // .getProperty(SlcNames.SLC_SUCCESS).getBoolean();\r
+ //\r
+ // if (!isActionUnderMyResult) {// Copy\r
+ // target = targetParentNode.addNode(source.getName(),\r
+ // source.getPrimaryNodeType().getName());\r
+ // JcrUtils.copy(source, target);\r
+ // } else {// move\r
+ // String sourcePath = source.getPath();\r
+ // String destPath = targetParentNode.getPath() + "/"\r
+ // + name;\r
+ // session.move(sourcePath, destPath);\r
+ // // session.save();\r
+ // // Update passed status of the parent source Node\r
+ // ResultParentUtils\r
+ // .updatePassedStatus(session.getNode(JcrUtils\r
+ // .parentPath(sourcePath)), true);\r
+ // target = session.getNode(destPath);\r
+ //\r
+ // }\r
+ // if (!target.isNodeType(NodeType.MIX_TITLE))\r
+ // target.addMixin(NodeType.MIX_TITLE);\r
+ // target.setProperty(Property.JCR_TITLE, name);\r
+ // ResultParentUtils.updatePassedStatus(target.getParent(),\r
+ // passedStatus);\r
+ // session.save();\r
+\r
+ }\r