Search in sources :

Example 21 with Group

use of controlP5.Group in project camel by apache.

the class GroupProducer method doGet.

private void doGet(Exchange exchange) {
    final Message msg = exchange.getIn();
    final String id = msg.getHeader(OpenstackConstants.ID, msg.getHeader(KeystoneConstants.GROUP_ID, String.class), String.class);
    ObjectHelper.notEmpty(id, "Group ID");
    final Group result = osV3Client.identity().groups().get(id);
    msg.setBody(result);
}
Also used : Group(org.openstack4j.model.identity.v3.Group) Message(org.apache.camel.Message)

Example 22 with Group

use of controlP5.Group in project camel by apache.

the class GroupProducer method doCreate.

private void doCreate(Exchange exchange) {
    final Group in = messageToGroup(exchange.getIn());
    final Group out = osV3Client.identity().groups().create(in);
    exchange.getIn().setBody(out);
}
Also used : Group(org.openstack4j.model.identity.v3.Group)

Example 23 with Group

use of controlP5.Group in project camel by apache.

the class GroupProducerTest method setUp.

@Before
public void setUp() {
    producer = new GroupProducer(endpoint, client);
    when(groupService.create(any(Group.class))).thenReturn(testOSgroup);
    when(groupService.get(anyString())).thenReturn(testOSgroup);
    List<Group> getAllList = new ArrayList<>();
    getAllList.add(testOSgroup);
    getAllList.add(testOSgroup);
    doReturn(getAllList).when(groupService).list();
    dummyGroup = createGroup();
    when(testOSgroup.getName()).thenReturn(dummyGroup.getName());
    when(testOSgroup.getDescription()).thenReturn(dummyGroup.getDescription());
}
Also used : Group(org.openstack4j.model.identity.v3.Group) GroupProducer(org.apache.camel.component.openstack.keystone.producer.GroupProducer) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 24 with Group

use of controlP5.Group in project camel by apache.

the class GroupProducerTest method updateTest.

@Test
public void updateTest() throws Exception {
    final String id = "myID";
    msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.UPDATE);
    final String newName = "newName";
    when(testOSgroup.getId()).thenReturn(id);
    when(testOSgroup.getName()).thenReturn(newName);
    when(testOSgroup.getDescription()).thenReturn("desc");
    when(groupService.update(any(Group.class))).thenReturn(testOSgroup);
    msg.setBody(testOSgroup);
    producer.process(exchange);
    ArgumentCaptor<Group> captor = ArgumentCaptor.forClass(Group.class);
    verify(groupService).update(captor.capture());
    assertEqualsGroup(testOSgroup, captor.getValue());
    assertNotNull(captor.getValue().getId());
    assertEquals(newName, msg.getBody(Group.class).getName());
}
Also used : Group(org.openstack4j.model.identity.v3.Group) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 25 with Group

use of controlP5.Group in project oxTrust by GluuFederation.

the class Scim2GroupService method updateGroup.

public Group updateGroup(String id, Group group) throws Exception {
    GluuGroup gluuGroup = groupService.getGroupByInum(id);
    if (gluuGroup == null) {
        throw new EntryPersistenceException("Scim2GroupService.updateGroup(): " + "Resource " + id + " not found");
    } else {
        // Validate if attempting to update displayName of a different id
        if (gluuGroup.getDisplayName() != null) {
            GluuGroup groupToFind = new GluuGroup();
            groupToFind.setDisplayName(group.getDisplayName());
            List<GluuGroup> foundGroups = groupService.findGroups(groupToFind, 2);
            if (foundGroups != null && foundGroups.size() > 0) {
                for (GluuGroup foundGroup : foundGroups) {
                    if (foundGroup != null && !foundGroup.getInum().equalsIgnoreCase(gluuGroup.getInum())) {
                        throw new DuplicateEntryException("Cannot update displayName of a different id: " + group.getDisplayName());
                    }
                }
            }
        }
    }
    GluuGroup updatedGluuGroup = copyUtils2.copy(group, gluuGroup, true);
    if (group.getMembers().size() > 0) {
        serviceUtil.personMembersAdder(updatedGluuGroup, groupService.getDnForGroup(id));
    }
    log.info(" Setting meta: update group ");
    // Date should be in UTC format
    DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime().withZoneUTC();
    Date dateLastModified = DateTime.now().toDate();
    updatedGluuGroup.setAttribute("oxTrustMetaLastModified", dateTimeFormatter.print(dateLastModified.getTime()));
    if (updatedGluuGroup.getAttribute("oxTrustMetaLocation") == null || (updatedGluuGroup.getAttribute("oxTrustMetaLocation") != null && updatedGluuGroup.getAttribute("oxTrustMetaLocation").isEmpty())) {
        String relativeLocation = "/scim/v2/Groups/" + id;
        updatedGluuGroup.setAttribute("oxTrustMetaLocation", relativeLocation);
    }
    // For custom script: update group
    if (externalScimService.isEnabled()) {
        externalScimService.executeScimUpdateGroupMethods(updatedGluuGroup);
    }
    groupService.updateGroup(updatedGluuGroup);
    log.debug(" group updated ");
    Group updatedGroup = copyUtils2.copy(updatedGluuGroup, null);
    return updatedGroup;
}
Also used : Group(org.gluu.oxtrust.model.scim2.Group) GluuGroup(org.gluu.oxtrust.model.GluuGroup) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) DuplicateEntryException(org.gluu.site.ldap.exception.DuplicateEntryException) GluuGroup(org.gluu.oxtrust.model.GluuGroup) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) Date(java.util.Date)

Aggregations

ArrayList (java.util.ArrayList)9 Group (org.gluu.oxtrust.model.scim2.Group)8 Group (org.openstack4j.model.identity.v3.Group)8 Group (ucar.nc2.Group)8 GluuGroup (org.gluu.oxtrust.model.GluuGroup)7 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)7 Group (com.google.monitoring.v3.Group)5 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)5 Test (org.junit.Test)5 GroupName (com.google.monitoring.v3.GroupName)3 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)3 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)3 URI (java.net.URI)3 Date (java.util.Date)3 DefaultValue (javax.ws.rs.DefaultValue)3 HeaderParam (javax.ws.rs.HeaderParam)3 Produces (javax.ws.rs.Produces)3 Response (javax.ws.rs.core.Response)3 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)3 Artifact (org.eclipse.bpmn2.Artifact)3