コード例 #1
0
  public static void main(String[] args) {
    //		AuthenticationClient authenticationClient = new AuthenticationClient();
    //        SystemUser tempSystemUser = (SystemUser)
    // authenticationClient.isSystemUserPresent(SystemUser.class, "processtestuserid");
    //        if( !(tempSystemUser.getUserid() != null && tempSystemUser.getUserid().length() > 0) )
    //        {
    //            SystemUser systemUser = new SystemUser();
    //            systemUser.setUserid("processtestuserid");
    //            systemUser.setName("processtestusername");
    //            systemUser.setPassword("pwd");
    //            tempSystemUser = (SystemUser)
    // authenticationClient.createSystemUser_XML(SystemUser.class, systemUser);
    //        }
    Constants.ontologyServerURI =
        "http://aufeef.itu.dk:8080/ArchitectureDesignWorkspace/webresources";

    AuthenticationClient authenticationClient = new AuthenticationClient();
    SystemUser systemUser = new SystemUser();
    systemUser.setUserid("processtestuserid");
    systemUser.setPassword("pwd");
    SystemUser tempSystemUser =
        (SystemUser) authenticationClient.getAccessKey_XML(SystemUser.class, systemUser);

    String userId = "processtestuserid";
    String authKey = tempSystemUser.getCurrentAuthKey();

    soapclient.DesignOntology service = new soapclient.DesignOntology();
    soapclient.DesignWorkspaceOntology port = service.getDesignWorkspaceOntologyPort();

    boolean success = port.initWorkspace("ProcessWorkspace");
    System.out.println(success);
    Map<String, Object> req_ctx = ((BindingProvider) port).getRequestContext();
    Map<String, List<String>> headers = new HashMap<String, List<String>>();
    headers.put(Constants.userId, Collections.singletonList(userId));
    headers.put(Constants.authKey, Collections.singletonList(authKey));
    req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
    List<bean.Tool> toolsList = (List) port.getToolsListAvailableForProvisioning("DesignWorkspace");
  }
コード例 #2
0
  @Override
  public List<soapclient.Tool> getToolList(String processId, String userName) {
    initialURI();
    AuthenticationClient authenticationClient = new AuthenticationClient();
    String userId = userName + USERID_PROCESS_POSTFIX;
    String pwd = userName + PASSWORD_PROCESS_POSTFIX;
    // To check whether this user exist, if not, create it
    SystemUser systemUser =
        (SystemUser) authenticationClient.isSystemUserPresent(SystemUser.class, userId);
    if (!(systemUser.getUserid() != null && systemUser.getUserid().length() > 0)) {
      SystemUser tempSystemUser = new SystemUser();
      tempSystemUser.setUserid(userId);
      tempSystemUser.setName(userName);
      tempSystemUser.setPassword(pwd);
      systemUser =
          (SystemUser) authenticationClient.createSystemUser_XML(SystemUser.class, tempSystemUser);
    } else {
      systemUser.setUserid(userId);
      systemUser.setName(userName);
      systemUser.setPassword(pwd);
    }
    // Sign in to tool server, so user get access key to server
    SystemUser authenticatedSystemUser =
        (SystemUser) authenticationClient.getAccessKey_XML(SystemUser.class, systemUser);
    System.out.println("system user" + authenticatedSystemUser.getName());
    String authKey = authenticatedSystemUser.getCurrentAuthKey();

    // initial port
    soapclient.DesignOntology service = new soapclient.DesignOntology();
    soapclient.DesignWorkspaceOntology port = service.getDesignWorkspaceOntologyPort();

    // to initial workspace, if this processName has been used before, the initWorkspace will return
    // false
    String processName = processId + PROCESS_WORKSPACE_POSTFIX;
    port.initWorkspace(processName);

    Map<String, Object> req_ctx = ((BindingProvider) port).getRequestContext();
    Map<String, List<String>> headers = new HashMap<String, List<String>>();
    headers.put(Constants.userId, Collections.singletonList(userId));
    headers.put(Constants.authKey, Collections.singletonList(authKey));
    req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
    List<soapclient.Tool> toolsList =
        (List<soapclient.Tool>) port.getToolsListAvailableForProvisioning(processName);
    return toolsList;
  }