List of usage examples for com.amazonaws.services.codebuild.model ListProjectsResult getNextToken
public String getNextToken()
If there are more than 100 items in the list, only the first 100 items are returned, along with a unique string called a nextToken.
From source file:ProjectFactory.java
License:Open Source License
public String createProject(String projectName, String description, ProjectSource source, ProjectArtifacts artifacts, ProjectEnvironment environment, String serviceIAMRole, String timeout, String encryptionKey) throws Exception { ListProjectsRequest lpRequest;//w w w .j a va2 s .c o m ListProjectsResult lpResult; List<String> projects = new ArrayList<String>(); String nextToken = null; do { lpRequest = new ListProjectsRequest().withNextToken(nextToken); lpResult = cbClient.listProjects(lpRequest); nextToken = lpResult.getNextToken(); projects.addAll(lpResult.getProjects()); } while (nextToken != null); if (projects.contains(projectName)) { UpdateProjectResult upResult = cbClient.updateProject( new UpdateProjectRequest().withName(projectName).withDescription(description).withSource(source) .withArtifacts(artifacts).withEnvironment(environment).withServiceRole(serviceIAMRole) .withTimeoutInMinutes(Validation.parseInt(timeout)).withEncryptionKey(encryptionKey)); return upResult.getProject().getName(); } else { CreateProjectResult cpResult = cbClient.createProject( new CreateProjectRequest().withName(projectName).withDescription(description).withSource(source) .withArtifacts(artifacts).withEnvironment(environment).withServiceRole(serviceIAMRole) .withTimeoutInMinutes(Validation.parseInt(timeout)).withEncryptionKey(encryptionKey)); return cpResult.getProject().getName(); } }