use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ProjectHandlerTest method testDeleteProject2_2.
@Test(expected = Exception.class)
public void testDeleteProject2_2() throws Exception {
RequestStatus status = handler.deleteProject("P2", user2);
assertEquals(RequestStatus.SUCCESS, status);
assertEquals(1, handler.getMyProjects(user1.getEmail()).size());
assertEquals(0, handler.getMyProjects(user2.getEmail()).size());
assertEquals(1, handler.getMyProjects(user3.getEmail()).size());
assertEquals(2, handler.getAccessibleProjectsSummary(user1).size());
assertEquals(0, handler.getAccessibleProjectsSummary(user2).size());
assertEquals(2, handler.getAccessibleProjectsSummary(user3).size());
boolean deleted = (handler.getProjectById("P2", user2) == null);
assertEquals(true, deleted);
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class FossologyFileHandler method sendToFossologyExistingUpload.
private RequestStatus sendToFossologyExistingUpload(Release release, User user, String clearingTeam, ComponentService.Iface componentClient) throws TException {
int fossologyUploadId;
fossologyUploadId = toUnsignedInt(release.getFossologyId());
failIf(fossologyUploadId <= 0, "release %s has an inconsistent FossologyId", release.getId());
FossologyStatus currentStatus = fossologyUploader.getStatusInFossology(fossologyUploadId, clearingTeam);
if (isVisible(currentStatus)) {
updateFossologyStatus(release, user, clearingTeam, currentStatus, componentClient);
return RequestStatus.SUCCESS;
} else {
return duplicateUploadFor(release, user, clearingTeam, fossologyUploadId, componentClient);
}
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class FossologyScriptsHandler method deployScripts.
public RequestStatus deployScripts() throws SW360Exception {
RequestStatus status = RequestStatus.SUCCESS;
for (String scriptFileName : SCRIPT_FILE_NAMES) {
final InputStream inputStream = FossologyScriptsHandler.class.getResourceAsStream(SCRIPTS_FOLDER + scriptFileName);
if (inputStream == null) {
log.error("cannot get content of script " + scriptFileName);
status = RequestStatus.FAILURE;
continue;
}
try {
if (!fossologyUploader.copyToFossology(scriptFileName, inputStream, true)) {
status = RequestStatus.FAILURE;
}
} finally {
closeQuietly(inputStream, log);
}
}
return status;
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ModerationDatabaseHandler method deleteModerationRequest.
public RequestStatus deleteModerationRequest(String id, User user) {
ModerationRequest moderationRequest = repository.get(id);
if (moderationRequest != null) {
if (hasPermissionToDeleteModerationRequest(user, moderationRequest)) {
boolean succeeded = repository.remove(id);
return succeeded ? RequestStatus.SUCCESS : RequestStatus.FAILURE;
} else {
log.error("Problems deleting moderation request: User " + user.getEmail() + " tried to delete " + "moderation request of user " + moderationRequest.getRequestingUser());
return RequestStatus.FAILURE;
}
}
log.error("Moderation request to delete was null.");
return RequestStatus.FAILURE;
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ModerationDatabaseHandler method createRequest.
public RequestStatus createRequest(Project project, User user, Boolean isDeleteRequest) {
Project dbproject;
try {
dbproject = projectDatabaseHandler.getProjectById(project.getId(), user);
} catch (SW360Exception e) {
log.error("Could not get original project from database. Could not generate moderation request.", e);
return RequestStatus.FAILURE;
}
// Define moderators
Set<String> moderators = getProjectModerators(dbproject);
ModerationRequest request = createStubRequest(user, isDeleteRequest, project.getId(), moderators);
// Set meta-data
request.setDocumentType(DocumentType.PROJECT);
request.setDocumentName(SW360Utils.printName(dbproject));
// Fill the request
ModerationRequestGenerator generator = new ProjectModerationRequestGenerator();
request = generator.setAdditionsAndDeletions(request, project, dbproject);
addOrUpdate(request, user);
return RequestStatus.SENT_TO_MODERATOR;
}
Aggregations