コード例 #1
0
 /**
  * Attempts to create a new project entry in the associated FreeAgent account.
  *
  * <p>Will return null if the project instance provided is null or cannot be saved into the
  * account.
  *
  * @param project The populated project instance.
  * @return The updated project instance or null.
  */
 public FreeAgentProject createProject(FreeAgentProject project) {
   if (project != null) {
     FreeAgentProjectWrapper projectWrapper =
         freeAgentServiceInstance.createProject(new FreeAgentProjectWrapper(project));
     if (projectWrapper != null) {
       return projectWrapper.getProject();
     }
   }
   return null;
 }
コード例 #2
0
  /**
   * Attempts to import a new project into the associated FreeAgent account by deserialising the
   * specified JSON project information and requesting a new project be created.
   *
   * <p>NOTE: The import (creation within FreeAgent) will only be actioned if no URL property is
   * present or if the URL property is not populated. Otherwise null will be returned.
   *
   * @param projectJSON A string containing project information in FreeAgent friendly format.
   * @return The newly populated project instance that has been imported into FreeAgent or null.
   * @throws JsonSyntaxException If the format does not match the FreeAgent V2 Project format.
   */
  public FreeAgentProject importProject(String projectJSON) throws JsonSyntaxException {
    if (projectJSON == null || projectJSON.isEmpty()) {
      return null;
    }

    FreeAgentProject project = buildProject(projectJSON);

    if (project != null && (project.getUrl() == null || project.getUrl().isEmpty())) {
      FreeAgentProjectWrapper projectWrapper =
          freeAgentServiceInstance.createProject(new FreeAgentProjectWrapper(project));

      if (projectWrapper != null) {
        return projectWrapper.getProject();
      }
    }

    return null;
  }