Search in sources :

Example 46 with Project

use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.

the class FossologyAwarePortlet method serveGetSendableReleases.

protected void serveGetSendableReleases(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
    String projectId = request.getParameter(PROJECT_ID);
    User user = UserCacheHolder.getUserFromRequest(request);
    try {
        putReleasesAndProjectIntoRequest(request, projectId, user);
        include("/html/projects/ajax/sendableTable.jsp", request, response, PortletRequest.RESOURCE_PHASE);
    } catch (TException e) {
        log.error("Problem with project client", e);
        throw new PortletException(e);
    }
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) PortletException(javax.portlet.PortletException)

Example 47 with Project

use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.

the class LinkedReleasesAndProjectsAwarePortlet method serveLoadLinkedProjectsRows.

protected void serveLoadLinkedProjectsRows(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
    final User user = UserCacheHolder.getUserFromRequest(request);
    String branchId = request.getParameter(PARENT_BRANCH_ID);
    request.setAttribute(PARENT_BRANCH_ID, branchId);
    if (branchId != null) {
        String id = branchId.split("_")[0];
        try {
            ProjectService.Iface client = thriftClients.makeProjectClient();
            Project project = client.getProjectById(id, user);
            List<ProjectLink> mappedProjectLinks = createLinkedProjects(project, user);
            request.setAttribute(PROJECT_LIST, mappedProjectLinks);
        } catch (TException e) {
            log.error("Error getting projects!", e);
            throw new PortletException("cannot get projects", e);
        }
    } else {
        List<ProjectLink> mappedProjectLinks = createLinkedProjects(new Project(), user);
        request.setAttribute(PROJECT_LIST, mappedProjectLinks);
    }
    request.setAttribute(PortalConstants.PARENT_SCOPE_GROUP_ID, request.getParameter(PortalConstants.PARENT_SCOPE_GROUP_ID));
    include("/html/utils/ajax/linkedProjectsRows.jsp", request, response, PortletRequest.RESOURCE_PHASE);
}
Also used : TException(org.apache.thrift.TException) Project(org.eclipse.sw360.datahandler.thrift.projects.Project) User(org.eclipse.sw360.datahandler.thrift.users.User) ProjectLink(org.eclipse.sw360.datahandler.thrift.projects.ProjectLink) PortletException(javax.portlet.PortletException) ProjectService(org.eclipse.sw360.datahandler.thrift.projects.ProjectService)

Example 48 with Project

use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.

the class ProjectModerationRequestGenerator method setAdditionsAndDeletions.

@Override
public ModerationRequest setAdditionsAndDeletions(ModerationRequest request, Project updateProject, Project actualProject) {
    updateDocument = updateProject;
    actualDocument = actualProject;
    documentAdditions = new Project();
    documentDeletions = new Project();
    // required fields:
    documentAdditions.setName(updateProject.getName());
    documentAdditions.setId(actualProject.getId());
    documentDeletions.setName(actualProject.getName());
    documentDeletions.setId(actualProject.getId());
    for (Project._Fields field : Project._Fields.values()) {
        if (Project.metaDataMap.get(field).valueMetaData.type == TType.BOOL || Project.metaDataMap.get(field).valueMetaData.type == TType.I32) {
            if (actualDocument.getFieldValue(field) != updateDocument.getFieldValue(field)) {
                documentAdditions.setFieldValue(field, updateDocument.getFieldValue(field));
                documentDeletions.setFieldValue(field, actualDocument.getFieldValue(field));
            }
        } else if (actualProject.getFieldValue(field) == null) {
            documentAdditions.setFieldValue(field, updateProject.getFieldValue(field));
        } else if (updateProject.getFieldValue(field) == null) {
            documentDeletions.setFieldValue(field, actualProject.getFieldValue(field));
        } else if (!actualProject.getFieldValue(field).equals(updateProject.getFieldValue(field))) {
            switch(field) {
                // ignored fields and concluded fields
                case PERMISSIONS:
                case DOCUMENT_STATE:
                case RELEASE_CLEARING_STATE_SUMMARY:
                    break;
                case ATTACHMENTS:
                    dealWithAttachments(Project._Fields.ATTACHMENTS);
                    break;
                case LINKED_PROJECTS:
                    dealWithEnumMap(Project._Fields.LINKED_PROJECTS, ProjectRelationship.class);
                    break;
                case RELEASE_ID_TO_USAGE:
                    dealWithStringKeyedMap(Project._Fields.RELEASE_ID_TO_USAGE);
                    break;
                case ROLES:
                    dealWithCustomMap(Project._Fields.ROLES);
                    break;
                default:
                    dealWithBaseTypes(field, Project.metaDataMap.get(field));
            }
        }
    }
    request.setProjectAdditions(documentAdditions);
    request.setProjectDeletions(documentDeletions);
    return request;
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) ProjectRelationship(org.eclipse.sw360.datahandler.thrift.projects.ProjectRelationship)

Example 49 with Project

use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.

the class ProjectHandler method getProjectById.

// //////////////////////////
// GET INDIVIDUAL OBJECTS //
// //////////////////////////
@Override
public Project getProjectById(String id, User user) throws TException {
    assertUser(user);
    assertId(id);
    Project project = handler.getProjectById(id, user);
    assertNotNull(project);
    return project;
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project)

Example 50 with Project

use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.

the class ProjectHandler method getLinkedProjectsById.

@Override
public List<ProjectLink> getLinkedProjectsById(String id, boolean deep, User user) throws TException {
    assertId(id);
    Project project = getProjectById(id, user);
    return getLinkedProjectsOfProject(project, deep, user);
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project)

Aggregations

Project (org.eclipse.sw360.datahandler.thrift.projects.Project)87 User (org.eclipse.sw360.datahandler.thrift.users.User)46 Test (org.junit.Test)42 TException (org.apache.thrift.TException)27 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)16 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)15 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)12 Release (org.eclipse.sw360.datahandler.thrift.components.Release)12 ProjectService (org.eclipse.sw360.datahandler.thrift.projects.ProjectService)10 StringReader (java.io.StringReader)8 ReaderInputStream (org.apache.commons.io.input.ReaderInputStream)8 ProjectLink (org.eclipse.sw360.datahandler.thrift.projects.ProjectLink)8 IOException (java.io.IOException)7 InputStream (java.io.InputStream)7 HashMap (java.util.HashMap)7 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)7 ProjectRelationship (org.eclipse.sw360.datahandler.thrift.projects.ProjectRelationship)6 JSONObject (com.liferay.portal.kernel.json.JSONObject)5 HashSet (java.util.HashSet)5 ResponseEntity (org.springframework.http.ResponseEntity)5