Exemplo n.º 1
0
  /** @see FlowService#createNewFlow(Credentials, Flow, HashMap, String, long) */
  @Override
  public Flow createNewFlow(
      Credentials credentials,
      Flow flow,
      HashMap<String, String> paramMap,
      String flowUri,
      long userId) {
    String result = null;
    try {
      result = headServer.createFlow(credentials, paramMap, flowUri, userId);
      byte[] flowContent = readFileAsBytes(result);

      assert getArtifactService() != null : "Artifact service is null.";
      assert flow != null : "Flow is null.";
      assert credentials != null : "Credentials are null.";
      assert flowContent != null : "Flowcontent is null.";

      String id = UUID.randomUUID().toString();
      ResourcePath resourcePath =
          getArtifactService().saveFlow((SimpleCredentials) credentials, flow, id, flowContent);

      String uri =
          resourcePath.getProtocol()
              + ":"
              + resourcePath.getWorkspace()
              + "://"
              + resourcePath.getPath();
      flow.setUri(uri);

      storeFlowInstance(flow);
    } catch (MeandreServerException e) {
      throw new ServiceException("Could not create flow: " + flowUri, e);
    } catch (ContentRepositoryServiceException e) {
      throw new ServiceException("Could not create flow: " + flowUri, e);
    } catch (IOException e) {
      throw new ServiceException("Could not create flow: " + flowUri, e);
    }
    return flow;
  }
Exemplo n.º 2
0
 /** @see FlowService#storeFlowInstance(Flow) */
 public Long storeFlowInstance(Flow instance) {
   FlowDao flowDao = daoFactory.getFlowDao();
   flowDao.makePersistent(instance);
   return instance.getId();
 }