Search in sources :

Example 71 with Group

use of org.orcid.jaxb.model.record_v2.Group in project oxTrust by GluuFederation.

the class GroupWebService method searchGroups.

@GET
@Produces({ Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8", MediaType.APPLICATION_JSON + "; charset=utf-8" })
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
@ApiOperation(value = "Search groups", notes = "Returns a list of groups (https://tools.ietf.org/html/rfc7644#section-3.4.2.2)", response = ListResponse.class)
public Response searchGroups(@HeaderParam("Authorization") String authorization, @QueryParam(OxTrustConstants.QUERY_PARAMETER_TEST_MODE_OAUTH2_TOKEN) final String token, @QueryParam(OxTrustConstants.QUERY_PARAMETER_FILTER) final String filterString, @QueryParam(OxTrustConstants.QUERY_PARAMETER_START_INDEX) final int startIndex, @QueryParam(OxTrustConstants.QUERY_PARAMETER_COUNT) final int count, @QueryParam(OxTrustConstants.QUERY_PARAMETER_SORT_BY) final String sortBy, @QueryParam(OxTrustConstants.QUERY_PARAMETER_SORT_ORDER) final String sortOrder, @QueryParam(OxTrustConstants.QUERY_PARAMETER_ATTRIBUTES) final String attributesArray) throws Exception {
    Response authorizationResponse;
    if (jsonConfigurationService.getOxTrustappConfiguration().isScimTestMode()) {
        log.info(" ##### SCIM Test Mode is ACTIVE");
        authorizationResponse = processTestModeAuthorization(token);
    } else {
        authorizationResponse = processAuthorization(authorization);
    }
    if (authorizationResponse != null) {
        return authorizationResponse;
    }
    try {
        if (count > getMaxCount()) {
            String detail = "Too many results (=" + count + ") would be returned; max is " + getMaxCount() + " only.";
            return getErrorResponse(Response.Status.BAD_REQUEST, ErrorScimType.TOO_MANY, detail);
        } else {
            log.info(" Searching groups from LDAP ");
            VirtualListViewResponse vlvResponse = new VirtualListViewResponse();
            List<GluuGroup> groupList = search(groupService.getDnForGroup(null), GluuGroup.class, filterString, startIndex, count, sortBy, sortOrder, vlvResponse, attributesArray);
            // List<GluuGroup> groupList = groupService.getAllGroupsList();
            ListResponse groupsListResponse = new ListResponse();
            List<String> schema = new ArrayList<String>();
            schema.add(Constants.LIST_RESPONSE_SCHEMA_ID);
            log.info(" setting schema");
            groupsListResponse.setSchemas(schema);
            // Set total
            groupsListResponse.setTotalResults(vlvResponse.getTotalResults());
            if (count > 0 && groupList != null && !groupList.isEmpty()) {
                for (GluuGroup gluuGroup : groupList) {
                    Group group = copyUtils2.copy(gluuGroup, null);
                    log.info(" group to be added displayName : " + group.getDisplayName());
                    groupsListResponse.getResources().add(group);
                    log.info(" group added? : " + groupsListResponse.getResources().contains(group));
                }
                // Set the rest of results info
                groupsListResponse.setItemsPerPage(vlvResponse.getItemsPerPage());
                groupsListResponse.setStartIndex(vlvResponse.getStartIndex());
            }
            // Serialize to JSON
            String json = serializeToJson(groupsListResponse, attributesArray);
            URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/Groups");
            return Response.ok(json).location(location).build();
        }
    } catch (Exception ex) {
        log.error("Error in searchGroups", ex);
        ex.printStackTrace();
        return getErrorResponse(Response.Status.BAD_REQUEST, ErrorScimType.INVALID_FILTER, INTERNAL_SERVER_ERROR_MESSAGE);
    }
}
Also used : VirtualListViewResponse(org.xdi.ldap.model.VirtualListViewResponse) ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) Response(javax.ws.rs.core.Response) GluuGroup(org.gluu.oxtrust.model.GluuGroup) Group(org.gluu.oxtrust.model.scim2.Group) ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) VirtualListViewResponse(org.xdi.ldap.model.VirtualListViewResponse) ArrayList(java.util.ArrayList) GluuGroup(org.gluu.oxtrust.model.GluuGroup) URI(java.net.URI) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) DuplicateEntryException(org.gluu.site.ldap.exception.DuplicateEntryException) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(com.wordnik.swagger.annotations.ApiOperation)

Example 72 with Group

use of org.orcid.jaxb.model.record_v2.Group in project oxTrust by GluuFederation.

the class GroupWebService method createGroup.

@POST
@Consumes({ Constants.MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON })
@Produces({ Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8", MediaType.APPLICATION_JSON + "; charset=utf-8" })
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
@ApiOperation(value = "Create group", notes = "Create group (https://tools.ietf.org/html/rfc7644#section-3.3)", response = Group.class)
public Response createGroup(@HeaderParam("Authorization") String authorization, @QueryParam(OxTrustConstants.QUERY_PARAMETER_TEST_MODE_OAUTH2_TOKEN) final String token, @ApiParam(value = "Group", required = true) Group group, @QueryParam(OxTrustConstants.QUERY_PARAMETER_ATTRIBUTES) final String attributesArray) throws Exception {
    Response authorizationResponse;
    if (jsonConfigurationService.getOxTrustappConfiguration().isScimTestMode()) {
        log.info(" ##### SCIM Test Mode is ACTIVE");
        authorizationResponse = processTestModeAuthorization(token);
    } else {
        authorizationResponse = processAuthorization(authorization);
    }
    if (authorizationResponse != null) {
        return authorizationResponse;
    }
    try {
        Group createdGroup = scim2GroupService.createGroup(group);
        // Serialize to JSON
        String json = serializeToJson(createdGroup, attributesArray);
        URI location = new URI(createdGroup.getMeta().getLocation());
        // Return HTTP response with status code 201 Created
        return Response.created(location).entity(json).build();
    } catch (DuplicateEntryException ex) {
        log.error("DuplicateEntryException", ex);
        ex.printStackTrace();
        return getErrorResponse(Response.Status.CONFLICT, ErrorScimType.UNIQUENESS, ex.getMessage());
    } catch (Exception ex) {
        log.error("Failed to create group", ex);
        ex.printStackTrace();
        return getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, INTERNAL_SERVER_ERROR_MESSAGE);
    }
}
Also used : VirtualListViewResponse(org.xdi.ldap.model.VirtualListViewResponse) ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) Response(javax.ws.rs.core.Response) GluuGroup(org.gluu.oxtrust.model.GluuGroup) Group(org.gluu.oxtrust.model.scim2.Group) DuplicateEntryException(org.gluu.site.ldap.exception.DuplicateEntryException) URI(java.net.URI) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) DuplicateEntryException(org.gluu.site.ldap.exception.DuplicateEntryException) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(com.wordnik.swagger.annotations.ApiOperation)

Example 73 with Group

use of org.orcid.jaxb.model.record_v2.Group in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method revisitGroups.

public void revisitGroups(Definitions def) {
    List<RootElement> rootElements = def.getRootElements();
    Category defaultCat = Bpmn2Factory.eINSTANCE.createCategory();
    defaultCat.setName("default");
    for (RootElement root : rootElements) {
        if (root instanceof Process) {
            Process process = (Process) root;
            List<Artifact> processArtifacts = process.getArtifacts();
            if (processArtifacts != null) {
                for (Artifact ar : processArtifacts) {
                    if (ar instanceof Group) {
                        Group group = (Group) ar;
                        Iterator<FeatureMap.Entry> iter = group.getAnyAttribute().iterator();
                        while (iter.hasNext()) {
                            FeatureMap.Entry entry = iter.next();
                            if (entry.getEStructuralFeature().getName().equals("categoryval")) {
                                CategoryValue catval = Bpmn2Factory.eINSTANCE.createCategoryValue();
                                catval.setValue((String) entry.getValue());
                                defaultCat.getCategoryValue().add(catval);
                                group.setCategoryValueRef(catval);
                            }
                        }
                    }
                }
            }
        }
    }
    // only add category if it includes at least one categoryvalue
    if (defaultCat.getCategoryValue() != null && defaultCat.getCategoryValue().size() > 0) {
        rootElements.add(defaultCat);
    }
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Group(org.eclipse.bpmn2.Group) Entry(java.util.Map.Entry) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) RootElement(org.eclipse.bpmn2.RootElement) Category(org.eclipse.bpmn2.Category) CategoryValue(org.eclipse.bpmn2.CategoryValue) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) Artifact(org.eclipse.bpmn2.Artifact)

Example 74 with Group

use of org.orcid.jaxb.model.record_v2.Group in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method createDiagram.

private void createDiagram(Definitions def) {
    for (RootElement rootElement : def.getRootElements()) {
        if (rootElement instanceof Process) {
            Process process = (Process) rootElement;
            BpmnDiFactory factory = BpmnDiFactory.eINSTANCE;
            BPMNDiagram diagram = factory.createBPMNDiagram();
            BPMNPlane plane = factory.createBPMNPlane();
            plane.setBpmnElement(process);
            diagram.setPlane(plane);
            // first process flowNodes
            for (FlowElement flowElement : process.getFlowElements()) {
                if (flowElement instanceof FlowNode) {
                    createBpmnShapeForElement(factory, plane, flowElement);
                    if (flowElement instanceof BoundaryEvent) {
                        createDockersForBoundaryEvent((BoundaryEvent) flowElement);
                    }
                    // check if its a subprocess
                    if (flowElement instanceof SubProcess) {
                        createSubProcessDiagram(plane, flowElement, factory);
                    }
                } else if (flowElement instanceof DataObject) {
                    createBpmnShapeForElement(factory, plane, flowElement);
                } else if (flowElement instanceof SequenceFlow) {
                    createBpmnEdgeForSequenceFlow(factory, plane, (SequenceFlow) flowElement);
                }
            }
            // then process artifacts
            if (process.getArtifacts() != null) {
                List<Association> incompleteAssociations = new ArrayList<Association>();
                for (Artifact artifact : process.getArtifacts()) {
                    // if (artifact instanceof TextAnnotation || artifact instanceof Group) {
                    if (artifact instanceof Group) {
                        createBpmnShapeForElement(factory, plane, artifact);
                    }
                    if (artifact instanceof Association) {
                        Association association = (Association) artifact;
                        if (association.getSourceRef() != null && association.getTargetRef() != null) {
                            createBpmnEdgeForAssociation(factory, plane, association);
                        } else {
                            incompleteAssociations.add(association);
                        }
                    }
                }
                if (!incompleteAssociations.isEmpty()) {
                    for (Association incompleteAssociation : incompleteAssociations) {
                        process.getArtifacts().remove(incompleteAssociation);
                    }
                }
            }
            // finally process lanes
            if (process.getLaneSets() != null && process.getLaneSets().size() > 0) {
                for (LaneSet ls : process.getLaneSets()) {
                    for (Lane lane : ls.getLanes()) {
                        createBpmnShapeForElement(factory, plane, lane);
                    }
                }
            }
            def.getDiagrams().add(diagram);
        }
    }
}
Also used : AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Group(org.eclipse.bpmn2.Group) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) ArrayList(java.util.ArrayList) Lane(org.eclipse.bpmn2.Lane) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) LaneSet(org.eclipse.bpmn2.LaneSet) BpmnDiFactory(org.eclipse.bpmn2.di.BpmnDiFactory) Artifact(org.eclipse.bpmn2.Artifact) BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) RootElement(org.eclipse.bpmn2.RootElement) DataObject(org.eclipse.bpmn2.DataObject) Association(org.eclipse.bpmn2.Association) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) FlowElement(org.eclipse.bpmn2.FlowElement) BPMNPlane(org.eclipse.bpmn2.di.BPMNPlane) FlowNode(org.eclipse.bpmn2.FlowNode)

Example 75 with Group

use of org.orcid.jaxb.model.record_v2.Group in project ORCID-Source by ORCID.

the class Api2_0_rc4_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(GroupsContainer groupsContainerRc4) {
    if (groupsContainerRc4.retrieveGroups() != null && !groupsContainerRc4.retrieveGroups().isEmpty()) {
        List<? extends Group> groupsRc1 = new ArrayList<>(groupsContainerRc4.retrieveGroups());
        List<org.orcid.jaxb.model.record_rc4.Group> groupsRc4 = new ArrayList<>(groupsContainerRc4.retrieveGroups());
        if (groupsRc1.get(0).getActivities() != null && !groupsRc1.get(0).getActivities().isEmpty()) {
            LastModifiedDate latest = null;
            for (Group group : groupsRc4) {
                calculateLastModified(group);
                if (group.getLastModifiedDate() != null && group.getLastModifiedDate().after(latest)) {
                    latest = group.getLastModifiedDate();
                }
            }
            groupsContainerRc4.setLastModifiedDate(latest);
        }
    }
}
Also used : Group(org.orcid.jaxb.model.record_rc4.Group) LastModifiedDate(org.orcid.jaxb.model.common_rc4.LastModifiedDate) ArrayList(java.util.ArrayList)

Aggregations

Test (org.junit.Test)41 Group (ucar.nc2.Group)24 Group (com.google.monitoring.v3.Group)21 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)17 ArrayList (java.util.ArrayList)16 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)16 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)15 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)12 AbstractMessage (com.google.protobuf.AbstractMessage)11 Group (org.openstack4j.model.identity.v3.Group)11 Group (org.gluu.oxtrust.model.scim2.Group)8 Url (org.orcid.jaxb.model.common_v2.Url)8 FundingGroup (org.orcid.jaxb.model.record.summary_v2.FundingGroup)8 Works (org.orcid.jaxb.model.record.summary_v2.Works)8 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)8 Variable (ucar.nc2.Variable)8 ClientResponse (com.sun.jersey.api.client.ClientResponse)7 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)7 GroupAble (org.orcid.jaxb.model.record_v2.GroupAble)7 GroupableActivity (org.orcid.jaxb.model.record_v2.GroupableActivity)7