Search in sources :

Example 31 with ModerationRequest

use of org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest 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;
}
Also used : ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Example 32 with ModerationRequest

use of org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest in project sw360portal by sw360.

the class ModerationDatabaseHandler method refuseRequest.

public void refuseRequest(String requestId, String moderationDecisionComment, String reviewer) {
    ModerationRequest request = repository.get(requestId);
    request.setModerationState(ModerationState.REJECTED);
    request.setTimestampOfDecision(System.currentTimeMillis());
    request.setCommentDecisionModerator(moderationDecisionComment);
    request.setReviewer(reviewer);
    repository.update(request);
    sendMailToUserForDeclinedRequest(request);
}
Also used : ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Example 33 with ModerationRequest

use of org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest 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;
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest) SW360Exception(org.eclipse.sw360.datahandler.thrift.SW360Exception)

Example 34 with ModerationRequest

use of org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest in project sw360portal by sw360.

the class ModerationHandler method cancelInProgress.

@Override
public void cancelInProgress(String requestId) throws TException {
    ModerationRequest request = handler.getRequest(requestId);
    request.setModerationState(ModerationState.PENDING);
    request.unsetReviewer();
    handler.updateModerationRequest(request);
}
Also used : ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Aggregations

ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)24 TException (org.apache.thrift.TException)11 User (org.eclipse.sw360.datahandler.thrift.users.User)8 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)5 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)4 Component (org.eclipse.sw360.datahandler.thrift.components.Component)4 ModerationService (org.eclipse.sw360.datahandler.thrift.moderation.ModerationService)4 Release (org.eclipse.sw360.datahandler.thrift.components.Release)3 License (org.eclipse.sw360.datahandler.thrift.licenses.License)3 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)2 Organization (com.liferay.portal.model.Organization)1 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)1 TProtocol (org.apache.thrift.protocol.TProtocol)1 THttpClient (org.apache.thrift.transport.THttpClient)1 CommonUtils.isTemporaryTodo (org.eclipse.sw360.datahandler.common.CommonUtils.isTemporaryTodo)1 DatabaseConnector (org.eclipse.sw360.datahandler.couchdb.DatabaseConnector)1 DocumentState (org.eclipse.sw360.datahandler.thrift.DocumentState)1 COTSDetails (org.eclipse.sw360.datahandler.thrift.components.COTSDetails)1 LicenseService (org.eclipse.sw360.datahandler.thrift.licenses.LicenseService)1 Obligation (org.eclipse.sw360.datahandler.thrift.licenses.Obligation)1