summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikas Mishra2012-03-13 07:57:39 (EDT)
committer Stephan Born2012-04-23 07:40:14 (EDT)
commit80b5a65cc1ed5588d7468b841bbf010113bd11a0 (patch)
tree2ec973d954b0c1475048fab66f7f4364a3c93671
parentaa8f93d7bc79e753bfa01aa44c47084ab0411b4b (diff)
downloadorg.eclipse.stardust.engine-80b5a65cc1ed5588d7468b841bbf010113bd11a0.zip
org.eclipse.stardust.engine-80b5a65cc1ed5588d7468b841bbf010113bd11a0.tar.gz
org.eclipse.stardust.engine-80b5a65cc1ed5588d7468b841bbf010113bd11a0.tar.bz2
Jira-ID: CRNT-24165
generate new file name in comment class and also for every extract page so that new file generate each time. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/engine@54502 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/command/impl/ExtractPageCommand.java66
1 files changed, 50 insertions, 16 deletions
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/command/impl/ExtractPageCommand.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/command/impl/ExtractPageCommand.java
index a347548..b1684d9 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/command/impl/ExtractPageCommand.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/command/impl/ExtractPageCommand.java
@@ -13,6 +13,7 @@ package org.eclipse.stardust.engine.core.runtime.command.impl;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -37,6 +38,7 @@ import org.eclipse.stardust.engine.extensions.dms.data.annotations.printdocument
+
/**
*
* Service command class for ExtractPage
@@ -52,10 +54,11 @@ public class ExtractPageCommand implements ServiceCommand
private ProcessInstance processInstance;
private List<PageModel> pages;
private String sourceDocumentName;
- private String sourceDocumentPath;
- private String newDocumentName;
+ private String sourceDocumentPath;
private ServiceFactory sf;
- private String mimeType;
+ private String mimeType;
+ private String fileName;
+ private String fileExtn;
/**
*
@@ -63,7 +66,7 @@ public class ExtractPageCommand implements ServiceCommand
public Serializable execute(ServiceFactory sf)
{
this.sf = sf;
-
+ init();
if (null != processInstance)
{
return (Serializable) spawnProcesses();
@@ -75,6 +78,14 @@ public class ExtractPageCommand implements ServiceCommand
}
}
+
+ private void init()
+ {
+ fileName = stripExtension(sourceDocumentName);
+ fileExtn = sourceDocumentName.length() > fileName.length()
+ ? sourceDocumentName.substring(fileName.length() + 1)
+ : "";
+ }
/**
* if source document is not associated with any process then call this method create
@@ -88,7 +99,7 @@ public class ExtractPageCommand implements ServiceCommand
{
Map<String, Object> data = null;
Document document = null;
-
+ String newDocumentName = generateName();
if (StringUtils.isNotEmpty(page.getDataId()) && !PROCESS_ATTACHMENT_DATA.equals(page.getDataId()))
{
Map<String, Object> properties = CollectionUtils.newHashMap();
@@ -120,7 +131,7 @@ public class ExtractPageCommand implements ServiceCommand
page.setDocument(document);
}
return processInstances;
- }
+ }
/**
* if document is associated with process then call this method create document in root
@@ -138,6 +149,7 @@ public class ExtractPageCommand implements ServiceCommand
for (PageModel page : pages)
{
+ String newDocumentName = generateName();
if (StringUtils.isNotEmpty(page.getDataId()) && !PROCESS_ATTACHMENT_DATA.equals(page.getDataId()))
{
Map<String, Object> properties = CollectionUtils.newHashMap();
@@ -168,6 +180,7 @@ public class ExtractPageCommand implements ServiceCommand
if (PROCESS_ATTACHMENT_DATA.equals(page.getDataId()) && ExtractPageUtil.isProcessAttachmentAllowed(sf, pi))
{
+ String newDocumentName = generateName();
Folder processFolder = ExtractPageUtil.getProcessAttachmentsFolder(sf, pi);
Map<String, Object> properties = CollectionUtils.newHashMap();
@@ -222,16 +235,7 @@ public class ExtractPageCommand implements ServiceCommand
{
this.sourceDocumentName = sourceDocumentName;
}
-
- public String getNewDocumentName()
- {
- return newDocumentName;
- }
-
- public void setNewDocumentName(String newDocumentName)
- {
- this.newDocumentName = newDocumentName;
- }
+
public String getMimeType()
{
@@ -494,6 +498,36 @@ public class ExtractPageCommand implements ServiceCommand
}
}
+ /**
+ * generate new file name by appending date-time in source file name
+ *
+ * @return
+ */
+ private String generateName()
+ {
+ StringBuilder name = new StringBuilder().append(fileName).append("_")
+ .append(String.valueOf(new Date().getTime()));
+
+ if (StringUtils.isNotEmpty(fileExtn))
+ {
+ name.append(".").append(fileExtn);
+ }
+ return name.toString();
+ }
+
+ /**
+ *
+ * @param fileName
+ */
+ private String stripExtension(String fileName)
+ {
+ int index = fileName.lastIndexOf('.');
+ if (index > 0 && index <= fileName.length() - 2)
+ {
+ return fileName.substring(0, index);
+ }
+ return fileName;
+ }
}