提交 f48b7ff2 编写于 作者: N nilspreusker

refactored cycle API, made CycleService the central API, added connectorId to...

refactored cycle API, made CycleService the central API, added connectorId to all methods in cycle service, got rid of root connector, seperated persistence into several services with interfaces and impl package, refactored GUI according to changes, removed some obsolete files and classes
上级 e4d13847
......@@ -3,6 +3,7 @@ package org.activiti.cycle;
import java.io.Serializable;
import java.util.List;
import org.activiti.cycle.impl.db.entity.CycleLink;
import org.activiti.engine.impl.db.PersistentObject;
/**
......
......@@ -50,4 +50,6 @@ public interface ArtifactType {
public List<DownloadContentAction> getDownloadContentActions();
public Long getRevision();
}
package org.activiti.cycle;
import org.activiti.cycle.impl.db.CycleServiceDbXStreamImpl;
import org.activiti.cycle.impl.plugin.PluginFinder;
/**
* TODO: make configurable somehow
* @author kristin.polenz@camunda.com
*/
public class Cycle {
public static CycleService getCycleService() {
PluginFinder.checkPluginInitialization();
return new CycleServiceDbXStreamImpl();
}
}
......@@ -13,8 +13,7 @@
package org.activiti.cycle;
import java.util.List;
import org.activiti.cycle.impl.conf.ConfigurationContainer;
import java.util.Map;
/**
* This is the central entry point for Activiti Cycle. The service provides the
......@@ -23,27 +22,95 @@ import org.activiti.cycle.impl.conf.ConfigurationContainer;
* repository like Tags, Links and so on...
*/
public interface CycleService {
public ConfigurationContainer getConfiguration(String name);
public void saveConfiguration(ConfigurationContainer container);
/**
* adds default {@link Artifact} for the supplied artifact ids. If you need
* more specific links please use the "addLink" method
* Log in user to all registered repositories
*
* TODO: (Nils Preusker, 20.10.2010) this needs to be reviewed, we are
* currently expecting one user for all repos...
*/
public boolean login(String username, String password);
/**
* Some connectors support commit (like SVN), so all pending changes must be
* committed correctly. If the connector doesn't support committing, this
* method just does nothing. This means, there is no rollback and you
* shouldn't rely on a transaction behavior.
*/
public void commitPendingChanges(String connectorId, String comment);
/**
* load the {@link RepositoryArtifact} including details
*/
public RepositoryArtifact getRepositoryArtifact(String connectorId, String artifactId) throws RepositoryNodeNotFoundException;
/**
* returns a preview for the artifact if available, otherwiese null is
* returned. Not every connector must provide a preview for all
* {@link ArtifactType}s.
*/
public Content getRepositoryArtifactPreview(String connectorId, String artifactId) throws RepositoryNodeNotFoundException;
public RepositoryFolder getRepositoryFolder(String connectorId, String folderId) throws RepositoryNodeNotFoundException;
/**
* gets all elements
*/
public RepositoryNodeCollection getChildren(String connectorId, String folderId) throws RepositoryNodeNotFoundException;
/**
* return the list of supported {@link ArtifactType}s of this
* {@link RepositoryConnector} for the given folder. Most conenctors doesn't
* make any difference between the folders, but some may do.
*/
public List<ArtifactType> getSupportedArtifactTypes(String connectorId, String folderId);
/**
* create a new file in the given folder with the default
* {@link ContentRepresentation}
*
* @param artifactId
*/
public RepositoryArtifact createArtifact(String connectorId, String containingFolderId, String artifactName, String artifactType, Content artifactContent)
throws RepositoryNodeNotFoundException;
public RepositoryArtifact createArtifactFromContentRepresentation(String connectorId, String containingFolderId, String artifactName, String artifactType,
String contentRepresentationId, Content artifactContent) throws RepositoryNodeNotFoundException;
/**
* create a new subfolder in the given folder
*/
public void addArtifactLink(String sourceArtifactId, String targetArtifactId);
public RepositoryFolder createFolder(String connectorId, String parentFolderId, String name) throws RepositoryNodeNotFoundException;
public Content getContent(String connectorId, String artifactId, String representationName) throws RepositoryNodeNotFoundException;
/**
* update artifact content with default {@link ContentRepresentation}
*/
public void updateContent(String connectorId, String artifactId, Content content) throws RepositoryNodeNotFoundException;
public void updateContent(String connectorId, String artifactId, String contentRepresentationName, Content content) throws RepositoryNodeNotFoundException;
/**
* add given link to Cycle
* deletes the given file from the folder
*/
public void addLink(RepositoryArtifactLink link);
public void deleteArtifact(String connectorId, String artifactId) throws RepositoryNodeNotFoundException;
/**
* deletes the given subfolder of the parent folder.
*
* TODO: Think about if we need the parent folder as argument of this API
*/
public void deleteFolder(String connectorId, String folderId) throws RepositoryNodeNotFoundException;
public void executeParameterizedAction(String connectorId, String artifactId, String actionId, Map<String, Object> parameters) throws Exception;
public void addArtifactLink(RepositoryArtifactLink link);
public List<RepositoryArtifactLink> getArtifactLinks(String sourceArtifactId);
public List<RepositoryArtifactLink> getArtifactLinks(String sourceArtifactId, Long sourceRevision);
public List<RepositoryArtifactLink> getArtifactLinks(String sourceArtifactId, String type);
public List<RepositoryArtifactLink> getArtifactLinks(String sourceArtifactId, Long sourceRevision, String type);
public void deleteLink(long linkId);
/**
......@@ -56,7 +123,7 @@ public interface CycleService {
* GUI later on when showing the tag to the user
*/
public void addTag(String nodeId, String tagName, String alias);
/**
* delete the
*/
......@@ -68,12 +135,12 @@ public interface CycleService {
* different alias for tag names lead to different {@link CycleTag} objects.
*/
public List<CycleTag> getTags(String nodeId) throws RepositoryNodeNotFoundException;
/**
* get all available tags for the system in order to show them in the GUI (as
* folder, tag cloud, ...)
*/
public List<CycleTag> getAllTags();
public List<CycleTag> getAllTags();
/**
* get all available tags for the system in order to show them in the GUI (as
......@@ -81,6 +148,6 @@ public interface CycleService {
* names with different alias are merged together (which normally make sense
* for the top level GUI)
*/
public List<CycleTag> getAllTagsIgnoreAlias();
public List<CycleTag> getAllTagsIgnoreAlias();
}
......@@ -26,4 +26,5 @@ public interface RepositoryArtifact extends RepositoryNode {
public ArtifactType getArtifactType();
public List<RepositoryArtifactOpenLinkAction> getOpenLinkActions();
}
......@@ -3,32 +3,25 @@ package org.activiti.cycle;
/**
*
* @author polenz
* @author Nils Preusker (nils.preusker@camunda.com)
*/
public interface RepositoryArtifactLink {
public String getId();
public RepositoryArtifact getSourceArtifactId();
public RepositoryArtifact getTargetArtifactId();
public String getSourceElementName();
public String getTargetElementName();
public RepositoryArtifact getSourceArtifact();
public String getSourceElementId();
public String getSourceElementName();
public RepositoryArtifact getTargetArtifact();
public String getTargetElementId();
public Long getSourceRevision();
public Long getTargetRevision();
public String getDescription();
public String getLinkType();
public Boolean isLinkedBothWays();
public String getTargetElementName();
public void setId(String id);
public void setSourceArtifactId(RepositoryArtifact sourceArtifactId);
public void setTargetArtifactId(RepositoryArtifact targetArtifactId);
public void setSourceElementName(String sourceElementName);
public void setTargetElementName(String targetElementName);
public void setSourceArtifact(RepositoryArtifact sourceArtifact);
public void setSourceElementId(String sourceElementId);
public void setSourceElementName(String sourceElementName);
public void setTargetArtifact(RepositoryArtifact targetArtifact);
public void setTargetElementId(String targetElementId);
public void setSourceRevision(Long sourceRevision);
public void setTargetRevision(Long targetRevision);
public void setDescription(String description);
public void setLinkType(String linkType);
public void setLinkedBothWays(Boolean linkedBothWays);
public void setTargetElementName(String targetElementName);
}
......@@ -12,7 +12,7 @@
*/
package org.activiti.cycle;
import org.activiti.cycle.impl.connector.view.RootConnector;
import org.activiti.cycle.impl.CycleServiceImpl;
/**
......@@ -69,10 +69,10 @@ public interface RepositoryNode {
* you don't have a special use case use this one!</b>
*
* current path of artifact in the current "context", so for example the id of
* the artifact when using the {@link RootConnector} or maybe another
* the artifact when using the {@link CycleServiceImpl} or maybe another
* accumulating connector like tags, ... This ID is <b>NOT</b> globally unique
* and just always used in one special context. It may even be changed by
* connectors like the {@link RootConnector} on the fly.
* connectors like the {@link CycleServiceImpl} on the fly.
*/
public String getCurrentPath();
......
......@@ -65,7 +65,9 @@ public class ArtifactTypeImpl implements ArtifactType {
private List<CreateUrlAction> openUrlActions;
private List<DownloadContentAction> downloadContentActions;
private List<DownloadContentAction> downloadContentActions;
private Long revision;
public ArtifactTypeImpl(String id, CycleDefaultMimeType mimeType) {
this.id = id;
......@@ -75,11 +77,12 @@ public class ArtifactTypeImpl implements ArtifactType {
this.parameterizedActions = new ArrayList<ParameterizedAction>();
this.openUrlActions = new ArrayList<CreateUrlAction>();
this.downloadContentActions = new ArrayList<DownloadContentAction>();
this.revision = 0l;
}
public ArtifactTypeImpl(String id, MimeType mimeType, List<ContentRepresentation> contentRepresentationList, ContentRepresentation defaultContentRepresentation,
Map<String, ContentProvider> contentProviderMap, List<ParameterizedAction> parameterizedActions, List<CreateUrlAction> openUrlActions,
List<DownloadContentAction> downloadContentActions) {
List<DownloadContentAction> downloadContentActions, Long revision) {
this.id = id;
this.mimeType = mimeType;
this.contentRepresentationList = contentRepresentationList;
......@@ -88,6 +91,7 @@ public class ArtifactTypeImpl implements ArtifactType {
this.parameterizedActions = parameterizedActions;
this.openUrlActions = openUrlActions;
this.downloadContentActions = downloadContentActions;
this.revision = revision;
}
public String getId() {
......@@ -278,6 +282,10 @@ public class ArtifactTypeImpl implements ArtifactType {
throw new RepositoryException("Action '" + id + "' not found, cannot be executed. Existing actions are: " + actionNames.toString());
}
public Long getRevision() {
return this.revision;
}
public void setMimeType(MimeType mimeType) {
this.mimeType = mimeType;
}
......@@ -318,4 +326,8 @@ public class ArtifactTypeImpl implements ArtifactType {
return this.getClass().getSimpleName() + "[" + id + "]";
}
public void setRevision(Long revision) {
this.revision = revision;
}
}
package org.activiti.cycle.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.activiti.cycle.ArtifactType;
import org.activiti.cycle.Content;
import org.activiti.cycle.CycleService;
import org.activiti.cycle.CycleTag;
import org.activiti.cycle.RepositoryArtifact;
import org.activiti.cycle.RepositoryArtifactLink;
import org.activiti.cycle.RepositoryConnector;
import org.activiti.cycle.RepositoryException;
import org.activiti.cycle.RepositoryFolder;
import org.activiti.cycle.RepositoryNode;
import org.activiti.cycle.RepositoryNodeCollection;
import org.activiti.cycle.RepositoryNodeNotFoundException;
import org.activiti.cycle.impl.conf.ConfigurationContainer;
import org.activiti.cycle.impl.connector.demo.DemoConnectorConfiguration;
import org.activiti.cycle.impl.connector.fs.FileSystemConnectorConfiguration;
import org.activiti.cycle.impl.connector.signavio.SignavioConnectorConfiguration;
import org.activiti.cycle.impl.db.CycleConfigurationService;
import org.activiti.cycle.impl.db.CycleLinkService;
import org.activiti.cycle.impl.db.entity.CycleLink;
import org.activiti.cycle.impl.db.impl.CycleConfigurationServiceImpl;
import org.activiti.cycle.impl.db.impl.CycleLinkServiceImpl;
import org.activiti.cycle.impl.plugin.PluginFinder;
/**
* Connector to represent customized view for a user of cycle to hide all the
* internal configuration and {@link RepositoryConnector} stuff from the client
* (e.g. the webapp)
*
* @author bernd.ruecker@camunda.com
* @author Nils Preusker (nils.preusker@camunda.com)
*/
public class CycleServiceImpl implements CycleService {
private CycleLinkService linkService;
private List<RepositoryConnector> repositoryConnectors;
/**
* TODO: Check if list roots can return an empty array
*/
private static final File fsBaseDir = File.listRoots()[0];
public CycleServiceImpl(List<RepositoryConnector> repositoryConnectors) {
PluginFinder.checkPluginInitialization();
this.linkService = new CycleLinkServiceImpl();
this.repositoryConnectors = repositoryConnectors;
}
// bootstrapping for cycle
/**
* Provides a static factory method for CycleService instances. Checks whether
* the HttpSession contains an instance for the specified user name and
* creates a new instance if none is found.
*
* @param currentUserId the user id of the currently logged in user
* @param session the HttpSession object from the currently logged in user
* @return the CycleService instance for the currently logged in user
*/
public static CycleService getCycleService(String currentUserId, HttpSession session) {
String key = currentUserId + "_cycleService";
CycleService cycleService = (CycleService) session.getAttribute(key);
if (cycleService == null) {
PluginFinder.registerServletContext(session.getServletContext());
ConfigurationContainer configuration = loadUserConfiguration(currentUserId);
cycleService = new CycleServiceImpl(configuration.getConnectorList());
// TODO: Correct user / password handling!!!!
cycleService.login(currentUserId, currentUserId);
session.setAttribute(key, cycleService);
}
return cycleService;
}
/**
* Loads the configuration for this user. If no configuration exists, a demo
* configuration is created and stored in the database.
*
* @param currentUserId the id of the currently logged in user
*/
private static ConfigurationContainer loadUserConfiguration(String currentUserId) {
PluginFinder.checkPluginInitialization();
CycleConfigurationService configService = new CycleConfigurationServiceImpl(null);
ConfigurationContainer configuration;
try {
configuration = configService.getConfiguration(currentUserId);
} catch (RepositoryException e) {
configuration = createDefaultDemoConfiguration(currentUserId);
configService.saveConfiguration(configuration);
}
return configuration;
}
private static ConfigurationContainer createDefaultDemoConfiguration(String currentUserId) {
ConfigurationContainer configuration = new ConfigurationContainer(currentUserId);
configuration.addRepositoryConnectorConfiguration(new DemoConnectorConfiguration("demo"));
configuration.addRepositoryConnectorConfiguration(new SignavioConnectorConfiguration("signavio", "http://localhost:8080/activiti-modeler/"));
configuration.addRepositoryConnectorConfiguration(new FileSystemConnectorConfiguration("files", fsBaseDir));
return configuration;
}
// implementation of CycleService methods
/**
* login into all repositories configured (if no username and password was
* provided by the configuration already).
*
* TODO: Make more sophisticated. Questions: What to do if one repo cannot
* login?
*/
public boolean login(String username, String password) {
for (RepositoryConnector connector : this.repositoryConnectors) {
// TODO: What if one repository failes? Try loading the other ones and
// remove the failing from the repo list? Example: Online SIgnavio when
// offile
connector.login(username, password);
}
return true;
}
/**
* commit pending changes in all repository connectors configured
*/
public void commitPendingChanges(String connectorId, String comment) {
for (RepositoryConnector connector : this.repositoryConnectors) {
connector.commitPendingChanges(comment);
}
}
public RepositoryNodeCollection getChildren(String connectorId, String nodeId) {
// special handling for root
if ("/".equals(connectorId)) {
return getRepoRootFolders();
}
RepositoryConnector connector = getRepositoryConnector(connectorId);
return connector.getChildren(nodeId);
}
public RepositoryNodeCollection getRepoRootFolders() {
ArrayList<RepositoryNode> nodes = new ArrayList<RepositoryNode>();
for (RepositoryConnector connector : this.repositoryConnectors) {
RepositoryFolderImpl folder = new RepositoryFolderImpl(connector.getConfiguration().getId(), "/");
folder.getMetadata().setName(connector.getConfiguration().getName());
folder.getMetadata().setParentFolderId("/");
nodes.add(folder);
}
return new RepositoryNodeCollectionImpl(nodes);
}
public RepositoryArtifact getRepositoryArtifact(String connectorId, String artifactId) {
RepositoryConnector connector = getRepositoryConnector(connectorId);
RepositoryArtifact repositoryArtifact = connector.getRepositoryArtifact(artifactId);
return repositoryArtifact;
}
public Content getRepositoryArtifactPreview(String connectorId, String artifactId) throws RepositoryNodeNotFoundException {
RepositoryConnector connector = getRepositoryConnector(connectorId);
return connector.getRepositoryArtifactPreview(artifactId);
}
public RepositoryFolder getRepositoryFolder(String connectorId, String artifactId) {
RepositoryConnector connector = getRepositoryConnector(connectorId);
RepositoryFolder repositoryFolder = connector.getRepositoryFolder(artifactId);
return repositoryFolder;
}
public RepositoryArtifact createArtifact(String connectorId, String containingFolderId, String artifactName, String artifactType, Content artifactContent)
throws RepositoryNodeNotFoundException {
return getRepositoryConnector(connectorId).createArtifact(containingFolderId, artifactName, artifactType, artifactContent);
}
public RepositoryArtifact createArtifactFromContentRepresentation(String connectorId, String containingFolderId, String artifactName, String artifactType,
String contentRepresentationName, Content artifactContent) throws RepositoryNodeNotFoundException {
return getRepositoryConnector(connectorId).createArtifactFromContentRepresentation(containingFolderId, artifactName, artifactType,
contentRepresentationName, artifactContent);
}
public void updateContent(String connectorId, String artifactId, Content content) throws RepositoryNodeNotFoundException {
RepositoryConnector connector = getRepositoryConnector(connectorId);
connector.updateContent(artifactId, content);
}
public void updateContent(String connectorId, String artifactId, String contentRepresentationName, Content content) throws RepositoryNodeNotFoundException {
RepositoryConnector connector = getRepositoryConnector(artifactId);
connector.updateContent(artifactId, contentRepresentationName, content);
}
public RepositoryFolder createFolder(String connectorId, String parentFolderId, String name) throws RepositoryNodeNotFoundException {
return getRepositoryConnector(connectorId).createFolder(parentFolderId, name);
}
public void deleteArtifact(String connectorId, String artifactId) {
getRepositoryConnector(connectorId).deleteArtifact(artifactId);
}
public void deleteFolder(String connectorId, String folderId) {
getRepositoryConnector(connectorId).deleteFolder(folderId);
}
public Content getContent(String connectorId, String artifactId, String representationName) throws RepositoryNodeNotFoundException {
return getRepositoryConnector(connectorId).getContent(artifactId, representationName);
}
public void executeParameterizedAction(String connectorId, String artifactId, String actionId, Map<String, Object> parameters) throws Exception {
RepositoryConnector connector = getRepositoryConnector(connectorId);
// TODO: (Nils Preusker, 20.10.2010), find a better way to solve this!
for(String key : parameters.keySet()) {
if(key.equals("targetConnectorId")) {
RepositoryConnector targetConnector = getRepositoryConnector((String)parameters.get(key));
parameters.put(key, targetConnector);
}
}
connector.executeParameterizedAction(artifactId, actionId, parameters);
}
public List<ArtifactType> getSupportedArtifactTypes(String connectorId, String folderId) {
if (folderId == null || folderId.length() <= 1) {
// "virtual" root folder doesn't support any artifact types
return new ArrayList<ArtifactType>();
}
return getRepositoryConnector(connectorId).getSupportedArtifactTypes(folderId);
}
// RepositoryArtifactLink specific methods
public void addArtifactLink(RepositoryArtifactLink repositoryArtifactLink) {
CycleLink cycleLink = new CycleLink();
cycleLink.setId(repositoryArtifactLink.getId());
// set source artifact attributes
cycleLink.setSourceConnectorId(repositoryArtifactLink.getSourceArtifact().getConnectorId());
cycleLink.setSourceArtifactId(repositoryArtifactLink.getSourceArtifact().getOriginalNodeId());
cycleLink.setSourceElementId(repositoryArtifactLink.getSourceElementId());
cycleLink.setSourceElementName(repositoryArtifactLink.getSourceElementName());
cycleLink.setSourceRevision(repositoryArtifactLink.getSourceArtifact().getArtifactType().getRevision());
// set target artifact attributes
cycleLink.setTargetConnectorId(repositoryArtifactLink.getTargetArtifact().getConnectorId());
cycleLink.setTargetArtifactId(repositoryArtifactLink.getTargetArtifact().getOriginalNodeId());
cycleLink.setTargetElementId(repositoryArtifactLink.getTargetElementId());
cycleLink.setTargetElementName(repositoryArtifactLink.getTargetElementName());
cycleLink.setTargetRevision(repositoryArtifactLink.getTargetArtifact().getArtifactType().getRevision());
// TODO: decide whether we will use these attributes or get rid of them.
// Just setting defaults to prevent null values for now.
cycleLink.setDescription("");
cycleLink.setLinkedBothWays(false);
cycleLink.setLinkType("");
this.linkService.updateCycleLink(cycleLink);
}
public List<RepositoryArtifactLink> getArtifactLinks(String sourceConnectorId, String sourceArtifactId) {
List<RepositoryArtifactLink> artifactLinks = new ArrayList<RepositoryArtifactLink>();
// TODO: query should be updated to use connectorId and artifactId
List<CycleLink> linkResultList = this.linkService.getCycleLinks(sourceArtifactId);
if (linkResultList != null && !linkResultList.isEmpty()) {
for (CycleLink entity : linkResultList) {
artifactLinks.add(createLinkDtoFromLinkEntity(entity));
}
}
return artifactLinks;
}
public void deleteLink(long linkId) {
// TODO: implement
throw new RuntimeException("Not implemented yet");
}
public List<RepositoryArtifactLink> getArtifactLinks(String sourceArtifactId) {
// TODO: implement
throw new RuntimeException("Not implemented yet");
}
public List<RepositoryArtifactLink> getArtifactLinks(String sourceArtifactId, Long sourceRevision) {
// TODO: implement
throw new RuntimeException("Not implemented yet");
}
public List<RepositoryArtifactLink> getArtifactLinks(String sourceArtifactId, Long sourceRevision, String type) {
// TODO: implement
throw new RuntimeException("Not implemented yet");
}
// Tag specific methods
public void addTag(String nodeId, String tagName) {
// TODO: implement
throw new RuntimeException("Not implemented yet");
}
public void addTag(String nodeId, String tagName, String alias) {
// TODO: implement
throw new RuntimeException("Not implemented yet");
}
public void deleteTag(String nodeId, String tagName) {
// TODO: implement
throw new RuntimeException("Not implemented yet");
}
public List<CycleTag> getAllTags() {
// TODO: implement
throw new RuntimeException("Not implemented yet");
}
public List<CycleTag> getAllTagsIgnoreAlias() {
// TODO: implement
throw new RuntimeException("Not implemented yet");
}
public List<CycleTag> getTags(String nodeId) throws RepositoryNodeNotFoundException {
// TODO: implement
throw new RuntimeException("Not implemented yet");
}
// Private convenience methods
private RepositoryArtifactLink createLinkDtoFromLinkEntity(CycleLink entity) {
RepositoryArtifactLink repositoryArtifactLink = new RepositoryArtifactLinkImpl();
repositoryArtifactLink.setId(entity.getId());
repositoryArtifactLink.setSourceElementId(entity.getSourceElementId());
repositoryArtifactLink.setSourceElementName(entity.getSourceElementName());
repositoryArtifactLink.setTargetElementId(entity.getTargetElementId());
repositoryArtifactLink.setTargetElementName(entity.getTargetElementName());
RepositoryArtifact sourceArtifact = null;
RepositoryArtifact targetArtifact = null;
for (RepositoryConnector conn : this.repositoryConnectors) {
if (conn.getConfiguration().getId().equals(entity.getSourceConnectorId())) {
sourceArtifact = conn.getRepositoryArtifact(entity.getSourceArtifactId());
}
if (conn.getConfiguration().getId().equals(entity.getTargetConnectorId())) {
targetArtifact = conn.getRepositoryArtifact(entity.getTargetArtifactId());
}
}
// TODO: think about exception handling :)
if (sourceArtifact == null) {
throw new RuntimeException("Source-artifact with id '" + entity.getSourceArtifactId() + "' not found for artifact-link with id '" + entity.getId() + "'");
}
if (targetArtifact == null) {
throw new RuntimeException("Target-artifact with id '" + entity.getSourceArtifactId() + "' not found for artifact-link with id '" + entity.getId() + "'");
}
repositoryArtifactLink.setSourceArtifact(sourceArtifact);
repositoryArtifactLink.setTargetArtifact(targetArtifact);
return repositoryArtifactLink;
}
private RepositoryConnector getRepositoryConnector(String connectorId) {
for (RepositoryConnector connector : this.repositoryConnectors) {
if (connector.getConfiguration().getId().equals(connectorId)) {
return connector;
}
}
throw new RepositoryException("Couldn't find Repository Connector with id '" + connectorId + "'");
}
}
......@@ -10,113 +10,85 @@ import org.activiti.cycle.RepositoryArtifactLink;
public class RepositoryArtifactLinkImpl implements RepositoryArtifactLink {
private String id;
private RepositoryArtifact sourceArtifactId;
private RepositoryArtifact targetArtifactId;
private RepositoryArtifact sourceArtifact;
private String sourceElementId;
private String targetElementId;
private String sourceElementName;
private RepositoryArtifact targetArtifact;
private String targetElementId;
private String targetElementName;
private Long sourceRevision;
private Long targetRevision;
private String description;
private String linkType;
private Boolean isLinkedBothWays;
public String getId() {
return id;
public RepositoryArtifactLinkImpl() {
}
public void setId(String id) {
public RepositoryArtifactLinkImpl(String id, RepositoryArtifact sourceArtifact, String sourceElementId, String sourceElementName,
RepositoryArtifact targetArtifact, String targetElementId, String targetElementName) {
super();
this.id = id;
this.sourceArtifact = sourceArtifact;
this.sourceElementId = sourceElementId;
this.sourceElementName = sourceElementName;
this.targetArtifact = targetArtifact;
this.targetElementId = targetElementId;
this.targetElementName = targetElementName;
}
public RepositoryArtifact getSourceArtifactId() {
return sourceArtifactId;
}
public void setSourceArtifactId(RepositoryArtifact sourceArtifactId) {
this.sourceArtifactId = sourceArtifactId;
}
public RepositoryArtifact getTargetArtifactId() {
return targetArtifactId;
public String getId() {
return id;
}
public void setTargetArtifactId(RepositoryArtifact targetArtifactId) {
this.targetArtifactId = targetArtifactId;
public RepositoryArtifact getSourceArtifact() {
return sourceArtifact;
}
public String getSourceElementId() {
return sourceElementId;
}
public void setSourceElementId(String sourceElementId) {
this.sourceElementId = sourceElementId;
}
public String getTargetElementId() {
return targetElementId;
}
public void setTargetElementId(String targetElementId) {
this.targetElementId = targetElementId;
}
public String getSourceElementName() {
return sourceElementName;
}
public void setSourceElementName(String sourceElementName) {
this.sourceElementName = sourceElementName;
public RepositoryArtifact getTargetArtifact() {
return targetArtifact;
}
public String getTargetElementId() {
return targetElementId;
}
public String getTargetElementName() {
return targetElementName;
}
public void setTargetElementName(String targetElementName) {
this.targetElementName = targetElementName;
}
public Long getSourceRevision() {
return sourceRevision;
}
public void setSourceRevision(Long sourceRevision) {
this.sourceRevision = sourceRevision;
}
public Long getTargetRevision() {
return targetRevision;
}
public void setTargetRevision(Long targetRevision) {
this.targetRevision = targetRevision;
public void setId(String id) {
this.id = id;
}
public String getDescription() {
return description;
public void setSourceArtifact(RepositoryArtifact sourceArtifact) {
this.sourceArtifact = sourceArtifact;
}
public void setDescription(String description) {
this.description = description;
public void setSourceElementId(String sourceElementId) {
this.sourceElementId = sourceElementId;
}
public String getLinkType() {
return linkType;
public void setSourceElementName(String sourceElementName) {
this.sourceElementName = sourceElementName;
}
public void setLinkType(String linkType) {
this.linkType = linkType;
public void setTargetArtifact(RepositoryArtifact targetArtifact) {
this.targetArtifact = targetArtifact;
}
public Boolean isLinkedBothWays() {
return isLinkedBothWays;
public void setTargetElementId(String targetElementId) {
this.targetElementId = targetElementId;
}
public void setLinkedBothWays(Boolean isLinkedBothWays) {
this.isLinkedBothWays = isLinkedBothWays;
public void setTargetElementName(String targetElementName) {
this.targetElementName = targetElementName;
}
}
......@@ -26,8 +26,8 @@ public class CopyArtifactAction extends ParameterizedHtmlFormTemplateAction {
int count = (Integer) getParameter(parameters, "copyCount", true, null, Integer.class);
String targetName = (String) getParameter(parameters, "targetName", true, null, String.class);
RepositoryConnector targetFolderConnector = (RepositoryConnector) getParameter(parameters, "targetFolderConnector", true, null, RepositoryConnector.class);
String targetFolder = (String) getParameter(parameters, "targetFolder", true, null, String.class);
RepositoryConnector targetFolderConnector = (RepositoryConnector) getParameter(parameters, "targetConnectorId", true, null, RepositoryConnector.class);
String targetFolderId = (String) getParameter(parameters, "targetFolderId", true, null, String.class);
// retrieve the platform independent file separator
// String fileSeperator = System.getProperty("file.separator");\
......@@ -38,10 +38,10 @@ public class CopyArtifactAction extends ParameterizedHtmlFormTemplateAction {
// targetName;
if (count == 1) {
copyArtifact(connector, targetFolderConnector, artifact, targetFolder, targetName);
copyArtifact(connector, targetFolderConnector, artifact, targetFolderId, targetName);
} else {
for (int i = 0; i < count; i++) {
copyArtifact(connector, targetFolderConnector, artifact, targetFolder, targetName + i);
copyArtifact(connector, targetFolderConnector, artifact, targetFolderId, targetName + i);
}
}
......
package org.activiti.cycle.impl.connector.view;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.activiti.cycle.ArtifactType;
import org.activiti.cycle.Content;
import org.activiti.cycle.RepositoryArtifact;
import org.activiti.cycle.RepositoryConnector;
import org.activiti.cycle.RepositoryException;
import org.activiti.cycle.RepositoryFolder;
import org.activiti.cycle.RepositoryNode;
import org.activiti.cycle.RepositoryNodeCollection;
import org.activiti.cycle.RepositoryNodeNotFoundException;
import org.activiti.cycle.impl.RepositoryFolderImpl;
import org.activiti.cycle.impl.RepositoryNodeCollectionImpl;
import org.activiti.cycle.impl.RepositoryNodeImpl;
/**
* Connector to represent customized view for a user of cycle to hide all the
* internal configuration and {@link RepositoryConnector} stuff from the client
* (e.g. the webapp)
*
* @author bernd.ruecker@camunda.com
*/
public class RootConnector implements RepositoryConnector {
public static final String ROOT_CONNECTOR_ID = "ROOT-CONNECTOR";
private List<RepositoryConnector> repositoryConnectors;
private RootConnectorConfiguration configuration;
public RootConnector(RootConnectorConfiguration customizedViewConfiguration) {
configuration = customizedViewConfiguration;
}
public RootConnectorConfiguration getConfiguration() {
return configuration;
}
/**
* Get a map with all {@link RepositoryConnector}s created lazily and the name
* of the connector as key for the map.
*/
private List<RepositoryConnector> getRepositoryConnectors() {
if (repositoryConnectors == null) {
repositoryConnectors = getConfiguration().getConfigurationContainer().getConnectorList();
}
return repositoryConnectors;
}
private RepositoryConnector getRepositoryConnector(String connectorId) {
for (RepositoryConnector connector : getRepositoryConnectors()) {
if (connector.getConfiguration().getId().equals(connectorId)) {
return connector;
}
}
throw new RepositoryException("Couldn't find Repository Connector with id '" + connectorId + "'");
}
/**
* login into all repositories configured (if no username and password was
* provided by the configuration already).
*
* TODO: Make more sophisticated. Questions: What to do if one repo cannot
* login?
*/
public boolean login(String username, String password) {
for (RepositoryConnector connector : getRepositoryConnectors()) {
// TODO: What if one repository failes? Try loading the other ones and
// remove the failing from the repo list? Example: Online SIgnavio when
// offile
connector.login(username, password);
}
return true;
}
/**
* commit pending changes in all repository connectors configured
*/
public void commitPendingChanges(String comment) {
for (RepositoryConnector connector : getRepositoryConnectors()) {
connector.commitPendingChanges(comment);
}
}
/**
* add repository name in config to URL
*/
private void adjust(RepositoryConnector connector, RepositoryNode node) {
RepositoryNodeImpl repositoryNode = ((RepositoryNodeImpl) node);
repositoryNode.addNewRootToCurrentPath(connector.getConfiguration().getId());
}
protected RepositoryConnector getConnectorFromUrl(String parentCurrentPath) {
RepositoryConnector connector = null;
int index = parentCurrentPath.indexOf("/");
if (index == -1) {
// demo connector itself
connector = getRepositoryConnector(parentCurrentPath);
} else if (index == 0) {
connector = getConnectorFromUrl(parentCurrentPath.substring(1));
} else {
String repositoryName = parentCurrentPath.substring(0, index);
connector = getRepositoryConnector(repositoryName);
}
if (connector == null) {
throw new RepositoryException("Couldn't find any RepositoryConnector for url '" + parentCurrentPath + "'");
} else {
return connector;
}
}
protected String getRepositoryPartOfUrl(String url) {
int index = url.indexOf("/");
if (index == -1) {
// demo connector itself -> root folder is shown
return "/";
} else if (index == 0) {
return getRepositoryPartOfUrl(url.substring(1));
} else {
return url.substring(index);
}
}
public RepositoryNodeCollection getChildren(String parentCurrentPath) {
// special handling for root
if ("/".equals(parentCurrentPath)) {
return getRepoRootFolders();
}
// First identify correct repo and truncate path to local part of
// connector
RepositoryConnector connector = getConnectorFromUrl(parentCurrentPath);
parentCurrentPath = getRepositoryPartOfUrl(parentCurrentPath);
// now make the query
RepositoryNodeCollection children = connector.getChildren(parentCurrentPath);
// and adjust the result to include repo name
for (RepositoryNode repositoryNode : children.asList()) {
adjust(connector, repositoryNode);
}
return children;
}
public RepositoryNodeCollection getRepoRootFolders() {
ArrayList<RepositoryNode> nodes = new ArrayList<RepositoryNode>();
for (RepositoryConnector connector : getRepositoryConnectors()) {
RepositoryFolderImpl folder = new RepositoryFolderImpl(ROOT_CONNECTOR_ID, connector.getConfiguration().getId());
folder.getMetadata().setName(connector.getConfiguration().getName());
folder.getMetadata().setParentFolderId("/");
nodes.add(folder);
}
return new RepositoryNodeCollectionImpl(nodes);
}
public RepositoryArtifact getRepositoryArtifact(String id) {
RepositoryConnector connector = getConnectorFromUrl(id);
RepositoryArtifact repositoryArtifact = connector.getRepositoryArtifact(
getRepositoryPartOfUrl(id));
adjust(connector, repositoryArtifact);
return repositoryArtifact;
}
public Content getRepositoryArtifactPreview(String artifactId) throws RepositoryNodeNotFoundException {
RepositoryConnector connector = getConnectorFromUrl(artifactId);
return connector.getRepositoryArtifactPreview(getRepositoryPartOfUrl(artifactId));
}
public RepositoryFolder getRepositoryFolder(String id) {
RepositoryConnector connector = getConnectorFromUrl(id);
RepositoryFolder repositoryFolder = connector.getRepositoryFolder(getRepositoryPartOfUrl(id));
adjust(connector, repositoryFolder);
return repositoryFolder;
}
public RepositoryArtifact createArtifact(String containingFolderId, String artifactName, String artifactType, Content artifactContent)
throws RepositoryNodeNotFoundException {
return getConnectorFromUrl(containingFolderId).createArtifact(getRepositoryPartOfUrl(containingFolderId), artifactName, artifactType, artifactContent);
}
public RepositoryArtifact createArtifactFromContentRepresentation(String containingFolderId, String artifactName, String artifactType,
String contentRepresentationName, Content artifactContent) throws RepositoryNodeNotFoundException {
return getConnectorFromUrl(containingFolderId).createArtifactFromContentRepresentation(getRepositoryPartOfUrl(containingFolderId), artifactName,
artifactType, contentRepresentationName, artifactContent);
}
public void updateContent(String artifactId, Content content) throws RepositoryNodeNotFoundException {
RepositoryConnector connector = getConnectorFromUrl(artifactId);
connector.updateContent(getRepositoryPartOfUrl(artifactId), content);
}
public void updateContent(String artifactId, String contentRepresentationName, Content content) throws RepositoryNodeNotFoundException {
RepositoryConnector connector = getConnectorFromUrl(artifactId);
connector.updateContent(getRepositoryPartOfUrl(artifactId), contentRepresentationName, content);
}
public RepositoryFolder createFolder(String parentFolderId, String name) throws RepositoryNodeNotFoundException {
return getConnectorFromUrl(parentFolderId).createFolder(getRepositoryPartOfUrl(parentFolderId), name);
}
public void deleteArtifact(String artifactUrl) {
getConnectorFromUrl(artifactUrl).deleteArtifact(getRepositoryPartOfUrl(artifactUrl));
}
public void deleteFolder(String subFolderUrl) {
getConnectorFromUrl(subFolderUrl).deleteFolder(getRepositoryPartOfUrl(subFolderUrl));
}
public Content getContent(String artifactId, String representationName) throws RepositoryNodeNotFoundException {
return getConnectorFromUrl(artifactId).getContent(getRepositoryPartOfUrl(artifactId), representationName);
}
public void executeParameterizedAction(String artifactId, String actionId, Map<String, Object> parameters) throws Exception {
RepositoryConnector connector = getConnectorFromUrl(artifactId);
String repoPartOfId = getRepositoryPartOfUrl(artifactId);
for (Entry<String, Object> parameter : new HashSet<Entry<String, Object>>(parameters.entrySet())) {
if (parameter.getKey().equals("treeTarget")) {
String targetFolderId = (String) parameter.getValue();
parameters.put("targetFolderConnector", getConnectorFromUrl(targetFolderId));
parameters.put("targetFolder", getRepositoryPartOfUrl(targetFolderId));
}
}
connector.executeParameterizedAction(repoPartOfId, actionId, parameters);
}
public List<ArtifactType> getSupportedArtifactTypes(String folderId) {
if (folderId == null || folderId.length() <= 1) {
// "virtual" root folder doesn't support any artifact types
return new ArrayList<ArtifactType>();
}
return getConnectorFromUrl(folderId).getSupportedArtifactTypes(getRepositoryPartOfUrl(folderId));
}
}
......@@ -4,6 +4,7 @@ import org.activiti.cycle.RepositoryConnector;
import org.activiti.cycle.impl.conf.ConfigurationContainer;
import org.activiti.cycle.impl.conf.RepositoryConnectorConfiguration;
@Deprecated
public class RootConnectorConfiguration extends RepositoryConnectorConfiguration {
private ConfigurationContainer configuration;
......@@ -25,9 +26,9 @@ public class RootConnectorConfiguration extends RepositoryConnectorConfiguration
@Override
public RepositoryConnector createConnector() {
return new RootConnector(this);
return null;
}
public ConfigurationContainer getConfigurationContainer() {
return configuration;
}
......
package org.activiti.cycle.impl.db;
import org.activiti.cycle.impl.conf.ConfigurationContainer;
/**
* Service to load and store repository connector configurations.
*
* @author Nils Preusker (nils.preusker@camunda.com)
*/
public interface CycleConfigurationService {
/**
* Retrieves the cycle-configuration with the specified name from the
* database.
*
* @param name the name of the requested cycle configuration
*/
public ConfigurationContainer getConfiguration(String name);
/**
* Persists the provided cycle configuration.
*
* @param container the cycle configuration to persist
*/
public void saveConfiguration(ConfigurationContainer container);
// public RepositoryConnectorConfiguration getConfiguration();
}
package org.activiti.cycle.impl.db;
import java.util.List;
import org.activiti.cycle.impl.db.entity.CycleLink;
public interface CycleLinkService {
public List<CycleLink> getCycleLinks(String sourceArtifactId);
public CycleLink findCycleLinkById(String id);
public void updateCycleLink(CycleLink cycleLink);
}
package org.activiti.cycle.impl.db;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.activiti.cycle.Cycle;
import org.activiti.cycle.CycleConfig;
import org.activiti.cycle.CycleLink;
import org.activiti.cycle.CycleService;
import org.activiti.cycle.RepositoryArtifact;
import org.activiti.cycle.RepositoryArtifactLink;
import org.activiti.cycle.RepositoryConnector;
import org.activiti.cycle.RepositoryException;
import org.activiti.cycle.impl.RepositoryArtifactLinkImpl;
import org.activiti.cycle.impl.conf.ConfigurationContainer;
import org.activiti.cycle.impl.conf.CycleDbSqlSessionFactory;
import org.activiti.cycle.impl.connector.demo.DemoConnectorConfiguration;
import org.activiti.cycle.impl.connector.fs.FileSystemConnectorConfiguration;
import org.activiti.cycle.impl.connector.signavio.SignavioConnectorConfiguration;
import org.activiti.cycle.impl.connector.view.RootConnectorConfiguration;
import org.activiti.cycle.impl.plugin.PluginFinder;
import org.activiti.engine.DbSchemaStrategy;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.impl.ProcessEngineImpl;
import org.activiti.engine.impl.cfg.ProcessEngineConfiguration;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import com.thoughtworks.xstream.XStream;
/**
* First implementation of {@link CycleService} using the database in the
* background to write stuff as XML in the database.
*/
public class CycleServiceDbXStreamImpl extends DummyBaseCycleService implements CycleService {
private XStream xStream = new XStream();
private String processEngineName = null;
private static Long DEFAULT_REVISION = new Long(0);
private static String DEFAULT_ENGINE = "DEFAULT_PROCESS_ENGINE";
private static HashMap<String, CycleDbSqlSessionFactory> dbFactories = new HashMap<String, CycleDbSqlSessionFactory>();
/**
* TODO: Check if list roots can return an empty array
*/
private static final File fsBaseDir = File.listRoots()[0];
public CycleServiceDbXStreamImpl(String processEngineName) {
if (processEngineName == null) {
this.processEngineName = DEFAULT_ENGINE;
} else {
this.processEngineName = processEngineName;
}
}
public CycleServiceDbXStreamImpl() {
this(DEFAULT_ENGINE);
}
private SqlSessionFactory getSessionFactory() {
if (dbFactories.get(processEngineName) == null) {
synchronized (dbFactories) {
// lazy initialization, only done once per proces engine!
if (dbFactories.get(processEngineName) == null) {
CycleDbSqlSessionFactory factory = new CycleDbSqlSessionFactory();
factory.configurationCompleted(getProcessEngineConfiguration());
performDbSchemaCreation(factory, getProcessEngineConfiguration());
dbFactories.put(processEngineName, factory);
}
}
}
return dbFactories.get(processEngineName).getSqlSessionFactory();
}
public XStream getXStream() {
return xStream;
}
//-- copied from SessionUtil class --
public static RepositoryConnector getRepositoryConnector(String currentUserId, HttpSession session) {
String key = currentUserId + "_connector";
RepositoryConnector connector = (RepositoryConnector) session.getAttribute(key);
if (connector == null) {
PluginFinder.registerServletContext(session.getServletContext());
ConfigurationContainer configuration = loadUserConfiguration(currentUserId);
connector = new RootConnectorConfiguration(configuration).createConnector();
// TODO: Correct user / password handling
connector.login(currentUserId, currentUserId);
session.setAttribute(key, connector);
}
return connector;
}
/**
* loads the configuration for this user. If no configuration exists, a demo
* config is created and save to file (this xml can be easily modified later
* on to play around with it).
*
* This is a temporary solution until real persistence for configs is in place
*
* TODO: This should be rewritten as soon as we have real persistence and
* stuff
*/
public static ConfigurationContainer loadUserConfiguration(String currentUserId) {
CycleService cycleConfigurationService = Cycle.getCycleService(); // new CycleServiceDbXStreamImpl(configBaseDir);
ConfigurationContainer configuration;
try{
configuration = cycleConfigurationService.getConfiguration(currentUserId);
} catch(RepositoryException e) {
configuration = createDefaultDemoConfiguration(currentUserId);
cycleConfigurationService.saveConfiguration(configuration);
}
return configuration;
}
public static ConfigurationContainer createDefaultDemoConfiguration(String currentUserId) {
ConfigurationContainer configuration = new ConfigurationContainer(currentUserId);
configuration.addRepositoryConnectorConfiguration(new DemoConnectorConfiguration("demo"));
configuration.addRepositoryConnectorConfiguration(new SignavioConnectorConfiguration("signavio", "http://localhost:8080/activiti-modeler/"));
configuration.addRepositoryConnectorConfiguration(new FileSystemConnectorConfiguration("files", fsBaseDir));
return configuration;
}
//-- end of copy --
public void saveConfiguration(ConfigurationContainer container) {
createAndInsert(container, container.getName());
}
public ConfigurationContainer getConfiguration(String name) {
CycleConfig cycleConfig = selectById(name);
Object configXML = getXStream().fromXML(cycleConfig.getConfigXML());
return (ConfigurationContainer) configXML;
}
/**
*
* Should be the parameter connectorId and artifactId or is the sourceArtifactId parameter composed of
* connectorId and artifactId??
* If yes, how can I split the sourceArtifactId in connectorId and artifactId? Only with String-Operation?
*/
@Override
public void addArtifactLink(String sourceArtifactId, String targetArtifactId) {
SqlSessionFactory sqlMapper = getSessionFactory();
CycleLink link = new CycleLink();
// link.setSourceConnectorId(sourceConnectorId);
// link.setTargetConnectorId(targetConnectorId);
link.setSourceArtifactId(sourceArtifactId);
link.setTargetArtifactId(targetArtifactId);
SqlSession session = sqlMapper.openSession();
session.insert("org.activiti.cycle.CycleLink.insertCycleLink", link);
session.commit();
}
/**
* Should be the parameter connectorId and artifactId or is the sourceArtifactId parameter composed of
* connectorId and artifactId??
* If yes, how can I split the sourceArtifactId in connectorId and artifactId? Only with String-Operation?
*/
@Override
public List<RepositoryArtifactLink> getArtifactLinks(String sourceArtifactId) {
List<RepositoryArtifactLink> repositoryArtifactLinkList = new ArrayList<RepositoryArtifactLink>();
SqlSessionFactory sqlMapper = getSessionFactory();
SqlSession session = sqlMapper.openSession();
try {
List<CycleLink> linkResultList = session.selectList(
"org.activiti.cycle.CycleLink.selectArtifactLinkForSourceArtifact", sourceArtifactId);
if (linkResultList != null && !linkResultList.isEmpty()) {
for (CycleLink cycleLink : linkResultList) {
RepositoryArtifactLink repositoryArtifactLink = new RepositoryArtifactLinkImpl();
repositoryArtifactLink.setId(cycleLink.getId());
repositoryArtifactLink.setSourceElementId(cycleLink.getSourceElementId());
repositoryArtifactLink.setTargetElementId(cycleLink.getTargetElementId());
repositoryArtifactLink.setSourceElementName(cycleLink.getSourceElementName());
repositoryArtifactLink.setTargetElementName(cycleLink.getTargetElementName());
repositoryArtifactLink.setSourceRevision(cycleLink.getSourceRevision());
repositoryArtifactLink.setTargetRevision(cycleLink.getTargetRevision());
repositoryArtifactLink.setDescription(cycleLink.getDescription());
repositoryArtifactLink.setLinkType(cycleLink.getLinkType());
repositoryArtifactLink.setLinkedBothWays(cycleLink.isLinkedBothWays());
//TODO: How can I get the connector to create a new RepositoryArtifact?
// RepositoryArtifact sourceRepositoryArtifact = new RepositoryArtifactLinkImpl(cycleLink.getSourceConnectorId(), cycleLink.getSourceArtifactId(), );
// RepositoryArtifact targetRepositoryArtifact = new RepositoryArtifactLinkImpl(cycleLink.getTargetConnectorId(), cycleLink.getTargetArtifactId(), );
// repositoryArtifactLink.setSourceArtifactId(sourceRepositoryArtifact);
// repositoryArtifactLink.setTargetArtifactId(targetRepositoryArtifact);
repositoryArtifactLinkList.add(repositoryArtifactLink);
}
}
return repositoryArtifactLinkList;
} finally {
session.close();
}
}
// @Override
// public void addArtifactLink(String sourceArtifactId, String targetArtifactId) {
// Artifact cycleLink = new Artifact();
// CycleLink cycleLinkTarget = new CycleLink();
// cycleLinkTarget.setTargetArtifactId(targetArtifactId);
//
// cycleLink.setSourceArtifactId(sourceArtifactId);
// cycleLinkTarget.setCycleLink(cycleLink);
//
// SqlSessionFactory sqlMapper = getSessionFactory();
//
// SqlSession session = sqlMapper.openSession();
// try {
// session.insert("org.activiti.cycle.CycleLink.insertCycleLink", cycleLink);
// session.insert("org.activiti.cycle.CycleLinkTarget.insertCycleLinkTarget", cycleLinkTarget);
// session.commit();
// } finally {
// session.close();
// }
// }
//
// @Override
// public void addLink(Artifact link) {
// SqlSessionFactory sqlMapper = getSessionFactory();
//
// SqlSession session = sqlMapper.openSession();
// try {
// session.insert("org.activiti.cycle.CycleLink.insertCycleLink", link);
// session.commit();
// } finally {
// session.close();
// }
// }
//
// @Override
// public List<Artifact> getArtifactLinks(String sourceArtifactId) {
// SqlSessionFactory sqlMapper = getSessionFactory();
//
// SqlSession session = sqlMapper.openSession();
// try {
//
// List<Artifact> linkList = (List<Artifact>) session.selectList(
// "org.activiti.cycle.CycleLink.selectCycleLinkBySourceArtifactId", sourceArtifactId);
// Artifact link = linkList.get(0);
// return linkList;
// } finally {
// session.close();
// }
// }
//
// @Override
// public List<Artifact> getArtifactLinks(String sourceArtifactId, String type) {
// Artifact cycleLink = new Artifact();
// CycleLink cycleLinkTarget = new CycleLink();
// List<CycleLink> cycleLinkTargetList = new ArrayList<CycleLink>();
//
// cycleLinkTarget.setLinkType(type);
// cycleLinkTargetList.add(cycleLinkTarget);
//
// cycleLink.setSourceArtifactId(sourceArtifactId);
// cycleLink.setCycleLinkTarget(cycleLinkTargetList);
//
// SqlSessionFactory sqlMapper = getSessionFactory();
//
// SqlSession session = sqlMapper.openSession();
// try {
// return (List<Artifact>) session.selectList(
// "org.activiti.cycle.CycleLink.selectCycleLinkBySourceArtifactIdAndType", cycleLink);
//
// } finally {
// session.close();
// }
// }
//
// @Override
// public List<Artifact> getArtifactLinks(String sourceArtifactId, Long sourceRevision) {
// Artifact cycleLink = new Artifact();
// cycleLink.setSourceArtifactId(sourceArtifactId);
// cycleLink.setSourceRevision(sourceRevision);
//
// SqlSessionFactory sqlMapper = getSessionFactory();
//
// SqlSession session = sqlMapper.openSession();
// try {
// return (List<Artifact>) session.selectList(
// "org.activiti.cycle.CycleLink.selectCycleLinkBySourceArtifactIdAndSourceRevision", cycleLink);
//
// } finally {
// session.close();
// }
//
// }
//
// @Override
// public List<Artifact> getArtifactLinks(String sourceArtifactId, Long sourceRevision, String type) {
// Artifact cycleLink = new Artifact();
// CycleLink cycleLinkTarget = new CycleLink();
// List<CycleLink> cycleLinkTargetList = new ArrayList<CycleLink>();
//
// cycleLinkTarget.setLinkType(type);
// cycleLinkTargetList.add(cycleLinkTarget);
//
// cycleLink.setSourceArtifactId(sourceArtifactId);
// cycleLink.setSourceRevision(sourceRevision);
// cycleLink.setCycleLinkTarget(cycleLinkTargetList);
//
// SqlSessionFactory sqlMapper = getSessionFactory();
//
// SqlSession session = sqlMapper.openSession();
// try {
// return (List<Artifact>) session.selectList(
// "org.activiti.cycle.CycleLink.selectCycleLinkBySourceArtifactIdAndTypeAndSourceRevision", cycleLink);
//
// } finally {
// session.close();
// }
//
// }
//
//
// @Override
// public void deleteLink(long linkId) {
// SqlSessionFactory sqlMapper = getSessionFactory();
//
// SqlSession session = sqlMapper.openSession();
// try {
// session.insert("org.activiti.cycle.CycleLink.deleteCycleLink", linkId);
// session.commit();
// } finally {
// session.close();
// }
// }
//----- start implementation for cycle persistence -----
public ProcessEngineConfiguration getProcessEngineConfiguration() {
if (DEFAULT_ENGINE.equals(processEngineName)) {
return ((ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine()).getProcessEngineConfiguration();
} else {
return ((ProcessEngineImpl) ProcessEngines.getProcessEngine(processEngineName)).getProcessEngineConfiguration();
}
}
public CycleConfig selectById(String id) {
SqlSessionFactory sqlMapper = getSessionFactory();
SqlSession session = sqlMapper.openSession();
try {
return (CycleConfig) session.selectOne(
"org.activiti.cycle.CycleConfig.selectCycleConfigById", id);
} finally {
session.close();
}
}
public void createAndInsert(Object o, String id) {
CycleConfig cycleConfig = new CycleConfig();
cycleConfig.setId(id);
String configXML = getXStream().toXML(o);
cycleConfig.setConfigXML(configXML);
SqlSessionFactory sqlMapper = getSessionFactory();
SqlSession session = sqlMapper.openSession();
try {
session.insert("org.activiti.cycle.CycleConfig.insertCycleConfig", cycleConfig);
session.commit();
} finally {
session.close();
}
}
public void updateById(CycleConfig cycleConfig) {
SqlSessionFactory sqlMapper = getSessionFactory();
SqlSession session = sqlMapper.openSession();
try {
session.update(
"org.activiti.cycle.CycleConfig.updateCycleConfigById", cycleConfig);
session.commit();
} finally {
session.close();
}
}
public void deleteById(String id) {
SqlSessionFactory sqlMapper = getSessionFactory();
SqlSession session = sqlMapper.openSession();
try {
session.delete(
"org.activiti.cycle.CycleConfig.deleteCycleConfigById", id);
session.commit();
} finally {
session.close();
}
}
private void performDbSchemaCreation(CycleDbSqlSessionFactory dbSqlSessionFactory, ProcessEngineConfiguration processEngineConfiguration) {
String dbSchemaStrategy = processEngineConfiguration.getDbSchemaStrategy();
if (ProcessEngineConfiguration.DBSCHEMASTRATEGY_DROP_CREATE.equals(dbSchemaStrategy)) {
try {
dbSqlSessionFactory.dbSchemaDrop();
} catch (RuntimeException e) {
// ignore
}
}
if ( DbSchemaStrategy.CREATE_DROP.equals(dbSchemaStrategy)
|| ProcessEngineConfiguration.DBSCHEMASTRATEGY_DROP_CREATE.equals(dbSchemaStrategy)
|| ProcessEngineConfiguration.DBSCHEMASTRATEGY_CREATE.equals(dbSchemaStrategy)
) {
dbSqlSessionFactory.dbSchemaCreate();
} else if (DbSchemaStrategy.CHECK_VERSION.equals(dbSchemaStrategy)) {
dbSqlSessionFactory.dbSchemaCheckVersion();
}
}
}
package org.activiti.cycle.impl.db;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.activiti.cycle.CycleService;
import org.activiti.cycle.RepositoryException;
import org.activiti.cycle.impl.conf.ConfigurationContainer;
import org.activiti.cycle.impl.conf.RepositoryConnectorConfiguration;
import org.activiti.cycle.impl.plugin.PluginFinder;
import com.thoughtworks.xstream.XStream;
/**
* VERY EASY implementation of Configuration Service to write stuff as XML on
* disk. DO NOT USE THIS ANYMORE, WILL BE DELETED SOON.
*
* This is just used temporary until real persistence is implemented. The API
* <b>and the resulting XML</b> should NOT be seen as stable in the meantime.
*/
@Deprecated
public class CycleServiceFileXStreamImpl extends DummyBaseCycleService implements CycleService {
// TODO: Set a config dir for xstream?
// private static final String CONFIG_DIR = "";
private static final String FILE_EXT = ".cycle-conf.xml";
private XStream xStream = new XStream();
public CycleServiceFileXStreamImpl() {
PluginFinder.checkPluginInitialization();
}
public XStream getXStream() {
return xStream;
}
public void persistRepositoryConfiguration(RepositoryConnectorConfiguration config) {
saveObjectToFile(config.getName(), config);
}
public List<RepositoryConnectorConfiguration> findAllRepositoryConfigurations() {
// TODO: Implement retrieving all files
return new ArrayList<RepositoryConnectorConfiguration>();
}
public RepositoryConnectorConfiguration getRepositoryConfiguration(String name) {
return (RepositoryConnectorConfiguration) loadFromFile(name);
}
public void removeRepositoryConfiguration(String name) {
new File(getFileName(name)).delete();
}
public void saveObjectToFile(String name, Object o) {
String configFileName = getFileName(name);
try {
FileWriter fileWriter = new FileWriter(configFileName);
getXStream().toXML(o, fileWriter);
fileWriter.close();
} catch (IOException ioe) {
throw new RepositoryException("Unable to persist '" + name + "' as XML in the file system sd file '" + configFileName + "'", ioe);
}
}
private String getFileName(String name) {
return name + FILE_EXT;
}
public Object loadFromFile(String name) {
String configFileName = getFileName(name);
try {
FileReader fileReader = new FileReader(configFileName);
Object config = getXStream().fromXML(fileReader);
fileReader.close();
return config;
} catch (IOException ioe) {
throw new RepositoryException("Unable to load '" + name + "' as XML in the file system sd file '" + configFileName + "'", ioe);
}
}
public void saveConfiguration(ConfigurationContainer container) {
saveObjectToFile(container.getName(), container);
}
public ConfigurationContainer getConfiguration(String name) {
return (ConfigurationContainer) loadFromFile(name);
}
}
......@@ -15,7 +15,7 @@ import org.activiti.cycle.impl.connector.demo.DemoConnector;
*/
public abstract class DummyBaseCycleService implements CycleService {
public void addArtifactLink(String sourceArtifactId, String targetArtifactId) {
public void addArtifactLink(String sourceConnectorId, String sourceArtifactId, String targetConnectorId, String targetArtifactId) {
}
public void addLink(RepositoryArtifactLink link) {
......
package org.activiti.cycle;
package org.activiti.cycle.impl.db.entity;
import java.io.Serializable;
import java.util.HashMap;
......
package org.activiti.cycle;
package org.activiti.cycle.impl.db.entity;
import org.activiti.cycle.RepositoryArtifact;
import org.activiti.cycle.RepositoryNode;
import org.activiti.engine.impl.db.PersistentObject;
/**
......
package org.activiti.cycle.impl.db.impl;
import org.activiti.cycle.impl.conf.ConfigurationContainer;
import org.activiti.cycle.impl.db.CycleConfigurationService;
import org.activiti.cycle.impl.db.entity.CycleConfig;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import com.thoughtworks.xstream.XStream;
public class CycleConfigurationServiceImpl extends CycleDbService implements CycleConfigurationService {
private XStream xStream = new XStream();
public CycleConfigurationServiceImpl(String processEngineName) {
if(processEngineName != null) {
this.processEngineName = processEngineName;
}
}
public void saveConfiguration(ConfigurationContainer container) {
createAndInsert(container, container.getName());
}
public ConfigurationContainer getConfiguration(String name) {
CycleConfig cycleConfig = selectById(name);
Object configXML = this.xStream.fromXML(cycleConfig.getConfigXML());
return (ConfigurationContainer) configXML;
}
private CycleConfig selectById(String id) {
SqlSessionFactory sqlMapper = getSessionFactory();
SqlSession session = sqlMapper.openSession();
try {
return (CycleConfig) session.selectOne("org.activiti.cycle.impl.db.entity.CycleConfig.selectCycleConfigById", id);
} finally {
session.close();
}
}
private void createAndInsert(Object o, String id) {
CycleConfig cycleConfig = new CycleConfig();
cycleConfig.setId(id);
String configXML = this.xStream.toXML(o);
cycleConfig.setConfigXML(configXML);
SqlSessionFactory sqlMapper = getSessionFactory();
SqlSession session = sqlMapper.openSession();
try {
session.insert("org.activiti.cycle.impl.db.entity.CycleConfig.insertCycleConfig", cycleConfig);
session.commit();
} finally {
session.close();
}
}
private void updateById(CycleConfig cycleConfig) {
SqlSessionFactory sqlMapper = getSessionFactory();
SqlSession session = sqlMapper.openSession();
try {
session.update("org.activiti.cycle.impl.db.entity.CycleConfig.updateCycleConfigById", cycleConfig);
session.commit();
} finally {
session.close();
}
}
private void deleteById(String id) {
SqlSessionFactory sqlMapper = getSessionFactory();
SqlSession session = sqlMapper.openSession();
try {
session.delete("org.activiti.cycle.impl.db.entity.CycleConfig.deleteCycleConfigById", id);
session.commit();
} finally {
session.close();
}
}
}
package org.activiti.cycle.impl.db.impl;
import java.util.HashMap;
import org.activiti.cycle.impl.conf.CycleDbSqlSessionFactory;
import org.activiti.engine.DbSchemaStrategy;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.impl.ProcessEngineImpl;
import org.activiti.engine.impl.cfg.ProcessEngineConfiguration;
import org.apache.ibatis.session.SqlSessionFactory;
public abstract class CycleDbService {
private static HashMap<String, CycleDbSqlSessionFactory> dbFactories = new HashMap<String, CycleDbSqlSessionFactory>();
protected String processEngineName = DEFAULT_ENGINE;
protected static String DEFAULT_ENGINE = "DEFAULT_PROCESS_ENGINE";
protected SqlSessionFactory getSessionFactory() {
if (dbFactories.get(processEngineName) == null) {
synchronized (dbFactories) {
// lazy initialization, only done once per proces engine!
if (dbFactories.get(processEngineName) == null) {
CycleDbSqlSessionFactory factory = new CycleDbSqlSessionFactory();
factory.configurationCompleted(getProcessEngineConfiguration());
performDbSchemaCreation(factory, getProcessEngineConfiguration());
dbFactories.put(processEngineName, factory);
}
}
}
return dbFactories.get(processEngineName).getSqlSessionFactory();
}
protected ProcessEngineConfiguration getProcessEngineConfiguration() {
if (DEFAULT_ENGINE.equals(processEngineName)) {
return ((ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine()).getProcessEngineConfiguration();
} else {
return ((ProcessEngineImpl) ProcessEngines.getProcessEngine(processEngineName)).getProcessEngineConfiguration();
}
}
private void performDbSchemaCreation(CycleDbSqlSessionFactory dbSqlSessionFactory, ProcessEngineConfiguration processEngineConfiguration) {
String dbSchemaStrategy = processEngineConfiguration.getDbSchemaStrategy();
if (ProcessEngineConfiguration.DBSCHEMASTRATEGY_DROP_CREATE.equals(dbSchemaStrategy)) {
try {
dbSqlSessionFactory.dbSchemaDrop();
} catch (RuntimeException e) {
// ignore
}
}
if (DbSchemaStrategy.CREATE_DROP.equals(dbSchemaStrategy) || ProcessEngineConfiguration.DBSCHEMASTRATEGY_DROP_CREATE.equals(dbSchemaStrategy)
|| ProcessEngineConfiguration.DBSCHEMASTRATEGY_CREATE.equals(dbSchemaStrategy)) {
dbSqlSessionFactory.dbSchemaCreate();
} else if (DbSchemaStrategy.CHECK_VERSION.equals(dbSchemaStrategy)) {
dbSqlSessionFactory.dbSchemaCheckVersion();
}
}
}
package org.activiti.cycle.impl.db.impl;
import java.util.ArrayList;
import java.util.List;
import org.activiti.cycle.impl.db.CycleLinkService;
import org.activiti.cycle.impl.db.entity.CycleLink;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
public class CycleLinkServiceImpl extends CycleDbService implements CycleLinkService {
public CycleLink findCycleLinkById(String id) {
// TODO
throw new RuntimeException("Not implemented");
}
@SuppressWarnings("unchecked")
public List<CycleLink> getCycleLinks(String sourceArtifactId) {
SqlSessionFactory sqlMapper = getSessionFactory();
SqlSession session = sqlMapper.openSession();
List<CycleLink> linkResultList;
try {
linkResultList = session.selectList("org.activiti.cycle.impl.db.entity.CycleLink.selectArtifactLinkForSourceArtifact", sourceArtifactId);
} finally {
session.close();
}
if (linkResultList != null) {
return linkResultList;
}
return new ArrayList<CycleLink>();
}
public void updateCycleLink(CycleLink cycleLink) {
SqlSessionFactory sqlMapper = getSessionFactory();
SqlSession session = sqlMapper.openSession();
session.insert("org.activiti.cycle.impl.db.entity.CycleLink.insertCycleLink", cycleLink);
session.commit();
}
}
......@@ -15,9 +15,10 @@
<td>
<label>
Target folder:<br/>
<input type="text" name="treeTarget" value="" />
<input type="hidden" name="treeTarget_required" value="true" />
<input type="hidden" name="treeTarget_type" value="Event" />
<input type="text" name="targetFolderId" value="" />
<input type="hidden" name="targetFolderId_required" value="true" />
<input type="hidden" name="targetFolderId_type" value="Event" />
<input type="hidden" name="targetConnectorId" value="" />
</label><br/>
</td>
</tr>
......
......@@ -6,7 +6,7 @@
<!-- CYCLE CONFIG RESULT MAP -->
<resultMap id="resultMapCycleConfig" type="org.activiti.cycle.CycleConfig">
<resultMap id="resultMapCycleConfig" type="org.activiti.cycle.impl.db.entity.CycleConfig">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="configXML" column="VALUE_" jdbcType="VARCHAR" />
<result property="revision" column="REV_" jdbcType="INTEGER" />
......@@ -21,7 +21,7 @@
<!-- CYCLE CONFIG INSERT -->
<insert id="insertCycleConfig" parameterType="org.activiti.cycle.CycleConfig">
<insert id="insertCycleConfig" parameterType="org.activiti.cycle.impl.db.entity.CycleConfig">
insert into ACT_CY_CONFIG (ID_, VALUE_, REV_)
values (
#{id ,jdbcType=VARCHAR},
......@@ -38,7 +38,7 @@
<!-- CYCLE CONFIG UPDATE -->
<update id="updateCycleConfigById" parameterType="org.activiti.cycle.CycleConfig">
<update id="updateCycleConfigById" parameterType="org.activiti.cycle.impl.db.entity.CycleConfig">
update ACT_CY_CONFIG set
ID_ = #{id},
VALUE_ = #{configXML},
......
......@@ -4,7 +4,7 @@
<mapper namespace="org.activiti.cycle">
<resultMap id="resultMapCycleLink" type="org.activiti.cycle.CycleLink">
<resultMap id="resultMapCycleLink" type="org.activiti.cycle.impl.db.entity.CycleLink">
<id property="id" column="ID_"/>
<result property="sourceConnectorId" column="SOURCE_CONNECTOR_ID_"/>
<result property="targetConnectorId" column="TARGET_CONNECTOR_ID_"/>
......@@ -33,7 +33,7 @@
</select>
<!-- insertCycleLink -->
<insert id="insertCycleLink" parameterType="org.activiti.cycle.CycleLink">
<insert id="insertCycleLink" parameterType="org.activiti.cycle.impl.db.entity.CycleLink">
insert into ACT_CY_LINK (ID_,SOURCE_CONNECTOR_ID_, TARGET_CONNECTOR_ID_, SOURCE_ARTIFACT_ID_,TARGET_ARTIFACT_ID_,SOURCE_ELEMENT_ID_,TARGET_ELEMENT_ID_,SOURCE_ELEMENT_NAME_,TARGET_ELEMENT_NAME_, SOURCE_REVISION_, TARGET_REVISION_ , LINK_TYPE_, DESCRIPTION_, LINKED_BOTH_WAYS_)
values (
#{id, jdbcType=VARCHAR},
......@@ -61,7 +61,7 @@
<result property="elementId" column="ELEMENT_ID_"/>
<result property="elementName" column="ELEMENT_NAME_"/>
<collection property="artifactRevisionList" javaType="ArrayList" ofType="org.activiti.cycle.ArtifactRevision" column="ID_" select="selectArtifactRevisionForArtifact"/>
<collection property="artifactCycleList" javaType="ArrayList" ofType="org.activiti.cycle.CycleLink" column="ID_" select="selectCycleLinkForSourceArtifact"/>
<collection property="artifactCycleList" javaType="ArrayList" ofType="org.activiti.cycle.impl.db.entity.CycleLink" column="ID_" select="selectCycleLinkForSourceArtifact"/>
</resultMap>
-->
......@@ -74,7 +74,7 @@
-->
<!-- @deprecated: not useful now: Cycle Link RESULT MAP
<resultMap id="resultMapCycleLink" type="org.activiti.cycle.CycleLink">
<resultMap id="resultMapCycleLink" type="org.activiti.cycle.impl.db.entity.CycleLink">
<id property="id" column="ID_"/>
<result property="targetArtifactId" column="TARGET_ARTIFACT_ID_"/>
<result property="targetElementId" column="TARGET_ELEMENT_ID_"/>
......@@ -128,7 +128,7 @@
-->
<!-- @deprecated: not useful now: insertCycleLink
<insert id="insertCycleLink" parameterType="org.activiti.cycle.CycleLink">
<insert id="insertCycleLink" parameterType="org.activiti.cycle.impl.db.entity.CycleLink">
insert into ACT_CY_LINK (ID_, TARGET_ELEMENT_NAME, TARGET_ELEMENT_ID_, TARGET_ELEMENT_REVISION_ ,SOURCE_ARTIFACT_ID_)
values (
#{id, jdbcType=VARCHAR},
......@@ -161,7 +161,7 @@
-->
<!-- @deprecated: not useful now: updateCycleLink
<update id="updateCycleLink" parameterType="org.activiti.cycle.CycleLink">
<update id="updateCycleLink" parameterType="org.activiti.cycle.impl.db.entity.CycleLink">
update ACT_CY_LINK set
ID_ = #{id},
TARGET_ELEMENT_NAME_ = #{targetElementName},
......
package org.activiti.cycle.impl.conf;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.activiti.cycle.Artifact;
import org.activiti.cycle.CycleLink;
import org.activiti.cycle.CycleService;
import org.activiti.cycle.RepositoryArtifactLink;
import org.activiti.cycle.RepositoryConnector;
import org.activiti.cycle.impl.connector.fs.FileSystemConnectorConfiguration;
import org.activiti.cycle.impl.connector.signavio.SignavioConnectorConfiguration;
import org.activiti.cycle.impl.connector.view.RootConnectorConfiguration;
import org.activiti.cycle.impl.db.CycleServiceDbXStreamImpl;
import org.activiti.engine.ProcessEngines;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import com.sun.xml.bind.CycleRecoverable;
public class RepositoryConnectorConfigurationManagerImplTest {
private static CycleService configurationService;
private static CycleService cycleService;
@BeforeClass
public static void setUp() throws Exception {
//ProcessEngines.destroy();
// ProcessEngines.destroy();
ProcessEngines.init();
configurationService = new CycleServiceDbXStreamImpl();
// configurationService = new CycleServiceImpl();
}
@AfterClass
public static void tearDown() throws Exception {
configurationService = null;
//ProcessEngines.destroy();
// configurationService = null;
// ProcessEngines.destroy();
}
// @Test
// public void testAPI() {
// try {
// ConfigurationContainer enterpriseConfiguration = new ConfigurationContainer("camunda");
// // This one is for all, so don't save a password, the GUI should query it!
// RepositoryConnectorConfiguration conf1 = new SignavioConnectorConfiguration("Activiti Modeler", "http://localhost:8080/activiti-modeler/");
// enterpriseConfiguration.addRepositoryConnectorConfiguration(conf1);
//
// ConfigurationContainer userConfiguration = new ConfigurationContainer("bernd");
// userConfiguration.addParent(enterpriseConfiguration);
// RepositoryConnectorConfiguration conf2 = new FileSystemConnectorConfiguration("Hard Drive", new File("c:"));
// userConfiguration.addRepositoryConnectorConfiguration(conf2);
// // This one ist just for me, I save the password
// RepositoryConnectorConfiguration conf3 = new SignavioConnectorConfiguration("Signavio SAAS", "http://editor.signavio.com/", null,
// "bernd.ruecker@camunda.com", "xxx");
// userConfiguration.addRepositoryConnectorConfiguration(conf3);
//
// // now we have a config for the user containing 2 repository configs
//
// configurationService.saveConfiguration(enterpriseConfiguration);
// configurationService.saveConfiguration(userConfiguration);
//
// ConfigurationContainer loadedConf = configurationService.getConfiguration("bernd");
//
// // ConfigurationContainer configuration =
// // configurationService.getConfiguration("bernd");
// List<RepositoryConnectorConfiguration> connectors = loadedConf.getConnectorConfigurations();
// assertEquals(3, connectors.size());
// assertEquals("Hard Drive", connectors.get(0).getName());
// assertEquals("Signavio SAAS", connectors.get(1).getName());
// assertEquals("Activiti Modeler", connectors.get(2).getName());
//
// RepositoryConnector connector = new RootConnectorConfiguration(loadedConf).createConnector();
//
// // check that files were created
//// assertTrue(new File("bernd.cycle-conf.xml").delete());
//// assertTrue(new File("camunda.cycle-conf.xml").delete());
// } finally {
// // clean up to delete created configs, do it in the finally again to make
// // sure they are deleted
//// new File("bernd.cycle-conf.xml").delete();
//// new File("camunda.cycle-conf.xml").delete();
// }
// }
// @Test
// public void testAPI() {
// try {
// ConfigurationContainer enterpriseConfiguration = new
// ConfigurationContainer("camunda");
// // This one is for all, so don't save a password, the GUI should query it!
// RepositoryConnectorConfiguration conf1 = new
// SignavioConnectorConfiguration("Activiti Modeler",
// "http://localhost:8080/activiti-modeler/");
// enterpriseConfiguration.addRepositoryConnectorConfiguration(conf1);
//
// ConfigurationContainer userConfiguration = new
// ConfigurationContainer("bernd");
// userConfiguration.addParent(enterpriseConfiguration);
// RepositoryConnectorConfiguration conf2 = new
// FileSystemConnectorConfiguration("Hard Drive", new File("c:"));
// userConfiguration.addRepositoryConnectorConfiguration(conf2);
// // This one ist just for me, I save the password
// RepositoryConnectorConfiguration conf3 = new
// SignavioConnectorConfiguration("Signavio SAAS",
// "http://editor.signavio.com/", null,
// "bernd.ruecker@camunda.com", "xxx");
// userConfiguration.addRepositoryConnectorConfiguration(conf3);
//
// // now we have a config for the user containing 2 repository configs
//
// configurationService.saveConfiguration(enterpriseConfiguration);
// configurationService.saveConfiguration(userConfiguration);
//
// ConfigurationContainer loadedConf =
// configurationService.getConfiguration("bernd");
//
// // ConfigurationContainer configuration =
// // configurationService.getConfiguration("bernd");
// List<RepositoryConnectorConfiguration> connectors =
// loadedConf.getConnectorConfigurations();
// assertEquals(3, connectors.size());
// assertEquals("Hard Drive", connectors.get(0).getName());
// assertEquals("Signavio SAAS", connectors.get(1).getName());
// assertEquals("Activiti Modeler", connectors.get(2).getName());
//
// RepositoryConnector connector = new
// RootConnectorConfiguration(loadedConf).createConnector();
//
// // check that files were created
// // assertTrue(new File("bernd.cycle-conf.xml").delete());
// // assertTrue(new File("camunda.cycle-conf.xml").delete());
// } finally {
// // clean up to delete created configs, do it in the finally again to make
// // sure they are deleted
// // new File("bernd.cycle-conf.xml").delete();
// // new File("camunda.cycle-conf.xml").delete();
// }
// }
@Test
public void testLinks() {
configurationService.addArtifactLink("FS/text/test.txt", "SIG/bpmn/test.bpmn20.xml");
List<RepositoryArtifactLink> artifactResultList = configurationService.getArtifactLinks("FS/text/test.txt");
// cycleLinkTarget.setDescription("nur ein Testlink");
// cycleLinkTarget.setLinkType(Artifact.TYPE_UNSPECIFIED);
// cycleLinkTarget.setTargetArtifactId("SIG/bpmn/test.bpmn20.xml");
// cycleLinkTargetList.add(cycleLinkTarget);
//
// cycleLink.setSourceArtifactId("FS/text/test.txt");
//
//// cycleLink.setCycleLinkTarget(cycleLinkTargetList);
//
// configurationService.addArtifactLink("FS/text/test.txt", "SIG/bpmn/test.bpmn20.xml");
//
// List<Artifact> artifactLinks = configurationService.getArtifactLinks("FS/text/test.txt");
// if (artifactLinks != null && !artifactLinks.isEmpty()) {
// Artifact cyleLink = artifactLinks.get(0);
// System.out.println(cycleLink.getSourceArtifactId());
// System.out.println(cycleLink.getCycleLinkTarget().size());
// }
// configurationService.addArtifactLink("FS/text/test.txt",
// "SIG/bpmn/test.bpmn20.xml");
// List<RepositoryArtifactLink> artifactResultList =
// configurationService.getArtifactLinks("FS/text/test.txt");
// cycleLinkTarget.setDescription("nur ein Testlink");
// cycleLinkTarget.setLinkType(Artifact.TYPE_UNSPECIFIED);
// cycleLinkTarget.setTargetArtifactId("SIG/bpmn/test.bpmn20.xml");
// cycleLinkTargetList.add(cycleLinkTarget);
//
// cycleLink.setSourceArtifactId("FS/text/test.txt");
//
// // cycleLink.setCycleLinkTarget(cycleLinkTargetList);
//
// configurationService.addArtifactLink("FS/text/test.txt",
// "SIG/bpmn/test.bpmn20.xml");
//
// List<Artifact> artifactLinks =
// configurationService.getArtifactLinks("FS/text/test.txt");
// if (artifactLinks != null && !artifactLinks.isEmpty()) {
// Artifact cyleLink = artifactLinks.get(0);
// System.out.println(cycleLink.getSourceArtifactId());
// System.out.println(cycleLink.getCycleLinkTarget().size());
// }
}
//Commented because method getProcessEngineConfiguration is not in the interface
// @Test
// public void testGetProcessEngineConfiguration() {
// ProcessEngineConfiguration processEngineConfiguration = configurationService.getProcessEngineConfiguration();
// if (processEngineConfiguration == null) {
// fail("config is null");
// }
// }
// @Test
// public void testInsertCycleConfiguration() {
// String id = "kristin";
// String configXML = "<org.activiti.cycle.impl.conf.ConfigurationContainer>"
// + " <name>kristin</name>"
// + " <linkedConnectors>"
// + "<org.activiti.cycle.impl.connector.signavio.SignavioConnectorConfiguration>"
// + "<name>Activiti Modeler</name>"
// + "<credentialsSaved>false</credentialsSaved>"
// + "<signavioBaseUrl>http://localhost:8080/activiti-modeler/</signavioBaseUrl>"
// + "<loginRequired>false</loginRequired>"
// + "</org.activiti.cycle.impl.connector.signavio.SignavioConnectorConfiguration>"
// + "<org.activiti.cycle.impl.connector.fs.FileSystemConnectorConfiguration>"
// + "<name>Eclipse Workspace (File System)</name>"
// + "<baseFilePath>C:/Dokumente+und+Einstellungen/polenz/workspace/activiti/distro/target/activiti-5.0.rc1-SNAPSHOT/apps/eclipse-workspace</baseFilePath>"
// + "</org.activiti.cycle.impl.connector.fs.FileSystemConnectorConfiguration>"
// + "<org.activiti.cycle.impl.connector.signavio.OryxConnectorConfiguration>"
// + "<name>oryx-project.org</name>"
// + "<credentialsSaved>false</credentialsSaved>"
// + "<signavioBaseUrl>http://oryx-project.org/</signavioBaseUrl>"
// + "<loginRequired>false</loginRequired>"
// + "</org.activiti.cycle.impl.connector.signavio.OryxConnectorConfiguration>"
// + "</linkedConnectors>"
// + "<parentContainers/>"
// + "</org.activiti.cycle.impl.conf.ConfigurationContainer>";
// configurationService.createAndInsert(configXML, id);
//
// }
//
// @Test
// public void testSelectById() {
// CycleConfigEntity cycleConfig = configurationService.selectById("kristin");
//
// String configXML = "<org.activiti.cycle.impl.conf.ConfigurationContainer>"
// + " <name>kristinPolenz</name>"
// + " <linkedConnectors>"
// + "<org.activiti.cycle.impl.connector.signavio.SignavioConnectorConfiguration>"
// + "<name>Activiti Modeler</name>"
// + "<credentialsSaved>false</credentialsSaved>"
// + "<signavioBaseUrl>http://localhost:8080/activiti-modeler/</signavioBaseUrl>"
// + "<loginRequired>false</loginRequired>"
// + "</org.activiti.cycle.impl.connector.signavio.SignavioConnectorConfiguration>"
// + "<org.activiti.cycle.impl.connector.fs.FileSystemConnectorConfiguration>"
// + "<name>Eclipse Workspace (File System)</name>"
// + "<baseFilePath>C:/Dokumente+und+Einstellungen/polenz/workspace/activiti/distro/target/activiti-5.0.rc1-SNAPSHOT/apps/eclipse-workspace</baseFilePath>"
// + "</org.activiti.cycle.impl.connector.fs.FileSystemConnectorConfiguration>"
// + "<org.activiti.cycle.impl.connector.signavio.OryxConnectorConfiguration>"
// + "<name>oryx-project.org</name>"
// + "<credentialsSaved>false</credentialsSaved>"
// + "<signavioBaseUrl>http://oryx-project.org/</signavioBaseUrl>"
// + "<loginRequired>false</loginRequired>"
// + "</org.activiti.cycle.impl.connector.signavio.OryxConnectorConfiguration>"
// + "</linkedConnectors>"
// + "<parentContainers/>"
// + "</org.activiti.cycle.impl.conf.ConfigurationContainer>";
//
// //update by id
// cycleConfig.setConfigXML(configXML);
// cycleConfig.setRevision(cycleConfig.getRevision()+1);
//
// configurationService.updateById(cycleConfig);
// }
//
// @Test
// public void testDeleteById() {
// configurationService.deleteById("kristin");
// }
// Commented because method getProcessEngineConfiguration is not in the
// interface
// @Test
// public void testGetProcessEngineConfiguration() {
// ProcessEngineConfiguration processEngineConfiguration =
// configurationService.getProcessEngineConfiguration();
// if (processEngineConfiguration == null) {
// fail("config is null");
// }
// }
// @Test
// public void testInsertCycleConfiguration() {
// String id = "kristin";
// String configXML = "<org.activiti.cycle.impl.conf.ConfigurationContainer>"
// + " <name>kristin</name>"
// + " <linkedConnectors>"
// +
// "<org.activiti.cycle.impl.connector.signavio.SignavioConnectorConfiguration>"
// + "<name>Activiti Modeler</name>"
// + "<credentialsSaved>false</credentialsSaved>"
// +
// "<signavioBaseUrl>http://localhost:8080/activiti-modeler/</signavioBaseUrl>"
// + "<loginRequired>false</loginRequired>"
// +
// "</org.activiti.cycle.impl.connector.signavio.SignavioConnectorConfiguration>"
// + "<org.activiti.cycle.impl.connector.fs.FileSystemConnectorConfiguration>"
// + "<name>Eclipse Workspace (File System)</name>"
// +
// "<baseFilePath>C:/Dokumente+und+Einstellungen/polenz/workspace/activiti/distro/target/activiti-5.0.rc1-SNAPSHOT/apps/eclipse-workspace</baseFilePath>"
// +
// "</org.activiti.cycle.impl.connector.fs.FileSystemConnectorConfiguration>"
// + "<org.activiti.cycle.impl.connector.signavio.OryxConnectorConfiguration>"
// + "<name>oryx-project.org</name>"
// + "<credentialsSaved>false</credentialsSaved>"
// + "<signavioBaseUrl>http://oryx-project.org/</signavioBaseUrl>"
// + "<loginRequired>false</loginRequired>"
// +
// "</org.activiti.cycle.impl.connector.signavio.OryxConnectorConfiguration>"
// + "</linkedConnectors>"
// + "<parentContainers/>"
// + "</org.activiti.cycle.impl.conf.ConfigurationContainer>";
// configurationService.createAndInsert(configXML, id);
//
// }
//
// @Test
// public void testSelectById() {
// CycleConfigEntity cycleConfig = configurationService.selectById("kristin");
//
// String configXML = "<org.activiti.cycle.impl.conf.ConfigurationContainer>"
// + " <name>kristinPolenz</name>"
// + " <linkedConnectors>"
// +
// "<org.activiti.cycle.impl.connector.signavio.SignavioConnectorConfiguration>"
// + "<name>Activiti Modeler</name>"
// + "<credentialsSaved>false</credentialsSaved>"
// +
// "<signavioBaseUrl>http://localhost:8080/activiti-modeler/</signavioBaseUrl>"
// + "<loginRequired>false</loginRequired>"
// +
// "</org.activiti.cycle.impl.connector.signavio.SignavioConnectorConfiguration>"
// + "<org.activiti.cycle.impl.connector.fs.FileSystemConnectorConfiguration>"
// + "<name>Eclipse Workspace (File System)</name>"
// +
// "<baseFilePath>C:/Dokumente+und+Einstellungen/polenz/workspace/activiti/distro/target/activiti-5.0.rc1-SNAPSHOT/apps/eclipse-workspace</baseFilePath>"
// +
// "</org.activiti.cycle.impl.connector.fs.FileSystemConnectorConfiguration>"
// + "<org.activiti.cycle.impl.connector.signavio.OryxConnectorConfiguration>"
// + "<name>oryx-project.org</name>"
// + "<credentialsSaved>false</credentialsSaved>"
// + "<signavioBaseUrl>http://oryx-project.org/</signavioBaseUrl>"
// + "<loginRequired>false</loginRequired>"
// +
// "</org.activiti.cycle.impl.connector.signavio.OryxConnectorConfiguration>"
// + "</linkedConnectors>"
// + "<parentContainers/>"
// + "</org.activiti.cycle.impl.conf.ConfigurationContainer>";
//
// //update by id
// cycleConfig.setConfigXML(configXML);
// cycleConfig.setRevision(cycleConfig.getRevision()+1);
//
// configurationService.updateById(cycleConfig);
// }
//
// @Test
// public void testDeleteById() {
// configurationService.deleteById("kristin");
// }
//
//
// @Test
......
......@@ -63,6 +63,7 @@
var eventValue = args[1].value;
this._connectorId = eventValue.connectorId;
this._repositoryNodeId = eventValue.repositoryNodeId;
this._isRepositoryArtifact = eventValue.isRepositoryArtifact;
this._name = eventValue.name;
......@@ -90,7 +91,7 @@
}
// Check whether the selected node is a file node. If so, load its data
if(eventValue.isRepositoryArtifact ) {
this.services.repositoryService.loadArtifact(eventValue.repositoryNodeId);
this.services.repositoryService.loadArtifact(eventValue.connectorId, eventValue.repositoryNodeId);
}
// Update the heading that displays the name of the selected node
headerEl.id = "header-" + eventValue.repositoryNodeId;
......@@ -118,7 +119,7 @@
for(var i = 0; i<artifactJson.contentRepresentations.length; i++) {
var tab = new YAHOO.widget.Tab({
label: artifactJson.contentRepresentations[i],
dataSrc: this.loadTabDataURL(artifactJson.id, artifactJson.contentRepresentations[i]),
dataSrc: this.loadTabDataURL(artifactJson.connectorId, artifactJson.artifactId, artifactJson.contentRepresentations[i]),
cacheData: true
});
tab.addListener("contentChange", this.onTabDataLoaded);
......@@ -155,7 +156,7 @@
for(i = 0; i<artifactJson.actions.length; i++) {
option = document.createElement("option");
option.setAttribute('value', artifactJson.id + "#TOKEN#" + artifactJson.actions[i].name);
option.setAttribute('value', artifactJson.connectorId + "#TOKEN#" + artifactJson.artifactId + "#TOKEN#" + artifactJson.actions[i].name);
option.appendChild(document.createTextNode(artifactJson.actions[i].label));
actionsDropdown.appendChild(option);
YAHOO.util.Event.addListener(option, "click", this.onExecuteActionClick);
......@@ -212,9 +213,9 @@
var tabContent;
if(responseJson.renderInfo == "IMAGE") {
tabContent = '<div class="artifact-image"><img id="' + responseJson.contentRepresentationId + '" src="' + responseJson.imageUrl + '" border=0></img></div>';
tabContent = '<div class="artifact-image"><img id="' + responseJson.contentRepresentationId + '" src="' + Activiti.service.REST_PROXY_URI_RELATIVE + "content?connectorId=" + encodeURIComponent(responseJson.connectorId) + "&artifactId=" + encodeURIComponent(responseJson.artifactId) + "&contentRepresentationId=" + encodeURIComponent(responseJson.contentRepresentationId) + '" border=0></img></div>';
} else if (responseJson.renderInfo == "HTML") {
tabContent = '<div class="artifact-html"><iframe src ="' + Activiti.service.REST_PROXY_URI_RELATIVE + "content?artifactId=" + encodeURIComponent(responseJson.artifactId) + "&contentRepresentationId=" + encodeURIComponent(responseJson.contentRepresentationId); + '" width="100%" height="100%"><p>Your browser does not support iframes.</p></iframe></div>';
tabContent = '<div class="artifact-html"><iframe src ="' + Activiti.service.REST_PROXY_URI_RELATIVE + "content?connectorId=" + encodeURIComponent(responseJson.connectorId) + "&artifactId=" + encodeURIComponent(responseJson.artifactId) + "&contentRepresentationId=" + encodeURIComponent(responseJson.contentRepresentationId) + '" width="100%" height="100%"><p>Your browser does not support iframes.</p></iframe></div>';
} else if (responseJson.renderInfo == "BINARY") {
// TODO: show some information but no content for binary
tabContent = '<div class="artifact-binary"><p>No preview available...</p></div>';
......@@ -233,10 +234,11 @@
onExecuteActionClick: function Artifact_onExecuteActionClick(e)
{
var artifactId = this.value.split("#TOKEN#")[0];
var actionName = this.value.split("#TOKEN#")[1];
var connectorId = this.value.split("#TOKEN#")[0];
var artifactId = this.value.split("#TOKEN#")[1];
var actionName = this.value.split("#TOKEN#")[2];
return new Activiti.widget.ExecuteArtifactActionForm(this.id + "-executeArtifactActionForm", artifactId, actionName);
return new Activiti.widget.ExecuteArtifactActionForm(this.id + "-executeArtifactActionForm", connectorId, artifactId, actionName);
},
onTabDataLoaded: function Artifact_onTabDataLoaded()
......@@ -244,15 +246,15 @@
prettyPrint();
},
loadTabDataURL: function Artifact_loadTabDataURL(artifactId, representationId)
loadTabDataURL: function Artifact_loadTabDataURL(connectorId, artifactId, representationId)
{
return Activiti.service.REST_PROXY_URI_RELATIVE + "content-representation?artifactId=" + encodeURIComponent(artifactId) + "&representationId=" + encodeURIComponent(representationId) + "&restProxyUri=" + encodeURIComponent(Activiti.service.REST_PROXY_URI_RELATIVE);
return Activiti.service.REST_PROXY_URI_RELATIVE + "content-representation?connectorId=" + encodeURIComponent(connectorId) + "&artifactId=" + encodeURIComponent(artifactId) + "&representationId=" + encodeURIComponent(representationId);
},
onActiveTabChange: function Artifact_onActiveTabChange(event)
{
var newActiveTabIndex = this._tabView.getTabIndex(event.newValue);
this.fireEvent(Activiti.event.updateArtifactView, {"repositoryNodeId": this._repositoryNodeId, "isRepositoryArtifact": this._isRepositoryArtifact, "name": this._name, "activeTabIndex": newActiveTabIndex}, null, true);
this.fireEvent(Activiti.event.updateArtifactView, {"connectorId": this._connectorId, "repositoryNodeId": this._repositoryNodeId, "isRepositoryArtifact": this._isRepositoryArtifact, "name": this._name, "activeTabIndex": newActiveTabIndex}, null, true);
YAHOO.util.Event.preventDefault(event);
},
......
......@@ -152,8 +152,8 @@
},
onSubmit: function FileChooserDialog_onSubmit() {
if(this._currentNode.data && this._currentNode.data.id && this._currentNode.label) {
this._callbackFn({"nodeId": this._currentNode.data.id, "nodeName": this._currentNode.label});
if(this._currentNode.data && this._currentNode.data.connectorId && this._currentNode.data.artifactId && this._currentNode.label) {
this._callbackFn({"connectorId": this._currentNode.data.connectorId, "nodeId": this._currentNode.data.artifactId, "nodeName": this._currentNode.label});
} else {
// TODO: handle error... should never happen due to validation, though...
}
......
......@@ -130,13 +130,20 @@
obj[1]();
},
// TODO: See how we can handle failures
// onLoadNodeDataFailure: function RepoTree_RepositoryService_onLoadNodeDataFailure(response, obj)
// {
//
//
// },
/**
* Will fire a Activiti.event.selectTreeLabel event so other components may display the node
*
* @method onLabelClick
* @param e {object} The click event
*/
onLabelClick: function RepoTree_onLabelClick (node)
onLabelClick: function RepoTree_onLabelClick (event)
{
// Map the node properties to the event value object (value object property -> node property):
......@@ -144,7 +151,7 @@
// - isRepositoryArtifact -> node.data.file
// - name -> node.label
this.fireEvent(Activiti.event.updateArtifactView, {"repositoryNodeId": node.node.data.id, "isRepositoryArtifact": node.node.data.file, "name": node.node.label, "activeTabIndex": 0}, null, true);
this.fireEvent(Activiti.event.updateArtifactView, {"connectorId": event.node.data.connectorId, "repositoryNodeId": event.node.data.artifactId, "isRepositoryArtifact": event.node.data.file, "name": event.node.label, "activeTabIndex": 0}, null, true);
},
onNodeExpand: function RepoTree_onNodeExpand (node)
......
......@@ -57,7 +57,7 @@
*/
loadTreeURL: function RepositoryService_loadTreeURL()
{
return Activiti.service.REST_PROXY_URI_RELATIVE + "child-nodes?artifactId=/";
return Activiti.service.REST_PROXY_URI_RELATIVE + "child-nodes?connectorId=/&artifactId=''";
},
/**
......@@ -67,7 +67,7 @@
loadNodeData: function RepositoryService_loadNodeData(node, fnLoadComplete)
{
var obj = [node, fnLoadComplete];
this.jsonGet(this.loadNodeURL(node.data.id), obj, "loadNodeData");
this.jsonGet(this.loadNodeURL(node.data.connectorId, node.data.artifactId), obj, "loadNodeData");
},
/**
......@@ -77,9 +77,9 @@
* @method loadTreeURL
* @return {string} The url
*/
loadNodeURL: function RepositoryService_loadNodeURL(nodeid)
loadNodeURL: function RepositoryService_loadNodeURL(connectorId, nodeid)
{
return Activiti.service.REST_PROXY_URI_RELATIVE + "child-nodes?artifactId=" + encodeURIComponent(nodeid);
return Activiti.service.REST_PROXY_URI_RELATIVE + "child-nodes?connectorId=" + encodeURIComponent(connectorId) + "&artifactId=" + encodeURIComponent(nodeid);
},
/**
......@@ -89,9 +89,9 @@
* @param artifactid {string} The id of the artifact to be loaded
* @param obj {Object} Helper object to be sent to the callback
*/
loadArtifact: function RepositoryService_loadArtifact(artifactid, obj)
loadArtifact: function RepositoryService_loadArtifact(connectorId, artifactid, obj)
{
this.jsonGet(this.loadArtifactURL(artifactid), obj, "loadArtifact");
this.jsonGet(this.loadArtifactURL(connectorId, artifactid), obj, "loadArtifact");
},
/**
......@@ -101,31 +101,31 @@
* @param artifactid {string} The id of the artifact
* @return {string} The url
*/
loadArtifactURL: function RepositoryService_loadArtifactURL(artifactid)
loadArtifactURL: function RepositoryService_loadArtifactURL(connectorId, artifactid)
{
return Activiti.service.REST_PROXY_URI_RELATIVE + "artifact?artifactId=" + encodeURIComponent(artifactid) + "&restProxyUri=" + encodeURIComponent(Activiti.service.REST_PROXY_URI_RELATIVE);
return Activiti.service.REST_PROXY_URI_RELATIVE + "artifact?connectorId=" + encodeURIComponent(connectorId) + "&artifactId=" + encodeURIComponent(artifactid) + "&restProxyUri=" + encodeURIComponent(Activiti.service.REST_PROXY_URI_RELATIVE);
},
// TODO: doc
loadArtifactActionForm: function RepositoryService_loadArtifactActionForm(artifactId, artifactActionName, obj)
loadArtifactActionForm: function RepositoryService_loadArtifactActionForm(connectorId, artifactId, artifactActionName, obj)
{
this.jsonGet(this.loadArtifactActionFormURL(artifactId, artifactActionName), obj, "loadArtifactActionForm");
this.jsonGet(this.loadArtifactActionFormURL(connectorId, artifactId, artifactActionName), obj, "loadArtifactActionForm");
},
// TODO: doc
loadArtifactActionFormURL: function RepositoryService_loadArtifactActionFormURL(artifactId, artifactActionName)
loadArtifactActionFormURL: function RepositoryService_loadArtifactActionFormURL(connectorId, artifactId, artifactActionName)
{
return Activiti.service.REST_PROXY_URI_RELATIVE + "artifact-action-form?artifactId=" + encodeURIComponent(artifactId) + "&actionName=" + encodeURIComponent(artifactActionName);
return Activiti.service.REST_PROXY_URI_RELATIVE + "artifact-action-form?connectorId=" + encodeURIComponent(connectorId) + "&artifactId=" + encodeURIComponent(artifactId) + "&actionName=" + encodeURIComponent(artifactActionName);
},
executeArtifactAction: function RepositoryService_executeArtifactAction(artifactId, artifactActionName, variables, obj)
executeArtifactAction: function RepositoryService_executeArtifactAction(connectorId, artifactId, artifactActionName, variables, obj)
{
this.jsonPut(this.executeArtifactFormURL(artifactId, artifactActionName), variables, obj, "executeArtifactAction");
this.jsonPut(this.executeArtifactFormURL(connectorId, artifactId, artifactActionName), variables, obj, "executeArtifactAction");
},
executeArtifactFormURL: function RepositoryService_executeArtifactFormURL(artifactId, artifactActionName)
executeArtifactFormURL: function RepositoryService_executeArtifactFormURL(connectorId, artifactId, artifactActionName)
{
return Activiti.service.REST_PROXY_URI_RELATIVE + "artifact-action?artifactId=" + encodeURIComponent(artifactId) + "&actionName=" + encodeURIComponent(artifactActionName);
return Activiti.service.REST_PROXY_URI_RELATIVE + "artifact-action?connectorId=" + encodeURIComponent(connectorId) + "&artifactId=" + encodeURIComponent(artifactId) + "&actionName=" + encodeURIComponent(artifactActionName);
}
});
......@@ -154,14 +154,15 @@
* @return {Activiti.widget.ExecuteArtifactActionForm} The new Activiti.widget.ExecuteArtifactActionForm instance
* @constructor
*/
Activiti.widget.ExecuteArtifactActionForm = function ExecuteArtifactActionForm_constructor(id, artifactId, artifactActionName)
Activiti.widget.ExecuteArtifactActionForm = function ExecuteArtifactActionForm_constructor(id, connectorId, artifactId, artifactActionName)
{
Activiti.widget.ExecuteArtifactActionForm.superclass.constructor.call(this, id);
this.connectorId = connectorId;
this.artifactId = artifactId;
this.artifactActionName = artifactActionName;
this.service = new Activiti.service.RepositoryService(this);
this.service.setCallback("loadArtifactActionForm", { fn: this.onLoadFormSuccess, scope: this }, {fn: this.onLoadFormFailure, scope: this });
this.service.loadArtifactActionForm(this.artifactId, this.artifactActionName);
this.service.loadArtifactActionForm(this.connectorId, this.artifactId, this.artifactActionName);
return this;
};
......@@ -175,7 +176,7 @@
*/
doSubmit: function ExecuteArtifactActionForm__doSubmit(variables)
{
this.service.executeArtifactAction(this.artifactId, this.artifactActionName, variables);
this.service.executeArtifactAction(this.connectorId, this.artifactId, this.artifactActionName, variables);
}
});
......
......@@ -4,8 +4,8 @@ import java.util.Map;
import javax.servlet.http.HttpSession;
import org.activiti.cycle.RepositoryConnector;
import org.activiti.cycle.impl.db.CycleServiceDbXStreamImpl;
import org.activiti.cycle.CycleService;
import org.activiti.cycle.impl.CycleServiceImpl;
import org.activiti.rest.util.ActivitiRequest;
import org.activiti.rest.util.ActivitiWebScript;
import org.springframework.extensions.webscripts.Cache;
......@@ -13,21 +13,20 @@ import org.springframework.extensions.webscripts.Status;
public class ActionExecutionPut extends ActivitiWebScript {
// private CycleService cycleService;
private RepositoryConnector repositoryConnector;
private CycleService cycleService;
private void init(ActivitiRequest req) {
String cuid = req.getCurrentUserId();
HttpSession session = req.getHttpServletRequest().getSession(true);
// this.cycleService = SessionUtil.getCycleService();
this.repositoryConnector = CycleServiceDbXStreamImpl.getRepositoryConnector(cuid, session);
this.cycleService = CycleServiceImpl.getCycleService(cuid, session);
}
@Override
protected void executeWebScript(ActivitiRequest req, Status status, Cache cache, Map<String, Object> model) {
init(req);
String connectorId = req.getMandatoryString("connectorId");
String artifactId = req.getMandatoryString("artifactId");
String actionId = req.getMandatoryString("actionName");
......@@ -35,7 +34,7 @@ public class ActionExecutionPut extends ActivitiWebScript {
Map<String, Object> parameters = req.getFormVariables(body);
try {
this.repositoryConnector.executeParameterizedAction(artifactId, actionId, parameters);
this.cycleService.executeParameterizedAction(connectorId, artifactId, actionId, parameters);
model.put("result", true);
} catch (Exception e) {
// TODO: see whether this makes sense, probably either exception or negative result.
......
......@@ -4,10 +4,10 @@ import java.util.Map;
import javax.servlet.http.HttpSession;
import org.activiti.cycle.CycleService;
import org.activiti.cycle.ParameterizedAction;
import org.activiti.cycle.RepositoryArtifact;
import org.activiti.cycle.RepositoryConnector;
import org.activiti.cycle.impl.db.CycleServiceDbXStreamImpl;
import org.activiti.cycle.impl.CycleServiceImpl;
import org.activiti.rest.util.ActivitiRequest;
import org.activiti.rest.util.ActivitiWebScript;
import org.springframework.extensions.webscripts.Cache;
......@@ -16,15 +16,13 @@ import org.springframework.extensions.webscripts.WebScriptException;
public class ArtifactActionFormGet extends ActivitiWebScript {
// private CycleService cycleService;
private RepositoryConnector repositoryConnector;
private CycleService cycleService;
private void init(ActivitiRequest req) {
String cuid = req.getCurrentUserId();
HttpSession session = req.getHttpServletRequest().getSession(true);
// this.cycleService = SessionUtil.getCycleService();
this.repositoryConnector = CycleServiceDbXStreamImpl.getRepositoryConnector(cuid, session);
this.cycleService = CycleServiceImpl.getCycleService(cuid, session);
}
/**
......@@ -40,14 +38,15 @@ public class ArtifactActionFormGet extends ActivitiWebScript {
init(req);
// Retrieve the artifactId from the request
String connectorId = req.getMandatoryString("connectorId");
String artifactId = req.getMandatoryString("artifactId");
String actionId = req.getMandatoryString("actionName");
// Retrieve the artifact from the repository
RepositoryArtifact artifact = this.repositoryConnector.getRepositoryArtifact(artifactId);
RepositoryArtifact artifact = this.cycleService.getRepositoryArtifact(connectorId, artifactId);
if (artifact == null) {
throw new WebScriptException(Status.STATUS_NOT_FOUND, "There is no artifact with id '" + artifactId + "'.");
throw new WebScriptException(Status.STATUS_NOT_FOUND, "There is no artifact with id '" + artifactId + "' for connector with id '" + connectorId + "'.");
}
// Retrieve the action and its form
......
......@@ -21,10 +21,10 @@ import java.util.Map;
import javax.servlet.http.HttpSession;
import org.activiti.cycle.ContentRepresentation;
import org.activiti.cycle.CycleService;
import org.activiti.cycle.DownloadContentAction;
import org.activiti.cycle.RepositoryArtifact;
import org.activiti.cycle.RepositoryConnector;
import org.activiti.cycle.impl.db.CycleServiceDbXStreamImpl;
import org.activiti.cycle.impl.CycleServiceImpl;
import org.activiti.rest.api.cycle.dto.DownloadActionView;
import org.activiti.rest.util.ActivitiRequest;
import org.activiti.rest.util.ActivitiWebScript;
......@@ -39,15 +39,13 @@ public class ArtifactGet extends ActivitiWebScript {
// private static Logger log = Logger.getLogger(ArtifactGet.class.getName());
// private CycleService cycleService;
private RepositoryConnector repositoryConnector;
private CycleService cycleService;
private void init(ActivitiRequest req) {
String cuid = req.getCurrentUserId();
HttpSession session = req.getHttpServletRequest().getSession(true);
// this.cycleService = SessionUtil.getCycleService();
this.repositoryConnector = CycleServiceDbXStreamImpl.getRepositoryConnector(cuid, session);
this.cycleService = CycleServiceImpl.getCycleService(cuid, session);
}
@Override
......@@ -55,11 +53,12 @@ public class ArtifactGet extends ActivitiWebScript {
init(req);
// Retrieve the artifactId from the request
String connectorId = req.getMandatoryString("connectorId");
String artifactId = req.getString("artifactId");
String restProxyUri = req.getString("restProxyUri");
// Retrieve the artifact from the repository
RepositoryArtifact artifact = this.repositoryConnector.getRepositoryArtifact(artifactId);
RepositoryArtifact artifact = this.cycleService.getRepositoryArtifact(connectorId, artifactId);
List<String> contentRepresentations = new ArrayList<String>();
for (ContentRepresentation representation : artifact.getArtifactType().getContentRepresentations()) {
......@@ -74,8 +73,8 @@ public class ArtifactGet extends ActivitiWebScript {
List<DownloadActionView> downloads = new ArrayList<DownloadActionView>();
for (DownloadContentAction action : artifact.getArtifactType().getDownloadContentActions()) {
try {
String url = restProxyUri + "content?artifactId=" + URLEncoder.encode(artifactId, "UTF-8") + "&contentRepresentationId="
+ URLEncoder.encode(action.getContentRepresentation().getId(), "UTF-8");
String url = restProxyUri + "content?connectorId=" + URLEncoder.encode(connectorId, "UTF-8") + "&artifactId=" + URLEncoder.encode(artifactId, "UTF-8")
+ "&contentRepresentationId=" + URLEncoder.encode(action.getContentRepresentation().getId(), "UTF-8");
downloads.add(new DownloadActionView(action.getId(), url, action.getContentRepresentation().getMimeType().getContentType(), action
.getContentRepresentation().getId()));
} catch (UnsupportedEncodingException e) {
......@@ -87,6 +86,7 @@ public class ArtifactGet extends ActivitiWebScript {
model.put("downloads", downloads);
model.put("links", artifact.getOpenLinkActions());
model.put("artifactId", artifact.getCurrentPath());
model.put("artifactId", artifact.getOriginalNodeId());
model.put("connectorId", artifact.getConnectorId());
}
}
package org.activiti.rest.api.cycle;
public class ArtifactLinksGet {
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.activiti.cycle.CycleService;
import org.activiti.cycle.impl.CycleServiceImpl;
import org.activiti.rest.util.ActivitiRequest;
import org.activiti.rest.util.ActivitiWebScript;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Status;
public class ArtifactLinksGet extends ActivitiWebScript {
private CycleService cycleService;
private void init(ActivitiRequest req) {
String cuid = req.getCurrentUserId();
HttpSession session = req.getHttpServletRequest().getSession(true);
this.cycleService = CycleServiceImpl.getCycleService(cuid, session);
}
@Override
protected void executeWebScript(ActivitiRequest req, Status status, Cache cache, Map<String, Object> model) {
init(req);
String artifactId = req.getString("artifactId");
String restProxyUri = req.getString("restProxyUri");
// List<Artifact> link = this.cycleService.getArtifactLinks(artifactId);
}
}
......@@ -19,12 +19,12 @@ import java.util.logging.Logger;
import javax.servlet.http.HttpSession;
import org.activiti.cycle.CycleService;
import org.activiti.cycle.RepositoryArtifact;
import org.activiti.cycle.RepositoryConnector;
import org.activiti.cycle.RepositoryException;
import org.activiti.cycle.RepositoryFolder;
import org.activiti.cycle.RepositoryNodeCollection;
import org.activiti.cycle.impl.db.CycleServiceDbXStreamImpl;
import org.activiti.cycle.impl.CycleServiceImpl;
import org.activiti.rest.util.ActivitiRequest;
import org.activiti.rest.util.ActivitiWebScript;
import org.springframework.extensions.webscripts.Cache;
......@@ -37,15 +37,13 @@ public class ChildNodesGet extends ActivitiWebScript {
private static Logger log = Logger.getLogger(ChildNodesGet.class.getName());
// private CycleService cycleService;
private RepositoryConnector repositoryConnector;
private CycleService cycleService;
private void init(ActivitiRequest req) {
String cuid = req.getCurrentUserId();
HttpSession session = req.getHttpServletRequest().getSession(true);
// this.cycleService = SessionUtil.getCycleService();
this.repositoryConnector = CycleServiceDbXStreamImpl.getRepositoryConnector(cuid, session);
this.cycleService = CycleServiceImpl.getCycleService(cuid, session);
}
@Override
......@@ -53,8 +51,9 @@ public class ChildNodesGet extends ActivitiWebScript {
init(req);
String artifactId = req.getMandatoryString("artifactId");
String connectorId = req.getMandatoryString("connectorId");
try {
RepositoryNodeCollection children = this.repositoryConnector.getChildren(artifactId);
RepositoryNodeCollection children = this.cycleService.getChildren(connectorId, artifactId);
model.put("files", children.getArtifactList());
model.put("folders", children.getFolderList());
......
......@@ -19,9 +19,9 @@ import javax.servlet.http.HttpSession;
import org.activiti.cycle.ContentRepresentation;
import org.activiti.cycle.CycleDefaultMimeType;
import org.activiti.cycle.CycleService;
import org.activiti.cycle.RepositoryArtifact;
import org.activiti.cycle.RepositoryConnector;
import org.activiti.cycle.impl.db.CycleServiceDbXStreamImpl;
import org.activiti.cycle.impl.CycleServiceImpl;
import org.activiti.rest.util.ActivitiRequest;
import org.activiti.rest.util.ActivitiStreamingWebScript;
import org.springframework.extensions.webscripts.WebScriptResponse;
......@@ -31,15 +31,13 @@ import org.springframework.extensions.webscripts.WebScriptResponse;
*/
public class ContentGet extends ActivitiStreamingWebScript {
// private CycleService cycleService;
private RepositoryConnector repositoryConnector;
private CycleService cycleService;
private void init(ActivitiRequest req) {
String cuid = req.getCurrentUserId();
HttpSession session = req.getHttpServletRequest().getSession(true);
// this.cycleService = SessionUtil.getCycleService();
this.repositoryConnector = CycleServiceDbXStreamImpl.getRepositoryConnector(cuid, session);
this.cycleService = CycleServiceImpl.getCycleService(cuid, session);
}
@Override
......@@ -47,11 +45,12 @@ public class ContentGet extends ActivitiStreamingWebScript {
init(req);
// Retrieve the artifactId from the request
String cnonectorId = req.getMandatoryString("connectorId");
String artifactId = req.getMandatoryString("artifactId");
String contentRepresentationId = req.getMandatoryString("contentRepresentationId");
// Retrieve the artifact from the repository
RepositoryArtifact artifact = repositoryConnector.getRepositoryArtifact(artifactId);
RepositoryArtifact artifact = cycleService.getRepositoryArtifact(cnonectorId, artifactId);
ContentRepresentation contentRepresentation = artifact.getArtifactType().getContentRepresentation(contentRepresentationId);
......@@ -83,7 +82,7 @@ public class ContentGet extends ActivitiStreamingWebScript {
}
// TODO: what is a good way to determine the etag? Using a fake one...
streamResponse(res, repositoryConnector.getContent(artifact.getCurrentPath(), contentRepresentation.getId()).asInputStream(), new Date(0),
streamResponse(res, this.cycleService.getContent(artifact.getConnectorId(), artifact.getOriginalNodeId(), contentRepresentation.getId()).asInputStream(), new Date(0),
"W/\"647-1281077702000\"", attach, attachmentFileName, contentType);
}
......
......@@ -2,7 +2,6 @@ package org.activiti.rest.api.cycle;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URLEncoder;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -10,10 +9,9 @@ import java.util.logging.Logger;
import javax.servlet.http.HttpSession;
import org.activiti.cycle.ContentRepresentation;
import org.activiti.cycle.RenderInfo;
import org.activiti.cycle.CycleService;
import org.activiti.cycle.RepositoryArtifact;
import org.activiti.cycle.RepositoryConnector;
import org.activiti.cycle.impl.db.CycleServiceDbXStreamImpl;
import org.activiti.cycle.impl.CycleServiceImpl;
import org.activiti.rest.util.ActivitiRequest;
import org.activiti.rest.util.ActivitiWebScript;
import org.springframework.extensions.webscripts.Cache;
......@@ -23,45 +21,42 @@ public class ContentRepresentationGet extends ActivitiWebScript {
private static Logger log = Logger.getLogger(ContentRepresentationGet.class.getName());
// private CycleService cycleService;
private RepositoryConnector repositoryConnector;
private CycleService cycleService;
private void init(ActivitiRequest req) {
String cuid = req.getCurrentUserId();
HttpSession session = req.getHttpServletRequest().getSession(true);
// this.cycleService = SessionUtil.getCycleService();
this.repositoryConnector = CycleServiceDbXStreamImpl.getRepositoryConnector(cuid, session);
this.cycleService = CycleServiceImpl.getCycleService(cuid, session);
}
@Override
protected void executeWebScript(ActivitiRequest req, Status status, Cache cache, Map<String, Object> model) {
init(req);
String connectorId = req.getMandatoryString("connectorId");
String artifactId = req.getString("artifactId");
String representationId = req.getString("representationId");
String restProxyUri = req.getString("restProxyUri");
RepositoryArtifact artifact = this.repositoryConnector.getRepositoryArtifact(artifactId);
RepositoryArtifact artifact = this.cycleService.getRepositoryArtifact(connectorId, artifactId);
// Get representation by id to determine whether it is an image...
try {
ContentRepresentation contentRepresentation = artifact.getArtifactType().getContentRepresentation(representationId);
switch (contentRepresentation.getRenderInfo()) {
case IMAGE:
model.put("renderInfo", RenderInfo.IMAGE.name());
String imageUrl = restProxyUri + "content?artifactId=" + URLEncoder.encode(artifactId, "UTF-8") + "&contentRepresentationId="
+ URLEncoder.encode(contentRepresentation.getId(), "UTF-8");
model.put("imageUrl", imageUrl);
case HTML:
// For images and HTML we don't need to send the content, the URL will be put together in the UI
// and the content will be requested via ContentGet.
break;
case BINARY:
case CODE:
case HTML:
case TEXT_PLAIN:
String content = this.repositoryConnector.getContent(artifactId, contentRepresentation.getId()).asString();
String content = this.cycleService.getContent(connectorId, artifactId, contentRepresentation.getId()).asString();
model.put("content", content);
}
model.put("connectorId", connectorId);
model.put("artifactId", artifactId);
model.put("renderInfo", contentRepresentation.getRenderInfo().name());
model.put("contentRepresentationId", contentRepresentation.getId());
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.rest.api.cycle;
import java.io.File;
import javax.servlet.http.HttpSession;
import org.activiti.cycle.Cycle;
import org.activiti.cycle.CycleService;
import org.activiti.cycle.RepositoryConnector;
import org.activiti.cycle.RepositoryException;
import org.activiti.cycle.impl.conf.ConfigurationContainer;
import org.activiti.cycle.impl.connector.demo.DemoConnectorConfiguration;
import org.activiti.cycle.impl.connector.fs.FileSystemConnectorConfiguration;
import org.activiti.cycle.impl.connector.signavio.SignavioConnectorConfiguration;
import org.activiti.cycle.impl.connector.view.RootConnectorConfiguration;
import org.activiti.cycle.impl.db.CycleServiceDbXStreamImpl;
import org.activiti.cycle.impl.plugin.PluginFinder;
public class SessionUtil {
/**
* TODO: Check if list roots can return an empty array
*/
private static final File fsBaseDir = File.listRoots()[0];
public static CycleService getCycleService() {
CycleService cycleService = Cycle.getCycleService();
return cycleService;
}
/**
* need the same method in class {@link CycleServiceDbXStreamImpl}
*/
@Deprecated
public static RepositoryConnector getRepositoryConnector(String currentUserId, HttpSession session) {
String key = currentUserId + "_connector";
RepositoryConnector connector = (RepositoryConnector) session.getAttribute(key);
if (connector == null) {
PluginFinder.registerServletContext(session.getServletContext());
ConfigurationContainer configuration = loadUserConfiguration(currentUserId);
connector = new RootConnectorConfiguration(configuration).createConnector();
// TODO: Correct user / password handling
connector.login(currentUserId, currentUserId);
session.setAttribute(key, connector);
}
return connector;
}
/**
* loads the configuration for this user. If no configuration exists, a demo
* config is created and save to file (this xml can be easily modified later
* on to play around with it).
*
* This is a temporary solution until real persistence for configs is in place
*
* TODO: This should be rewritten as soon as we have real persistence and
* stuff
*/
/**
* need the same method in class {@link CycleServiceDbXStreamImpl}
*/
@Deprecated
public static ConfigurationContainer loadUserConfiguration(String currentUserId) {
CycleService cycleConfigurationService = Cycle.getCycleService(); // new CycleServiceDbXStreamImpl(configBaseDir);
ConfigurationContainer configuration;
try{
configuration = cycleConfigurationService.getConfiguration(currentUserId);
} catch(RepositoryException e) {
configuration = createDefaultDemoConfiguration(currentUserId);
cycleConfigurationService.saveConfiguration(configuration);
}
return configuration;
}
/**
* need the same method in class {@link CycleServiceDbXStreamImpl}
*/
@Deprecated
public static ConfigurationContainer createDefaultDemoConfiguration(String currentUserId) {
ConfigurationContainer configuration = new ConfigurationContainer(currentUserId);
configuration.addRepositoryConnectorConfiguration(new DemoConnectorConfiguration("demo"));
configuration.addRepositoryConnectorConfiguration(new SignavioConnectorConfiguration("signavio", "http://localhost:8080/activiti-modeler/"));
configuration.addRepositoryConnectorConfiguration(new FileSystemConnectorConfiguration("files", fsBaseDir));
return configuration;
}
}
<webscript>
<shortname>Execute an action</shortname>
<description>Executes an action for an artifact</description>
<url>/artifact-action?artifactId={artifactId}&amp;actionName={artifactActionName}</url>
<url>/artifact-action?connectorId={connectorId}&amp;artifactId={artifactId}&amp;actionName={artifactActionName}</url>
<authentication>user</authentication>
<format default="json">argument</format>
</webscript>
\ No newline at end of file
<webscript>
<shortname>Repository Artifact Action Form</shortname>
<description>Returns an artifact action's form</description>
<url>/artifact-action-form?artifactId={artifactId}&amp;actionName={actionName}</url>
<url>/artifact-action-form?connectorId={connectorId}&amp;artifactId={artifactId}&amp;actionName={actionName}</url>
<authentication>user</authentication>
<format default="html">argument</format>
</webscript>
\ No newline at end of file
<webscript>
<shortname>Artifact</shortname>
<description>Returns a json string that contains the URL to an image</description>
<url>/artifact?artifactId={artifactId}</url>
<url>/artifact?connectorId={connectorId}&amp;artifactId={artifactId}</url>
<authentication>user</authentication>
<format default="json">argument</format>
</webscript>
\ No newline at end of file
<#escape x as jsonUtils.encodeJSONString(x)>
{
"id": "${artifactId}",
"connectorId": "${connectorId}",
"artifactId": "${artifactId}",
"contentRepresentations": [
<#list contentRepresentations as contentRepresentation>
"${contentRepresentation}"
......
<webscript>
<shortname>Child nodes</shortname>
<description>Returns a json representation of tree nodes starting at the node identified by the nodeId parameter</description>
<url>/child-nodes?artifactId={artifactId}</url>
<url>/child-nodes?connectorId={connectorId}&amp;artifactId={artifactId}</url>
<authentication>user</authentication>
<format default="json">argument</format>
</webscript>
\ No newline at end of file
......@@ -7,7 +7,8 @@
<#macro printFolder folder>
{
"label": "${folder.metadata.name}",
"id": "${folder.currentPath}",
"connectorId": "${folder.connectorId}",
"artifactId": "${folder.originalNodeId}",
"folder": "true"
}
</#macro>
......@@ -15,7 +16,8 @@
<#macro printFile file>
{
"label": "${file.metadata.name}",
"id": "${file.currentPath}",
"connectorId": "${file.connectorId}",
"artifactId": "${file.originalNodeId}",
"expanded": "true",
"file": "true",
"contentType": "${file.artifactType.mimeType.contentType}"
......
<webscript>
<shortname>Content Representation</shortname>
<description>Returns the specified content representation of an artifact as HTML</description>
<url>/content-representation?artifactId={artifactId}&amp;representationId={representationId}</url>
<url>/content-representation?connectorId={connectorId}&amp;artifactId={artifactId}&amp;representationId={representationId}</url>
<authentication>user</authentication>
<format default="json">argument</format>
</webscript>
\ No newline at end of file
<#if imageUrl??>
<div id="artifact-image"><img id="${id}" src="${imageUrl}" border=0></img></div>
<#else>
<div id="artifact-source"><pre id="${id}" class="prettyprint lang-${id}" >${content?html}</pre></div>
</#if>
\ No newline at end of file
<#escape x as jsonUtils.encodeJSONString(x)>
{
"connectorId": "${connectorId}",
"artifactId": "${artifactId}",
"renderInfo": "${renderInfo}",
"contentRepresentationId": "${contentRepresentationId}",
"contentType": "${contentType}",
<#if renderInfo == "IMAGE" >
"imageUrl": "${imageUrl}"
<#-- For images we don't need to send the content since it will be requested through a URL and the content.get webscript. -->
<#elseif renderInfo == "HTML">
"content": "${content}"
<#-- For HTML we don't need to send the content since it will be requested through a URL and the content.get webscript. -->
<#else>
<#-- Content for "BINARY", "CODE" or "TEXT_PLAIN" needs to be HTML escaped. -->
"content": "${content?html}"
......
<webscript>
<shortname>Streams an image</shortname>
<description>Streams back the content of an image</description>
<url>/content</url>
<url>/content?connectorId={connectorId}&amp;artifactId={artifactId}</url>
<authentication>user</authentication>
<format default="">argument</format>
</webscript>
......@@ -1164,11 +1164,17 @@ Activiti.widget.PopupManager = function()
onFormEventButtonClick: function Form_onFormEventButtonClick(event, inputEl) {
var me = this;
Activiti.event.fire(Activiti.event.clickFormEventButton, {"callback": function (args) {
var input = Selector.query("input[name=treeTarget]", me.dialog.form, true);
input.value = args.nodeId;
input.type = "hidden";
var connectorIdInput = Selector.query("input[name=targetConnectorId]", me.dialog.form, true);
connectorIdInput.value = args.connectorId;
var targetFolderId = Selector.query("input[name=targetFolderId]", me.dialog.form, true);
targetFolderId.value = args.nodeId;
targetFolderId.type = "hidden";
var formEventValueSpan = Selector.query("span[class=form-Event-value]", me.dialog.form, true);
formEventValueSpan.innerHTML = args.nodeName;
me.doValidate();
}}, null, false);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册