Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed sample using deprecated methods. Slightly improved newer sample. #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.blackducksoftware.sdk.protex.license.LicenseCategory;
import com.blackducksoftware.sdk.protex.project.AnalysisSourceLocation;
import com.blackducksoftware.sdk.protex.project.AnalysisSourceRepository;
import com.blackducksoftware.sdk.protex.project.Project;
import com.blackducksoftware.sdk.protex.project.ProjectApi;
import com.blackducksoftware.sdk.protex.project.ProjectRequest;
import com.blackducksoftware.sdk.protex.project.codetree.CodeTreeApi;
Expand Down Expand Up @@ -165,15 +166,31 @@ public static void main(String[] args) throws Exception {
String projectId = null;

try {
projectId = projectApi.createProject(projectRequest, LicenseCategory.PROPRIETARY);
Project project = projectApi.getProjectByName(projectName);
AnalysisSourceLocation projectSourceLocation = project.getAnalysisSourceLocation();
if (sourceLocation.getHostname().equals(projectSourceLocation.getHostname())
&& sourceLocation.getRepository().equals(projectSourceLocation.getRepository())
&& sourceLocation.getSourcePath().equals(projectSourceLocation.getSourcePath())) {
projectId = project.getProjectId();
System.out.println("Existing project '" + projectName + "' found with source path '" + serverSourceDir + "'");
}
} catch (SdkFault e_) {
try {
projectId = projectApi.createProject(projectRequest, LicenseCategory.PROPRIETARY);
System.out.println("Project '" + projectName + "' created with source path '" + serverSourceDir + "'");
} catch (SdkFault e) {
System.err.println("ProjectApi.createProject() failed");
throw new RuntimeException(e);
}
}

try {
projectApi.updateCaptureOptions(projectId, captureOptions);
} catch (SdkFault e) {
System.err.println("ProjectApi.createProject() failed");
System.err.println("ProjectApi.updateCaptureOptions() failed");
throw new RuntimeException(e);
}

System.out.println("Project '" + projectName + "' created with source path '" + serverSourceDir + "'");

// Start Analysis
try {
projectApi.startAnalysis(projectId, Boolean.FALSE);
Expand Down Expand Up @@ -222,7 +239,7 @@ public static void main(String[] args) throws Exception {
// Get matches to read data about
if (filesWithMatches.isEmpty()) {
System.out
.println("No files with pending ID code matches found to compare. Make sure code matches are set to marked as pending identification");
.println("No files with pending ID code matches found to compare. Make sure code matches are set to marked as pending identification");
} else {
List<CodeMatchDiscovery> discoveries = discoveryApi
.getCodeMatchDiscoveries(projectId, filesWithMatches, Arrays.asList(CodeMatchType.PRECISION));
Expand Down
Loading