diff --git a/modules/activiti-cycle/src/main/java/org/activiti/cycle/ArtifactType.java b/modules/activiti-cycle/src/main/java/org/activiti/cycle/ArtifactType.java index 735657563fb69f1342399dfde6975be9f5697687..f01112e55840735ce6ec61574ec847d0c66e647e 100644 --- a/modules/activiti-cycle/src/main/java/org/activiti/cycle/ArtifactType.java +++ b/modules/activiti-cycle/src/main/java/org/activiti/cycle/ArtifactType.java @@ -28,6 +28,8 @@ import java.util.List; public interface ArtifactType { public String getId(); + + public ContentType getContentType(); /** * list of {@link ContentRepresentation} in the configured order diff --git a/modules/activiti-cycle/src/main/java/org/activiti/cycle/ContentRepresentation.java b/modules/activiti-cycle/src/main/java/org/activiti/cycle/ContentRepresentation.java index 81daf06979056dfd9563a816f32d2816e437cb1c..425664e2d3896a36cf39810c941ae1063728f3d7 100644 --- a/modules/activiti-cycle/src/main/java/org/activiti/cycle/ContentRepresentation.java +++ b/modules/activiti-cycle/src/main/java/org/activiti/cycle/ContentRepresentation.java @@ -25,10 +25,10 @@ public interface ContentRepresentation extends Serializable { public String getId(); /** - * type of content as normally indicated by {@link ContentType} (e.g. text - * file, image, ...). Information for the client to render it correctly. + * Type of content (e.g. text file, image, ...). Information for the client + * to render the content correctly. */ - public String getMimeType(); + public ContentType getContentType(); // TODO: Think about that, maybe as annotation in the Plugin-Config // public boolean isDownloadable(); } diff --git a/modules/activiti-cycle/src/main/java/org/activiti/cycle/ContentType.java b/modules/activiti-cycle/src/main/java/org/activiti/cycle/ContentType.java index f538e36d9aadec2196cba3953179475bcfb3526b..19e7cec8a2e5929f61ee389aebfa2442960de4b9 100644 --- a/modules/activiti-cycle/src/main/java/org/activiti/cycle/ContentType.java +++ b/modules/activiti-cycle/src/main/java/org/activiti/cycle/ContentType.java @@ -10,22 +10,32 @@ package org.activiti.cycle; * * @author bernd.ruecker@camunda.com */ -public class ContentType { +public enum ContentType { - public static final String PNG = "image/png"; - public static final String GIF = "image/gif"; - public static final String JPEG = "image/jpeg"; // or use "image/jpeg;charset=ISO-8859-1" ? - public static final String XML = "application/xml"; - public static final String HTML = "text/html"; - public static final String TEXT = "text/plain"; - public static final String PDF = "application/pdf"; - public static final String JSON = "application/json;charset=UTF-8"; - public static final String MS_WORD = "application/msword"; - public static final String MS_POWERPOINT = "application/powerpoint"; - public static final String MS_EXCEL = "application/excel"; - public static final String JAVASCRIPT = "application/javascript"; - - // TODO: Hmm? - public static final String BINARY = "unknown"; + PNG("image/png"), + GIF("image/gif"), + JPEG("image/jpeg") /* or use "image/jpeg;charset=ISO-8859-1" ? */, + XML("application/xml"), + HTML("text/html"), + TEXT("text/plain"), + PDF("application/pdf"), + JSON("application/json;charset=UTF-8"), + MS_WORD("application/msword"), + MS_POWERPOINT("application/powerpoint"), + MS_EXCEL("application/excel"), + JAVASCRIPT("application/javascript"), + // + // // TODO: Hmm? + BINARY("unknown"); -} + private final String name; + + private ContentType(String description) { + this.name = description; + } + + public String getName() { + return this.name; + } + +} \ No newline at end of file diff --git a/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/ArtifactTypeImpl.java b/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/ArtifactTypeImpl.java index 70f7aca697c3d0827067ac0cb2a1389af281e45d..d7b449e675d3e1e0b0f442371c8b492ff7c1f38f 100644 --- a/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/ArtifactTypeImpl.java +++ b/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/ArtifactTypeImpl.java @@ -20,6 +20,7 @@ import java.util.Map; import org.activiti.cycle.ArtifactType; import org.activiti.cycle.ContentProvider; import org.activiti.cycle.ContentRepresentation; +import org.activiti.cycle.ContentType; import org.activiti.cycle.CreateUrlAction; import org.activiti.cycle.DownloadContentAction; import org.activiti.cycle.ParameterizedAction; @@ -42,6 +43,8 @@ import org.activiti.cycle.RepositoryException; public class ArtifactTypeImpl implements ArtifactType { private String id; + + private ContentType contentType; /** * {@link List} of registered {@link ContentRepresentation}s of this @@ -63,8 +66,9 @@ public class ArtifactTypeImpl implements ArtifactType { private List downloadContentActions; - public ArtifactTypeImpl(String id) { + public ArtifactTypeImpl(String id, ContentType contentType) { this.id = id; + this.contentType = contentType; this.contentRepresentationList = new ArrayList(); this.contentProviderMap = new HashMap(); this.parameterizedActions = new ArrayList(); @@ -72,10 +76,11 @@ public class ArtifactTypeImpl implements ArtifactType { this.downloadContentActions = new ArrayList(); } - public ArtifactTypeImpl(String id, List contentRepresentationList, ContentRepresentation defaultContentRepresentation, + public ArtifactTypeImpl(String id, ContentType contentType, List contentRepresentationList, ContentRepresentation defaultContentRepresentation, Map contentProviderMap, List parameterizedActions, List openUrlActions, List downloadContentActions) { this.id = id; + this.contentType = contentType; this.contentRepresentationList = contentRepresentationList; this.defaultContentRepresentation = defaultContentRepresentation; this.contentProviderMap = contentProviderMap; @@ -88,6 +93,10 @@ public class ArtifactTypeImpl implements ArtifactType { return id; } + public ContentType getContentType() { + return this.contentType; + } + public ContentRepresentation getContentRepresentation(String id) { for (ContentRepresentation cr : getContentRepresentations()) { if (id.equals(cr.getId())) { @@ -268,6 +277,10 @@ public class ArtifactTypeImpl implements ArtifactType { throw new RepositoryException("Action '" + id + "' not found, cannot be executed. Existing actions are: " + actionNames.toString()); } + public void setContentType(ContentType contentType) { + this.contentType = contentType; + } + public void addDefaultContentRepresentation(ContentRepresentation contentRepresentation, ContentProvider provider) { addContentRepresentation(contentRepresentation, provider); defaultContentRepresentation = contentRepresentation; diff --git a/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/ContentRepresentationImpl.java b/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/ContentRepresentationImpl.java index f055e515e82a9da5b7831acb74c700c14e1c85a5..e1fddcbebab9aff5854b9978c690ed3adb9c5a50 100644 --- a/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/ContentRepresentationImpl.java +++ b/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/ContentRepresentationImpl.java @@ -3,6 +3,7 @@ package org.activiti.cycle.impl; import java.io.Serializable; import org.activiti.cycle.ContentRepresentation; +import org.activiti.cycle.ContentType; /** * Data structure for link to content, including the URL to the content, the @@ -22,11 +23,10 @@ public class ContentRepresentationImpl implements ContentRepresentation, Seriali private static final long serialVersionUID = 1L; /** - * type of content as normally indicated by {@link ContentType} - * (e.g. text file, image, ...). Information for the client to render it - * correctly. + * type of content (e.g. text file, image, ...). Information for the client to render + * the content correctly. */ - private String mimeType; + private ContentType contentType; /** * Name of this representation, serves as a unique key to query the @@ -35,17 +35,17 @@ public class ContentRepresentationImpl implements ContentRepresentation, Seriali */ private String id; - public ContentRepresentationImpl(String id, String mimeType) { + public ContentRepresentationImpl(String id, ContentType contentType) { super(); this.id = id; - this.mimeType = mimeType; + this.contentType = contentType; } public String getId() { return id; } - public String getMimeType() { - return mimeType; + public ContentType getContentType() { + return this.contentType; } } diff --git a/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/connector/demo/DemoConnectorPluginDefinition.java b/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/connector/demo/DemoConnectorPluginDefinition.java index 47269bfd89f7ef41909260c9d55e51d3ff1905f6..e7005c5d942fc61eef95e99efbc84db2f60bb30e 100644 --- a/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/connector/demo/DemoConnectorPluginDefinition.java +++ b/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/connector/demo/DemoConnectorPluginDefinition.java @@ -27,7 +27,7 @@ public class DemoConnectorPluginDefinition implements ActivitiCyclePluginDefinit public static final String CONTENT_REPRESENTATION_ID_XML = "XML"; public void addArtifactTypes(List types) { - ArtifactTypeImpl artifactType1 = new ArtifactTypeImpl(ARTIFACT_TYPE_TEXT); + ArtifactTypeImpl artifactType1 = new ArtifactTypeImpl(ARTIFACT_TYPE_TEXT, ContentType.TEXT); artifactType1.addDefaultContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_TEXT, ContentType.TEXT), new DemoProvider( CONTENT_REPRESENTATION_ID_TEXT)); artifactType1.addContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_EXCEPTION, ContentType.TEXT), new ExceptionProvider()); @@ -36,14 +36,14 @@ public class DemoConnectorPluginDefinition implements ActivitiCyclePluginDefinit artifactType1.addDownloadContentAction(CONTENT_REPRESENTATION_ID_TEXT); types.add(artifactType1); - ArtifactTypeImpl artifactType2 = new ArtifactTypeImpl(ARTIFACT_TYPE_MINDMAP); + ArtifactTypeImpl artifactType2 = new ArtifactTypeImpl(ARTIFACT_TYPE_MINDMAP, ContentType.XML); artifactType2.addDefaultContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_TEXT, ContentType.TEXT), new DemoProvider( CONTENT_REPRESENTATION_ID_TEXT)); artifactType2.addContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_PNG, ContentType.PNG), new DemoProvider( CONTENT_REPRESENTATION_ID_PNG)); types.add(artifactType2); - ArtifactTypeImpl artifactType3 = new ArtifactTypeImpl(ARTIFACT_TYPE_BPMN_20); + ArtifactTypeImpl artifactType3 = new ArtifactTypeImpl(ARTIFACT_TYPE_BPMN_20, ContentType.XML); artifactType3.addDefaultContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_XML, ContentType.TEXT), new DemoProvider( CONTENT_REPRESENTATION_ID_XML)); artifactType3.addParameterizedAction(new CopyArtifactAction()); diff --git a/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/connector/fs/FileSystemPluginDefinition.java b/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/connector/fs/FileSystemPluginDefinition.java index cb8528a44cb1714a02091b474217755b127b9117..4cc3743c470ce69bf89f2999e0ebc3dbb818a1bb 100644 --- a/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/connector/fs/FileSystemPluginDefinition.java +++ b/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/connector/fs/FileSystemPluginDefinition.java @@ -36,48 +36,48 @@ public class FileSystemPluginDefinition implements ActivitiCyclePluginDefinition // public static final String CONTENT_REPRESENTATION_ID_PDF = "pdf"; public void addArtifactTypes(List types) { - ArtifactTypeImpl artifactTypeDefault = new ArtifactTypeImpl(ARTIFACT_TYPE_DEFAULT); + ArtifactTypeImpl artifactTypeDefault = new ArtifactTypeImpl(ARTIFACT_TYPE_DEFAULT, ContentType.TEXT); artifactTypeDefault.addDefaultContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_BINARY, ContentType.BINARY), new FileBinaryContentProvider()); artifactTypeDefault.addDownloadContentAction(CONTENT_REPRESENTATION_ID_BINARY); types.add(artifactTypeDefault); - ArtifactTypeImpl artifactType1 = new ArtifactTypeImpl(ARTIFACT_TYPE_BPMN_20_XML); + ArtifactTypeImpl artifactType1 = new ArtifactTypeImpl(ARTIFACT_TYPE_BPMN_20_XML, ContentType.XML); artifactType1.addDefaultContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_XML, ContentType.XML), new XmlFileContentProvider()); artifactType1.addDownloadContentAction(CONTENT_REPRESENTATION_ID_XML); types.add(artifactType1); - ArtifactTypeImpl artifactType2 = new ArtifactTypeImpl(ARTIFACT_TYPE_ORYX_XML); + ArtifactTypeImpl artifactType2 = new ArtifactTypeImpl(ARTIFACT_TYPE_ORYX_XML, ContentType.XML); artifactType2.addDefaultContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_XML, ContentType.XML), new XmlFileContentProvider()); artifactType2.addDownloadContentAction(CONTENT_REPRESENTATION_ID_XML); types.add(artifactType2); - ArtifactTypeImpl artifactType3 = new ArtifactTypeImpl(ARTIFACT_TYPE_TEXT); + ArtifactTypeImpl artifactType3 = new ArtifactTypeImpl(ARTIFACT_TYPE_TEXT, ContentType.TEXT); artifactType3 .addDefaultContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_TEXT, ContentType.TEXT), new TextFileContentProvider()); artifactType3.addDownloadContentAction(CONTENT_REPRESENTATION_ID_TEXT); types.add(artifactType3); - ArtifactTypeImpl artifactTypeXml = new ArtifactTypeImpl(ARTIFACT_TYPE_XML); + ArtifactTypeImpl artifactTypeXml = new ArtifactTypeImpl(ARTIFACT_TYPE_XML, ContentType.XML); artifactTypeXml .addDefaultContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_XML, ContentType.XML), new XmlFileContentProvider()); artifactTypeXml.addDownloadContentAction(CONTENT_REPRESENTATION_ID_XML); types.add(artifactTypeXml); - ArtifactTypeImpl artifactType4 = new ArtifactTypeImpl(ARTIFACT_TYPE_MS_WORD); + ArtifactTypeImpl artifactType4 = new ArtifactTypeImpl(ARTIFACT_TYPE_MS_WORD, ContentType.MS_WORD); artifactType4.addDefaultContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_BINARY, ContentType.MS_WORD), new FileBinaryContentProvider()); artifactType4.addDownloadContentAction(CONTENT_REPRESENTATION_ID_BINARY); types.add(artifactType4); - ArtifactTypeImpl artifactType5 = new ArtifactTypeImpl(ARTIFACT_TYPE_MS_PP); + ArtifactTypeImpl artifactType5 = new ArtifactTypeImpl(ARTIFACT_TYPE_MS_PP, ContentType.MS_POWERPOINT); artifactType5.addDefaultContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_BINARY, ContentType.MS_POWERPOINT), new FileBinaryContentProvider()); artifactType5.addDownloadContentAction(CONTENT_REPRESENTATION_ID_BINARY); types.add(artifactType5); - ArtifactTypeImpl artifactType6 = new ArtifactTypeImpl(ARTIFACT_TYPE_PDF); + ArtifactTypeImpl artifactType6 = new ArtifactTypeImpl(ARTIFACT_TYPE_PDF, ContentType.PDF); artifactType6.addDefaultContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_BINARY, ContentType.PDF), new FileBinaryContentProvider()); artifactType6.addDownloadContentAction(CONTENT_REPRESENTATION_ID_BINARY); diff --git a/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/connector/signavio/SignavioPluginDefinition.java b/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/connector/signavio/SignavioPluginDefinition.java index 850b32fa50bdac1209eeb0f43e7f758b4a92e29d..1e6e6ea86835695231de425022fb94cc3a288563 100644 --- a/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/connector/signavio/SignavioPluginDefinition.java +++ b/modules/activiti-cycle/src/main/java/org/activiti/cycle/impl/connector/signavio/SignavioPluginDefinition.java @@ -59,7 +59,7 @@ public class SignavioPluginDefinition implements ActivitiCyclePluginDefinition { // SignavioConnector.SIGNAVIO_NAMESPACE_FOR_BPMN_JBPM4)); - ArtifactTypeImpl artifactType1 = new ArtifactTypeImpl(ARTIFACT_TYPE_BPMN_20); + ArtifactTypeImpl artifactType1 = new ArtifactTypeImpl(ARTIFACT_TYPE_BPMN_20, ContentType.XML); artifactType1.addDefaultContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_PNG, ContentType.PNG), new PngProvider()); artifactType1.addContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_BPMN_20_DEVELOPER, ContentType.XML), new ActivitiCompliantBpmn20Provider()); @@ -75,7 +75,7 @@ public class SignavioPluginDefinition implements ActivitiCyclePluginDefinition { types.add(artifactType1); - ArtifactTypeImpl artifactType2 = new ArtifactTypeImpl(ARTIFACT_TYPE_BPMN_FOR_JPDL4); + ArtifactTypeImpl artifactType2 = new ArtifactTypeImpl(ARTIFACT_TYPE_BPMN_FOR_JPDL4, ContentType.XML); artifactType2.addDefaultContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_PNG, ContentType.PNG), new PngProvider()); artifactType2.addContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_JPDL4, ContentType.XML), new Jpdl4Provider()); artifactType2.addContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_JSON, ContentType.XML), new JsonProvider()); @@ -89,7 +89,7 @@ public class SignavioPluginDefinition implements ActivitiCyclePluginDefinition { // initialize RepositoryRegistry with supported formats? // TODO: Check if really any artifact in Signavio has a PNG? - ArtifactTypeImpl artifactTypeDefault = new ArtifactTypeImpl(ARTIFACT_TYPE_DEFAULT); + ArtifactTypeImpl artifactTypeDefault = new ArtifactTypeImpl(ARTIFACT_TYPE_DEFAULT, ContentType.XML); artifactTypeDefault.addDefaultContentRepresentation(new ContentRepresentationImpl(CONTENT_REPRESENTATION_ID_PNG, ContentType.PNG), new PngProvider()); types.add(artifactTypeDefault); }