Author: mputz
Date: 2008-10-07 15:36:55 -0400 (Tue, 07 Oct 2008)
New Revision: 12045
Modified:
branches/JBoss_Portal_2_6_6_JBPORTAL-2109/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
branches/JBoss_Portal_2_6_6_JBPORTAL-2109/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties
Log:
JBPORTAL-2193 - Copy and Move functions create dummy files if destination exists
Modified:
branches/JBoss_Portal_2_6_6_JBPORTAL-2109/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
===================================================================
---
branches/JBoss_Portal_2_6_6_JBPORTAL-2109/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-10-07
15:31:16 UTC (rev 12044)
+++
branches/JBoss_Portal_2_6_6_JBPORTAL-2109/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-10-07
19:36:55 UTC (rev 12045)
@@ -1109,7 +1109,27 @@
{
String sNodeName = sFrom.substring(sFrom.lastIndexOf("/") + 1,
sFrom.length());
sTo = FileUtil.cleanDoubleSlashes(sTo + "/" + sNodeName);
+
+ // check if destination already exists
+ Command existsCMD =
CMSService.getCommandFactory().createItemExistsCommand(sTo);
+ Boolean bExists = (Boolean)CMSService.execute(existsCMD);
+ if (bExists.booleanValue())
+ {
+ List messages = new ArrayList();
+
messages.add(this.resources.getObject("CMS_MSG_DESTINATION_ALREADY_EXISTS"));
+ aReq.getPortletSession().setAttribute("messages",
messages);
+ try
+ {
+ String sParentPath = NodeUtil.getParentPath(sFrom);
+ aRes.setRenderParameter("path", sParentPath);
+ }
+ catch (Exception e)
+ {
+ }
+ return;
+ }
+
Command copyCommand =
CMSService.getCommandFactory().createCopyCommand(sFrom, sTo);
CMSService.execute(copyCommand);
@@ -1134,6 +1154,29 @@
{
String sNodeName = sFrom.substring(sFrom.lastIndexOf("/") + 1,
sFrom.length());
sTo = FileUtil.cleanDoubleSlashes(sTo + "/" + sNodeName);
+
+ // check if destination already exists
+ Command existsCMD =
CMSService.getCommandFactory().createItemExistsCommand(sTo);
+ Boolean bExists = (Boolean)CMSService.execute(existsCMD);
+ if (bExists.booleanValue())
+ {
+ List messages = new ArrayList();
+
messages.add(this.resources.getObject("CMS_MSG_DESTINATION_ALREADY_EXISTS"));
+ aReq.getPortletSession().setAttribute("messages",
messages);
+ try
+ {
+ String sParentPath = NodeUtil.getParentPath(sFrom);
+ aRes.setRenderParameter("path", sParentPath);
+ }
+ catch (Exception e)
+ {
+
+ }
+ return;
+ }
+
+ Command moveCommand =
CMSService.getCommandFactory().createMoveCommand(sFrom, sTo);
+ CMSService.execute(moveCommand);
if ("fo".equalsIgnoreCase(sType))
{
aRes.setRenderParameter("op", CMSAdminConstants.OP_MAIN);
@@ -1142,8 +1185,6 @@
{
aRes.setRenderParameter("op",
CMSAdminConstants.OP_VIEWFILE);
}
- Command moveCommand =
CMSService.getCommandFactory().createMoveCommand(sFrom, sTo);
- CMSService.execute(moveCommand);
aRes.setRenderParameter("path", sTo);
}
Modified:
branches/JBoss_Portal_2_6_6_JBPORTAL-2109/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties
===================================================================
---
branches/JBoss_Portal_2_6_6_JBPORTAL-2109/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties 2008-10-07
15:31:16 UTC (rev 12044)
+++
branches/JBoss_Portal_2_6_6_JBPORTAL-2109/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties 2008-10-07
19:36:55 UTC (rev 12045)
@@ -138,3 +138,5 @@
CMS_FILENAME_INVALID=File Name is invalid. It may not contain illegal characters such as
'.', '/', ':', '[', ']', '*',
''', '"', '|' or any whitespace character.
CMS_FOLDERNAME_INVALID=Folder Name is invalid. It may not contain illegal characters such
as '.', '/', ':', '[', ']', '*',
''', '"', '|' or any whitespace character.
+
+CMS_MSG_DESTINATION_ALREADY_EXISTS=The command was not performed, because the destination
already exists.
Show replies by date