use of org.orcid.jaxb.model.groupid_rc2.GroupIdRecord in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegatorImpl method createGroupIdRecord.
@Override
public Response createGroupIdRecord(GroupIdRecord groupIdRecord) {
orcidSecurityManager.checkScopes(ScopePathType.GROUP_ID_RECORD_UPDATE);
GroupIdRecord newRecord = groupIdRecordManager.createGroupIdRecord(groupIdRecord);
try {
return Response.created(new URI(String.valueOf(newRecord.getPutCode()))).build();
} catch (URISyntaxException ex) {
throw new RuntimeException(localeManager.resolveMessage("apiError.creategroupidrecord_response.exception"), ex);
}
}
use of org.orcid.jaxb.model.groupid_rc2.GroupIdRecord in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegatorImpl method updateGroupIdRecord.
@Override
public Response updateGroupIdRecord(GroupIdRecord groupIdRecord, Long putCode) {
orcidSecurityManager.checkScopes(ScopePathType.GROUP_ID_RECORD_UPDATE);
if (!putCode.equals(groupIdRecord.getPutCode())) {
Map<String, String> params = new HashMap<String, String>();
params.put("urlPutCode", String.valueOf(putCode));
params.put("bodyPutCode", String.valueOf(groupIdRecord.getPutCode()));
throw new MismatchedPutCodeException(params);
}
GroupIdRecord updatedRecord = groupIdRecordManager.updateGroupIdRecord(putCode, groupIdRecord);
return Response.ok(updatedRecord).build();
}
use of org.orcid.jaxb.model.groupid_rc2.GroupIdRecord in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_GroupIdTest method testDeleteGroupIdRecord.
@Test(expected = GroupIdRecordNotFoundException.class)
public void testDeleteGroupIdRecord() {
SecurityContextTestUtils.setUpSecurityContextForGroupIdClientOnly();
// Verify if the record exists
Response response = serviceDelegator.viewGroupIdRecord(5L);
assertNotNull(response);
GroupIdRecord groupIdRecord = (GroupIdRecord) response.getEntity();
assertNotNull(groupIdRecord);
// Delete the record
serviceDelegator.deleteGroupIdRecord(5L);
// Throws a record not found exception
serviceDelegator.viewGroupIdRecord(5L);
}
use of org.orcid.jaxb.model.groupid_rc2.GroupIdRecord in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_GroupIdTest method testUpdateGroupIdRecord.
@Test
public void testUpdateGroupIdRecord() {
SecurityContextTestUtils.setUpSecurityContextForGroupIdClientOnly();
Response response = serviceDelegator.viewGroupIdRecord(Long.valueOf("3"));
assertNotNull(response);
GroupIdRecord groupIdRecord = (GroupIdRecord) response.getEntity();
assertNotNull(groupIdRecord);
Utils.verifyLastModified(groupIdRecord.getLastModifiedDate());
LastModifiedDate before = groupIdRecord.getLastModifiedDate();
// Verify the name
assertEquals(groupIdRecord.getName(), "TestGroup3");
// Set a new name for update
groupIdRecord.setName("TestGroup33");
serviceDelegator.updateGroupIdRecord(groupIdRecord, Long.valueOf("3"));
// Get the entity again and verify the name
response = serviceDelegator.viewGroupIdRecord(Long.valueOf("3"));
assertNotNull(response);
GroupIdRecord groupIdRecordNew = (GroupIdRecord) response.getEntity();
assertNotNull(groupIdRecordNew);
Utils.verifyLastModified(groupIdRecordNew.getLastModifiedDate());
assertTrue(groupIdRecordNew.getLastModifiedDate().after(before));
// Verify the name
assertEquals(groupIdRecordNew.getName(), "TestGroup33");
}
use of org.orcid.jaxb.model.groupid_rc2.GroupIdRecord in project ORCID-Source by ORCID.
the class Api2_0_rc2_LastModifiedDatesHelper method calculateLatest.
public static Date calculateLatest(GroupIdRecords groupIdRecords) {
Date latestAct = null;
if (groupIdRecords != null && groupIdRecords.getGroupIdRecord() != null && !groupIdRecords.getGroupIdRecord().isEmpty()) {
XMLGregorianCalendar latest = groupIdRecords.getGroupIdRecord().get(0).getLastModifiedDate().getValue();
for (GroupIdRecord groupid : groupIdRecords.getGroupIdRecord()) {
if (latest.compare(groupid.getLastModifiedDate().getValue()) == -1) {
latest = groupid.getLastModifiedDate().getValue();
}
}
latestAct = latest.toGregorianCalendar().getTime();
groupIdRecords.setLastModifiedDate(new LastModifiedDate(latest));
}
return latestAct;
}
Aggregations