use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class FossologyHandlerTest method testSendToFossology.
@Test
public void testSendToFossology() throws Exception {
final String releaseId = "a";
final String clearingTeam = "b";
final RequestStatus requestStatus = RequestStatus.FAILURE;
doReturn(requestStatus).when(fossologyFileHandler).sendToFossology(releaseId, user, clearingTeam);
assertThat(fossologyHandler.sendToFossology(releaseId, user, clearingTeam), sameInstance(requestStatus));
verify(fossologyFileHandler).sendToFossology(releaseId, user, clearingTeam);
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class CveSearchHandler method update.
@Override
public RequestStatus update() throws TException {
log.info("Starting CveSearch update...");
VulnerabilityUpdateStatus vulnerabilityUpdateStatus = fullUpdate();
log.info("CveSearch update finished with status:" + vulnerabilityUpdateStatus.getRequestStatus());
log.info("The following vulnerability/ies could not be imported:" + vulnerabilityUpdateStatus.getStatusToVulnerabilityIds().get(UpdateType.FAILED) + "\n" + "The following vulnerability/ies were updated:" + vulnerabilityUpdateStatus.getStatusToVulnerabilityIds().get(UpdateType.UPDATED) + "\n" + "The following vulnerability/ies were added:" + vulnerabilityUpdateStatus.getStatusToVulnerabilityIds().get(UpdateType.NEW));
return vulnerabilityUpdateStatus.getRequestStatus();
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class FossologyFileHandler method sendToFossology.
public RequestStatus sendToFossology(String releaseId, User user, String clearingTeam) throws TException {
Release release;
final ComponentService.Iface componentClient = thriftClients.makeComponentClient();
release = getReleaseAndUnlockIt(releaseId, user, componentClient);
Set<Attachment> sourceAttachments = getSourceAttachment(releaseId, user, componentClient);
if (sourceAttachments.size() != 1) {
log.error("release " + releaseId + " does not have a single source attachment");
// TODO return a summary and better fitting status
return RequestStatus.FAILURE;
}
final Attachment attachment = getFirst(sourceAttachments);
final FilledAttachment filledAttachment = fillAttachment(attachment);
if (!release.isSetFossologyId()) {
/* send the attachment as a new upload */
AttachmentContent attachmentContent = filledAttachment.getAttachmentContent();
return sendToFossologyNewUpload(release, user, clearingTeam, attachmentContent, componentClient);
} else {
if (!checkSourceAttachment(release, filledAttachment)) {
// TODO summary
return RequestStatus.FAILURE;
} else {
/* duplicate the old upload making it visible for clearingTeam */
return sendToFossologyExistingUpload(release, user, clearingTeam, componentClient);
}
}
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class VulnerabilityConnector method addOrUpdate.
public UpdateType addOrUpdate(Vulnerability vulnerability, ReleaseVulnerabilityRelation partiallyFilledRelation) {
RequestStatus vulRequestStatus = RequestStatus.SUCCESS;
UpdateType updateType;
Vulnerability dbVulnerability = vulnerabilityDatabaseHandler.getByExternalId(Vulnerability.class, vulnerability.getExternalId());
if (dbVulnerability != null) {
if (isMoreRecent(vulnerability, dbVulnerability)) {
updateType = UpdateType.UPDATED;
dbVulnerability = VulnerabilityMapper.updateFromVulnerability(dbVulnerability, vulnerability);
vulRequestStatus = vulnerabilityDatabaseHandler.update(dbVulnerability);
} else {
updateType = UpdateType.OLD;
}
} else {
updateType = UpdateType.NEW;
vulRequestStatus = vulnerabilityDatabaseHandler.add(vulnerability);
dbVulnerability = vulnerability;
}
if (RequestStatus.FAILURE.equals(vulRequestStatus)) {
return UpdateType.FAILED;
}
partiallyFilledRelation.setVulnerabilityId(dbVulnerability.getId());
RequestStatus requestStatus = addOrUpdate(partiallyFilledRelation);
if (RequestStatus.FAILURE.equals(requestStatus)) {
return UpdateType.FAILED;
}
return updateType;
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ProjectDatabaseHandlerTest method testSanityCheckSucceeds.
@Test
public void testSanityCheckSucceeds() throws Exception {
Project project = handler.getProjectById("P1", user1);
project.setReleaseIdToUsage(ImmutableMap.<String, ProjectReleaseRelationship>builder().put("r1", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r2", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r3", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).build());
RequestStatus status = handler.updateProject(project, user1);
assertThat(status, is(RequestStatus.SUCCESS));
Project project2 = handler.getProjectById("P2", user1);
project2.setReleaseIdToUsage(Collections.emptyMap());
RequestStatus status2 = handler.updateProject(project2, user1);
assertThat(status2, is(RequestStatus.SUCCESS));
}
Aggregations