use of org.orcid.jaxb.model.record_v2.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);
}
use of org.orcid.jaxb.model.record_v2.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());
}
use of org.orcid.jaxb.model.record_v2.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());
}
use of org.orcid.jaxb.model.record_v2.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;
}
use of org.orcid.jaxb.model.record_v2.Group in project oxTrust by GluuFederation.
the class Scim2GroupService method createGroup.
public Group createGroup(Group group) throws Exception {
log.debug(" copying gluuGroup ");
GluuGroup gluuGroup = copyUtils2.copy(group, null, false);
if (gluuGroup == null) {
throw new Exception("Scim2GroupService.createGroup(): Failed to create group; GluuGroup is null");
}
log.debug(" generating inum ");
String inum = groupService.generateInumForNewGroup();
log.debug(" getting DN ");
String dn = groupService.getDnForGroup(inum);
log.debug(" getting iname ");
String iname = groupService.generateInameForNewGroup(group.getDisplayName().replaceAll(" ", ""));
log.debug(" setting dn ");
gluuGroup.setDn(dn);
log.debug(" setting inum ");
gluuGroup.setInum(inum);
log.debug(" setting iname ");
gluuGroup.setIname(iname);
log.info("group.getMembers().size() : " + group.getMembers().size());
if (group.getMembers().size() > 0) {
serviceUtil.personMembersAdder(gluuGroup, dn);
}
// As per spec, the SP must be the one to assign the meta attributes
log.info(" Setting meta: create group ");
// Date should be in UTC format
DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime().withZoneUTC();
Date dateCreated = DateTime.now().toDate();
String relativeLocation = "/scim/v2/Groups/" + inum;
gluuGroup.setAttribute("oxTrustMetaCreated", dateTimeFormatter.print(dateCreated.getTime()));
gluuGroup.setAttribute("oxTrustMetaLastModified", dateTimeFormatter.print(dateCreated.getTime()));
gluuGroup.setAttribute("oxTrustMetaLocation", relativeLocation);
// For custom script: create group
if (externalScimService.isEnabled()) {
externalScimService.executeScimCreateGroupMethods(gluuGroup);
}
log.debug("adding new GluuGroup");
groupService.addGroup(gluuGroup);
Group createdGroup = copyUtils2.copy(gluuGroup, null);
return createdGroup;
}
Aggregations