提交 68d70880 编写于 作者: M meyerd

Activiti Cycle added 'createNewEmptyArtifact'-method to RepositoryConnector-Interface.

上级 903928a2
......@@ -79,6 +79,20 @@ public interface RepositoryConnector {
public RepositoryArtifact createArtifactFromContentRepresentation(String parentFolderId, String artifactName, String artifactType,
String contentRepresentationName, Content artifactContent) throws RepositoryNodeNotFoundException;
/**
* create a new {@link RepositoryArtifact} with no content.
*
*
* @param parentFolderId
* the id of the parent {@link RepositoryFolder}
* @param artifactName
* name of the new {@link RepositoryArtifact}
* @param artifactType
* type of the new {@link RepositoryArtifact}
*
*/
public RepositoryArtifact createEmptyArtifact(String parentFolderId, String artifactName, String artifactType) throws RepositoryNodeNotFoundException;;
/**
* create a new subfolder in the given folder
*/
......
......@@ -84,8 +84,27 @@ public abstract class AbstractRepositoryConnector implements RepositoryConnector
if (value == null) {
return null;
}
if (value instanceof String) {
if (String.class.equals(castTo)) {
return (T) value;
}
if (Boolean.class.equals(castTo)) {
return (T) Boolean.valueOf((String) value);
}
if (Integer.class.equals(castTo)) {
return (T) Integer.valueOf((String) value);
}
if (Float.class.equals(castTo)) {
return (T) Float.valueOf((String) value);
}
if (Long.class.equals(castTo)) {
return (T) Long.valueOf((String) value);
}
throw new RuntimeException("Cannot cast connector configuration value of type 'String' for key '" + key + "' to class '" + castTo);
} else {
return (T) value;
}
}
protected void setConfigValue(String key, String value) {
configurationValues.put(key, value);
......
......@@ -201,6 +201,12 @@ public class FileSystemConnector extends AbstractFileSystemBasedRepositoryConnec
return folder;
}
public RepositoryArtifact createEmptyArtifact(String parentFolderId, String artifactName, String artifactType) throws RepositoryNodeNotFoundException {
Content emptyContent = new Content();
emptyContent.setValue("");
return createArtifact(parentFolderId, artifactName, artifactType, emptyContent);
}
public RepositoryArtifact createArtifact(String parentFolderId, String artifactName, String artifactType, Content artifactContent)
throws RepositoryNodeNotFoundException {
File newFile = new File(getFileFromId(parentFolderId), artifactName);
......
......@@ -601,6 +601,10 @@ public class SignavioConnector extends AbstractRepositoryConnector implements Si
}
}
public RepositoryArtifact createEmptyArtifact(String parentFolderId, String artifactName, String artifactType) throws RepositoryNodeNotFoundException {
return createArtifactFromJSON(parentFolderId, artifactName, artifactType, "{}");
}
public RepositoryArtifact createArtifact(String parentFolderId, String artifactName, String artifactType, Content artifactContent)
throws RepositoryNodeNotFoundException {
// TODO: Add handling of different artifact types!
......
......@@ -70,6 +70,10 @@ public class TagConnector implements RepositoryConnector {
return tagFolderList;
}
public RepositoryArtifact createEmptyArtifact(String parentFolderId, String artifactName, String artifactType) throws RepositoryNodeNotFoundException {
throw new UnsupportedOperationException("Cannot create artifact in TagConnector, use real RepositoryConnector istead.");
}
public RepositoryNode getRepositoryNode(String id) throws RepositoryNodeNotFoundException {
return getRepositoryFolder(id);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册