use of org.eclipse.bpmn2.Group in project ORCID-Source by ORCID.
the class Api2_0_LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(GroupsContainer groupsContainerV2) {
if (groupsContainerV2.retrieveGroups() != null && !groupsContainerV2.retrieveGroups().isEmpty()) {
List<? extends Group> groupsRc1 = new ArrayList<>(groupsContainerV2.retrieveGroups());
List<org.orcid.jaxb.model.record_v2.Group> groupsV2 = new ArrayList<>(groupsContainerV2.retrieveGroups());
if (groupsRc1.get(0).getActivities() != null && !groupsRc1.get(0).getActivities().isEmpty()) {
LastModifiedDate latest = null;
for (Group group : groupsV2) {
calculateLastModified(group);
if (group.getLastModifiedDate() != null && group.getLastModifiedDate().after(latest)) {
latest = group.getLastModifiedDate();
}
}
groupsContainerV2.setLastModifiedDate(latest);
}
}
}
use of org.eclipse.bpmn2.Group in project camel by apache.
the class GroupProducer method messageToGroup.
private Group messageToGroup(Message message) {
Group group = message.getBody(Group.class);
if (group == null) {
Map headers = message.getHeaders();
GroupBuilder builder = Builders.group();
ObjectHelper.notEmpty(message.getHeader(OpenstackConstants.NAME, String.class), "Name");
builder.name(message.getHeader(OpenstackConstants.NAME, String.class));
if (headers.containsKey(KeystoneConstants.DOMAIN_ID)) {
builder.domainId(message.getHeader(KeystoneConstants.DOMAIN_ID, String.class));
}
if (headers.containsKey(KeystoneConstants.DESCRIPTION)) {
builder.description(message.getHeader(KeystoneConstants.DESCRIPTION, String.class));
}
group = builder.build();
}
return group;
}
use of org.eclipse.bpmn2.Group in project camel by apache.
the class GroupProducer method doUpdate.
private void doUpdate(Exchange exchange) {
final Message msg = exchange.getIn();
final Group group = messageToGroup(msg);
final Group updatedGroup = osV3Client.identity().groups().update(group);
msg.setBody(updatedGroup);
}
use of org.eclipse.bpmn2.Group in project oxTrust by GluuFederation.
the class CopyUtils2 method copy.
/**
* Copy data from GluuGroup object to ScimGroup object
*
* @param source
* @param destination
* @return
* @throws Exception
*/
public Group copy(GluuGroup source, Group destination) throws Exception {
if (source == null) {
return null;
}
if (destination == null) {
destination = new Group();
}
destination.setDisplayName(source.getDisplayName());
destination.setId(source.getInum());
if (source.getMembers() != null) {
if (source.getMembers().size() > 0) {
Set<MemberRef> memberRefSet = new HashSet<MemberRef>();
List<String> membersList = source.getMembers();
for (String oneMember : membersList) {
if (oneMember != null && !oneMember.isEmpty()) {
GluuCustomPerson gluuCustomPerson = personService.getPersonByDn(oneMember);
MemberRef memberRef = new MemberRef();
memberRef.setValue(gluuCustomPerson.getInum());
memberRef.setDisplay(gluuCustomPerson.getDisplayName());
String reference = appConfiguration.getBaseEndpoint() + "/scim/v2/Users/" + gluuCustomPerson.getInum();
memberRef.setReference(reference);
memberRefSet.add(memberRef);
}
}
destination.setMembers(memberRefSet);
}
}
log.trace(" getting meta ");
Meta meta = (destination.getMeta() != null) ? destination.getMeta() : new Meta();
if (source.getAttribute("oxTrustMetaVersion") != null) {
meta.setVersion(source.getAttribute("oxTrustMetaVersion"));
}
String location = source.getAttribute("oxTrustMetaLocation");
if (location != null && !location.isEmpty()) {
if (!location.startsWith("https://") && !location.startsWith("http://")) {
location = appConfiguration.getBaseEndpoint() + location;
}
} else {
location = appConfiguration.getBaseEndpoint() + "/scim/v2/Groups/" + source.getInum();
}
meta.setLocation(location);
if (source.getAttribute("oxTrustMetaCreated") != null && !source.getAttribute("oxTrustMetaCreated").isEmpty()) {
try {
DateTime dateTimeUtc = new DateTime(source.getAttribute("oxTrustMetaCreated"), DateTimeZone.UTC);
meta.setCreated(dateTimeUtc.toDate());
} catch (Exception e) {
log.error(" Date parse exception (NEW format), continuing...", e);
// For backward compatibility
try {
meta.setCreated(new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(source.getAttribute("oxTrustMetaCreated")));
} catch (Exception ex) {
log.error(" Date parse exception (OLD format)", ex);
}
}
}
if (source.getAttribute("oxTrustMetaLastModified") != null && !source.getAttribute("oxTrustMetaLastModified").isEmpty()) {
try {
DateTime dateTimeUtc = new DateTime(source.getAttribute("oxTrustMetaLastModified"), DateTimeZone.UTC);
meta.setLastModified(dateTimeUtc.toDate());
} catch (Exception e) {
log.error(" Date parse exception (NEW format), continuing...", e);
// For backward compatibility
try {
meta.setLastModified(new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(source.getAttribute("oxTrustMetaLastModified")));
} catch (Exception ex) {
log.error(" Date parse exception (OLD format)", ex);
}
}
}
destination.setMeta(meta);
return destination;
}
use of org.eclipse.bpmn2.Group in project oxTrust by GluuFederation.
the class BulkWebService method processGroupOperation.
private BulkOperation processGroupOperation(BulkOperation operation, Map<String, String> processedBulkIds) throws Exception {
log.info(" Operation is for Group ");
// Intercept bulkId
Group group = null;
if (operation.getData() != null) {
// Required in a request when
// "method" is "POST", "PUT", or
// "PATCH".
String serializedData = serialize(operation.getData());
for (Map.Entry<String, String> entry : processedBulkIds.entrySet()) {
String key = "bulkId:" + entry.getKey();
serializedData = serializedData.replaceAll(key, entry.getValue());
}
group = deserializeToGroup(serializedData);
}
String groupRootEndpoint = appConfiguration.getBaseEndpoint() + "/scim/v2/Groups/";
if (operation.getMethod().equalsIgnoreCase(HttpMethod.POST)) {
log.info(" Method is POST ");
try {
group = scim2GroupService.createGroup(group);
GluuGroup gluuGroup = groupService.getGroupByDisplayName(group.getDisplayName());
String id = gluuGroup.getInum();
// String location = (new
// StringBuilder()).append(domain).append("/Groups/").append(id).toString();
String location = groupRootEndpoint + id;
operation.setLocation(location);
operation.setStatus(String.valueOf(Response.Status.CREATED.getStatusCode()));
operation.setResponse(group);
// Set aside successfully-processed bulkId
// bulkId is only required in POST
processedBulkIds.put(operation.getBulkId(), group.getId());
} catch (DuplicateEntryException ex) {
log.error("DuplicateEntryException", ex);
ex.printStackTrace();
operation.setStatus(String.valueOf(Response.Status.CONFLICT.getStatusCode()));
operation.setResponse(createErrorResponse(Response.Status.CONFLICT, ErrorScimType.UNIQUENESS, ex.getMessage()));
} catch (Exception ex) {
log.error("Failed to create group", ex);
ex.printStackTrace();
operation.setStatus(String.valueOf(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()));
operation.setResponse(createErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, null, INTERNAL_SERVER_ERROR_MESSAGE));
}
} else if (operation.getMethod().equalsIgnoreCase(HttpMethod.PUT)) {
log.info(" Method is PUT ");
String path = operation.getPath();
String id = getId(path);
for (Map.Entry<String, String> entry : processedBulkIds.entrySet()) {
String key = "bulkId:" + entry.getKey();
if (id.equalsIgnoreCase(key)) {
id = id.replaceAll(key, entry.getValue());
break;
}
}
try {
group = scim2GroupService.updateGroup(id, group);
// String location = (new
// StringBuilder()).append(domain).append("/Groups/").append(groupiD).toString();
String location = groupRootEndpoint + id;
operation.setLocation(location);
operation.setStatus(String.valueOf(Response.Status.OK.getStatusCode()));
operation.setResponse(group);
// bulkId is only required in POST
if (operation.getBulkId() != null) {
processedBulkIds.put(operation.getBulkId(), group.getId());
}
} catch (EntryPersistenceException ex) {
log.error("Failed to update group", ex);
ex.printStackTrace();
operation.setStatus(String.valueOf(Response.Status.NOT_FOUND.getStatusCode()));
operation.setResponse(createErrorResponse(Response.Status.NOT_FOUND, ErrorScimType.INVALID_VALUE, "Resource " + id + " not found"));
} catch (DuplicateEntryException ex) {
log.error("DuplicateEntryException", ex);
ex.printStackTrace();
operation.setStatus(String.valueOf(Response.Status.CONFLICT.getStatusCode()));
operation.setResponse(createErrorResponse(Response.Status.CONFLICT, ErrorScimType.UNIQUENESS, ex.getMessage()));
} catch (Exception ex) {
log.error("Failed to update group", ex);
ex.printStackTrace();
operation.setStatus(String.valueOf(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()));
operation.setResponse(createErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, null, INTERNAL_SERVER_ERROR_MESSAGE));
}
} else if (operation.getMethod().equalsIgnoreCase(HttpMethod.DELETE)) {
log.info(" Method is DELETE ");
String path = operation.getPath();
String id = getId(path);
for (Map.Entry<String, String> entry : processedBulkIds.entrySet()) {
String key = "bulkId:" + entry.getKey();
if (id.equalsIgnoreCase(key)) {
id = id.replaceAll(key, entry.getValue());
break;
}
}
try {
scim2GroupService.deleteGroup(id);
// Location may be omitted on DELETE
operation.setStatus(String.valueOf(Response.Status.OK.getStatusCode()));
operation.setResponse("Group " + id + " deleted");
// bulkId is only required in POST
if (operation.getBulkId() != null) {
processedBulkIds.put(operation.getBulkId(), id);
}
} catch (EntryPersistenceException ex) {
log.error("Failed to delete group", ex);
ex.printStackTrace();
operation.setStatus(String.valueOf(Response.Status.NOT_FOUND.getStatusCode()));
operation.setResponse(createErrorResponse(Response.Status.NOT_FOUND, null, "Resource " + id + " not found"));
} catch (Exception ex) {
log.error("Failed to delete group", ex);
ex.printStackTrace();
operation.setStatus(String.valueOf(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()));
operation.setResponse(createErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, null, INTERNAL_SERVER_ERROR_MESSAGE));
}
}
return operation;
}
Aggregations