Issue #1910 Changes to comply with the Ebxml 4.0 spec for SubmitObjects
Amend: Rebase on newest development commits Change-Id: I70fcf39d4c819e961921496c9a8f9097981b1de7 Former-commit-id:42b2e12061
[formerly457710f5d4
] [formerly3adc0f3bd9
[formerly 78bfd27bf513a4014c957a069432e8a05d519004]] Former-commit-id:3adc0f3bd9
Former-commit-id:6b1bd85a9b
This commit is contained in:
parent
5718dcb41a
commit
ef0c554826
9 changed files with 395 additions and 97 deletions
|
@ -20,6 +20,8 @@
|
|||
|
||||
package oasis.names.tc.ebxml.regrep.xsd.lcm.v4;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
@ -28,6 +30,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectListType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryRequestType;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
|
@ -96,6 +99,18 @@ public class SubmitObjectsRequest extends RegistryRequestType {
|
|||
this.registryObjectList = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the registry objects on the request.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<RegistryObjectType> getRegistryObjects() {
|
||||
if (registryObjectList == null) {
|
||||
registryObjectList = new RegistryObjectListType();
|
||||
}
|
||||
return registryObjectList.getRegistryObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the checkReferences property.
|
||||
*
|
||||
|
|
|
@ -102,6 +102,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
* Sep 14, 2012 1169 djohnson Throw exception when object exists during create only mode.
|
||||
* 3/18/2013 1802 bphillip Modified to use transaction boundaries and spring injection
|
||||
* 4/9/2013 1802 bphillip Changed how auditable events are handled
|
||||
* Apr 18, 2013 1693 djohnson Changes to conform to Ebxml 4.0 SubmitObjects protocol.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -294,6 +295,7 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
* The LifecycleManager sends a RegistryResponse back to the client as
|
||||
* response.
|
||||
*/
|
||||
@Override
|
||||
public RegistryResponseType submitObjects(SubmitObjectsRequest request)
|
||||
throws MsgRegistryException {
|
||||
|
||||
|
@ -430,16 +432,12 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
*
|
||||
* Submits objects to the registry
|
||||
*
|
||||
* @param submitMode
|
||||
* The mode of submission
|
||||
* @param objs
|
||||
* The objects to submit
|
||||
* @param request
|
||||
* The submit objects request
|
||||
* @param response
|
||||
* The response object to update with any errors or warnings
|
||||
* @throws MsgRegistryException
|
||||
* If the submission process encounters errors
|
||||
* @return time taken for transaction
|
||||
* @throws MsgRegistryException
|
||||
*/
|
||||
private void processSubmit(SubmitObjectsRequest request,
|
||||
RegistryResponseType response) throws MsgRegistryException {
|
||||
|
@ -450,40 +448,50 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
List<RegistryObjectType> objsUpdated = new ArrayList<RegistryObjectType>();
|
||||
for (RegistryObjectType obj : request.getRegistryObjectList()
|
||||
.getRegistryObject()) {
|
||||
statusHandler.info("Processing object [" + obj.getId() + "]");
|
||||
if (obj.getId() == null) {
|
||||
String objectId = obj.getId();
|
||||
statusHandler.info("Processing object [" + objectId + "]");
|
||||
if (objectId == null) {
|
||||
if (request.getMode().equals(Mode.CREATE_ONLY)) {
|
||||
statusHandler
|
||||
.info("Generating id for object specified with CREATE_ONLY Mode");
|
||||
String uuid = EbxmlObjectUtil.getUUID();
|
||||
obj.setId(uuid);
|
||||
objectId = EbxmlObjectUtil.getUUID();
|
||||
obj.setId(objectId);
|
||||
} else {
|
||||
response.getException()
|
||||
.add(EbxmlExceptionUtil
|
||||
.createRegistryException(
|
||||
InvalidRequestExceptionType.class,
|
||||
"",
|
||||
"The id field MUST be specified by the client",
|
||||
"Please specify an id for all registry objects submitted",
|
||||
ErrorSeverity.ERROR, statusHandler));
|
||||
continue;
|
||||
final String message = "The id field MUST be specified by the client";
|
||||
final String pleaseSpecifyId = "Please specify an id for all registry objects submitted";
|
||||
|
||||
final MsgRegistryException registryException = EbxmlExceptionUtil
|
||||
.createMsgRegistryException(
|
||||
message,
|
||||
InvalidRequestExceptionType.class,
|
||||
"",
|
||||
message,
|
||||
pleaseSpecifyId,
|
||||
ErrorSeverity.ERROR, null, statusHandler);
|
||||
response.getException().add(
|
||||
registryException.getFaultInfo());
|
||||
throw registryException;
|
||||
}
|
||||
}
|
||||
if (obj.getLid() == null) {
|
||||
response.getException()
|
||||
.add(EbxmlExceptionUtil
|
||||
.createRegistryException(
|
||||
InvalidRequestExceptionType.class,
|
||||
"",
|
||||
"The lid field MUST be specified by the client",
|
||||
"Please specify an lid for all registry objects submitted",
|
||||
ErrorSeverity.ERROR, statusHandler));
|
||||
continue;
|
||||
|
||||
final String objectLid = obj.getLid();
|
||||
if (objectLid == null) {
|
||||
final String message = "The lid field MUST be specified by the client";
|
||||
final String pleaseSpecifyLid = "Please specify an lid for all registry objects submitted";
|
||||
|
||||
final MsgRegistryException registryException = EbxmlExceptionUtil
|
||||
.createMsgRegistryException(
|
||||
message,
|
||||
InvalidRequestExceptionType.class,
|
||||
"",
|
||||
message,
|
||||
pleaseSpecifyLid,
|
||||
ErrorSeverity.ERROR, null, statusHandler);
|
||||
response.getException().add(registryException.getFaultInfo());
|
||||
throw registryException;
|
||||
}
|
||||
|
||||
List<RegistryObjectType> dbObjects = registryObjectDao.getByLid(obj
|
||||
.getLid());
|
||||
List<RegistryObjectType> dbObjects = registryObjectDao.getByLid(objectLid);
|
||||
storedObjects.clear();
|
||||
for (RegistryObjectType regObj : dbObjects) {
|
||||
storedObjects.put(regObj.getId(), regObj);
|
||||
|
@ -499,42 +507,42 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
|
||||
switch (request.getMode()) {
|
||||
case CREATE_OR_REPLACE:
|
||||
if (storedObjects.containsKey(obj.getId())) {
|
||||
if (storedObjects.containsKey(objectId)) {
|
||||
VersionInfoType versionInfo = storedObjects
|
||||
.get(obj.getId()).getVersionInfo();
|
||||
.get(objectId).getVersionInfo();
|
||||
obj.setVersionInfo(versionInfo);
|
||||
obj.setStatus(storedObjects.get(obj.getId()).getStatus());
|
||||
obj.setStatus(storedObjects.get(objectId).getStatus());
|
||||
/*
|
||||
* A server MUST NOT perform update operations via
|
||||
* SubmitObjects and UpdateObjects operations on a local
|
||||
* replica of a remote object. (Except in the case of
|
||||
* updating objects from notifications)
|
||||
*/
|
||||
checkReplica(request, obj, storedObjects.get(obj.getId()));
|
||||
statusHandler.info("Object [" + obj.getId()
|
||||
checkReplica(request, obj, storedObjects.get(objectId));
|
||||
statusHandler.info("Object [" + objectId
|
||||
+ "] replaced in the registry.");
|
||||
// registryObjectDao.delete(storedObjects.get(obj.getId()));
|
||||
objsUpdated.add(obj);
|
||||
registryObjectDao
|
||||
.merge(obj, storedObjects.get(obj.getId()));
|
||||
.merge(obj, storedObjects.get(objectId));
|
||||
|
||||
} else {
|
||||
obj.setStatus(StatusTypes.APPROVED);
|
||||
obj.setVersionInfo(new VersionInfoType());
|
||||
statusHandler.info("Object [" + obj.getId()
|
||||
statusHandler.info("Object [" + objectId
|
||||
+ "] added to the registry.");
|
||||
objsCreated.add(obj);
|
||||
registryObjectDao.create(obj);
|
||||
}
|
||||
break;
|
||||
case CREATE_OR_VERSION:
|
||||
if (storedObjects.containsKey(obj.getId())) {
|
||||
if (storedObjects.containsKey(objectId)) {
|
||||
VersionInfoType versionInfo = dbObjects.get(0)
|
||||
.getVersionInfo();
|
||||
obj.setVersionInfo(EbxmlObjectUtil
|
||||
.incrementVersion(versionInfo));
|
||||
obj.setStatus(storedObjects.get(obj.getId()).getStatus());
|
||||
statusHandler.info("Object [" + obj.getId()
|
||||
obj.setStatus(storedObjects.get(objectId).getStatus());
|
||||
statusHandler.info("Object [" + objectId
|
||||
+ "] versioned in the registry.");
|
||||
obj.setId(EbxmlObjectUtil.getUUID());
|
||||
AssociationType versionAssociation = EbxmlObjectUtil.rimObjectFactory
|
||||
|
@ -546,13 +554,13 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
.getInternationalString("Version Association"));
|
||||
versionAssociation
|
||||
.setDescription(RegistryUtil
|
||||
.getInternationalString(obj.getId()
|
||||
.getInternationalString(objectId
|
||||
+ " Supersedes "
|
||||
+ dbObjects.get(0).getId()));
|
||||
versionAssociation.setOwner(dbObjects.get(0).getOwner());
|
||||
versionAssociation
|
||||
.setObjectType(RegistryObjectTypes.ASSOCIATION);
|
||||
versionAssociation.setSourceObject(obj.getId());
|
||||
versionAssociation.setSourceObject(objectId);
|
||||
versionAssociation
|
||||
.setTargetObject(dbObjects.get(0).getId());
|
||||
versionAssociation.setStatus(StatusTypes.APPROVED);
|
||||
|
@ -562,7 +570,7 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
objsVersioned.add(obj);
|
||||
statusHandler
|
||||
.info("Supersedes association for new version of ["
|
||||
+ obj.getId()
|
||||
+ objectId
|
||||
+ "] persisted to the registry");
|
||||
registryObjectDao.create(obj);
|
||||
} else {
|
||||
|
@ -578,37 +586,49 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
}
|
||||
obj.setStatus(StatusTypes.APPROVED);
|
||||
obj.setVersionInfo(new VersionInfoType());
|
||||
statusHandler.info("Object [" + obj.getId()
|
||||
statusHandler.info("Object [" + objectId
|
||||
+ "] added to the registry.");
|
||||
objsCreated.add(obj);
|
||||
registryObjectDao.create(obj);
|
||||
}
|
||||
break;
|
||||
case CREATE_ONLY:
|
||||
if (storedObjects.containsKey(obj.getId())) {
|
||||
String message = "Object with id [" + obj.getId()
|
||||
if (storedObjects.containsKey(objectId)) {
|
||||
final String message = "Object with id [" + objectId
|
||||
+ "] already exists";
|
||||
response.getException()
|
||||
.add(EbxmlExceptionUtil
|
||||
.createRegistryException(
|
||||
ObjectExistsExceptionType.class,
|
||||
"",
|
||||
message,
|
||||
"The "
|
||||
+ Mode.CREATE_ONLY
|
||||
+ " submit mode only accepts new objects",
|
||||
ErrorSeverity.ERROR, statusHandler));
|
||||
final String onlyAcceptsNewObjects = "The "
|
||||
+ Mode.CREATE_ONLY
|
||||
+ " submit mode only accepts new objects";
|
||||
|
||||
throw EbxmlExceptionUtil.createMsgRegistryException(
|
||||
message, ObjectExistsExceptionType.class, "",
|
||||
message, "Error submitting object [" + obj.getId()
|
||||
+ "]", ErrorSeverity.ERROR, null,
|
||||
statusHandler);
|
||||
final MsgRegistryException registryException = EbxmlExceptionUtil
|
||||
.createMsgRegistryException(message,
|
||||
ObjectExistsExceptionType.class, "",
|
||||
message, onlyAcceptsNewObjects,
|
||||
ErrorSeverity.ERROR, null, statusHandler);
|
||||
response.getException().add(
|
||||
registryException.getFaultInfo());
|
||||
throw registryException;
|
||||
|
||||
} else if (!storedObjects.isEmpty()) {
|
||||
final String message = "Object with lid [" + objectLid
|
||||
+ "] already exists";
|
||||
final String onlyAcceptsNewObjects = "The "
|
||||
+ Mode.CREATE_ONLY
|
||||
+ " submit mode only accepts new objects";
|
||||
|
||||
final MsgRegistryException registryException = EbxmlExceptionUtil
|
||||
.createMsgRegistryException(message,
|
||||
ObjectExistsExceptionType.class, "",
|
||||
message, onlyAcceptsNewObjects,
|
||||
ErrorSeverity.ERROR, null, statusHandler);
|
||||
response.getException().add(
|
||||
registryException.getFaultInfo());
|
||||
throw registryException;
|
||||
|
||||
} else {
|
||||
obj.setVersionInfo(new VersionInfoType());
|
||||
obj.setStatus(StatusTypes.APPROVED);
|
||||
statusHandler.info("Object [" + obj.getId()
|
||||
statusHandler.info("Object [" + objectId
|
||||
+ "] added to the registry.");
|
||||
objsCreated.add(obj);
|
||||
registryObjectDao.create(obj);
|
||||
|
|
|
@ -19,12 +19,18 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.registry.ebxml.dao;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager;
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.QueryManager;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.Mode;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.SubmitObjectsRequest;
|
||||
|
@ -35,12 +41,14 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectListType;
|
|||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SlotType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.StringValueType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryExceptionType;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.edex.core.EDEXUtil;
|
||||
import com.raytheon.uf.edex.registry.ebxml.services.query.QueryConstants;
|
||||
import com.raytheon.uf.edex.registry.ebxml.services.query.QueryManagerImpl.RETURN_TYPE;
|
||||
|
@ -56,6 +64,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 15, 2013 1914 djohnson Initial creation
|
||||
* Apr 18, 2013 1693 djohnson Consolidate reusable methods.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -94,6 +103,10 @@ public class AbstractRegistryTest {
|
|||
registryObject.setId(MY_REGISTRY_OBJECT_ID);
|
||||
registryObject.setLid(registryObject.getId());
|
||||
registryObject.setObjectType(registryObjectType);
|
||||
registryObject.setName(RegistryUtil
|
||||
.getInternationalString(registryObjectId));
|
||||
registryObject.setDescription(RegistryUtil
|
||||
.getInternationalString(registryObjectId));
|
||||
|
||||
List<RegistryObjectType> registryObjects = Lists.newArrayList();
|
||||
registryObjects.add(registryObject);
|
||||
|
@ -138,4 +151,26 @@ public class AbstractRegistryTest {
|
|||
return partQueryRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect the specified exception to be wrapped in a
|
||||
* {@link MsgRegistryException}.
|
||||
*
|
||||
* @param <T>
|
||||
* the expected exception type
|
||||
* @param submitObjectsRequest
|
||||
* the request
|
||||
* @param expectedException
|
||||
* the expected exception class
|
||||
*/
|
||||
protected <T extends RegistryExceptionType> void expectFaultException(
|
||||
SubmitObjectsRequest submitObjectsRequest,
|
||||
Class<T> expectedException) {
|
||||
try {
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
fail("Expected a MsgRegistryException to have been thrown!");
|
||||
} catch (MsgRegistryException exception) {
|
||||
final RegistryExceptionType faultInfo = exception.getFaultInfo();
|
||||
assertThat(faultInfo, is(instanceOf(expectedException)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@ package com.raytheon.uf.edex.registry.ebxml.dao;
|
|||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager;
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
|
||||
|
@ -34,10 +34,12 @@ import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.Mode;
|
|||
import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.SubmitObjectsRequest;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryRequest;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryResponse;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ClassificationType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.InvalidRequestExceptionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.ObjectExistsExceptionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryExceptionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.UnresolvedReferenceExceptionType;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -46,6 +48,7 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryResponseStatus;
|
||||
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
|
||||
|
||||
|
@ -59,6 +62,7 @@ import com.raytheon.uf.edex.database.dao.DatabaseUtil;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 15, 2013 1693 djohnson Initial creation
|
||||
* Apr 18, 2013 1693 djohnson More tests verifying spec compliance..
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -81,7 +85,7 @@ public class LifecycleManagerSubmitObjectsTest extends AbstractRegistryTest {
|
|||
* @throws MsgRegistryException
|
||||
*/
|
||||
@Test
|
||||
public void createOnlySubmitObjectsWithNonExistantObjectSucceeds()
|
||||
public void createOnlyWithNonExistantObjectSucceeds()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
|
@ -102,7 +106,7 @@ public class LifecycleManagerSubmitObjectsTest extends AbstractRegistryTest {
|
|||
* @throws MsgRegistryException
|
||||
*/
|
||||
@Test
|
||||
public void createOnlySubmitObjectsWithExistantObjectFails()
|
||||
public void createOnlyWithExistantObjectFails()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
|
@ -110,15 +114,8 @@ public class LifecycleManagerSubmitObjectsTest extends AbstractRegistryTest {
|
|||
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
|
||||
try {
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
|
||||
fail("Expected a MsgRegistryException to have been thrown!");
|
||||
} catch (MsgRegistryException exception) {
|
||||
final RegistryExceptionType faultInfo = exception.getFaultInfo();
|
||||
assertThat(faultInfo,
|
||||
is(instanceOf(ObjectExistsExceptionType.class)));
|
||||
}
|
||||
expectFaultException(submitObjectsRequest,
|
||||
ObjectExistsExceptionType.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -127,7 +124,7 @@ public class LifecycleManagerSubmitObjectsTest extends AbstractRegistryTest {
|
|||
* replace the existing object with the submitted object
|
||||
*/
|
||||
@Test
|
||||
public void createOrReplaceSubmitObjectsWithNonExistantObjectSucceeds()
|
||||
public void createOrReplaceWithNonExistantObjectSucceeds()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
|
@ -141,13 +138,36 @@ public class LifecycleManagerSubmitObjectsTest extends AbstractRegistryTest {
|
|||
is(equalTo(RegistryResponseStatus.SUCCESS)));
|
||||
}
|
||||
|
||||
/**
|
||||
* CreateOrReplace (default)
|
||||
*/
|
||||
@Test
|
||||
public void noModeSpecifiedCanReplaceExistantObject()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE,
|
||||
Mode.CREATE_OR_REPLACE);
|
||||
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
|
||||
// Null out the mode
|
||||
submitObjectsRequest.setMode(null);
|
||||
|
||||
final RegistryResponseType response = lifecycleManager
|
||||
.submitObjects(submitObjectsRequest);
|
||||
|
||||
assertThat(response.getStatus(),
|
||||
is(equalTo(RegistryResponseStatus.SUCCESS)));
|
||||
}
|
||||
|
||||
/**
|
||||
* CreateOrReplace (default) - If an object does not exist, server MUST
|
||||
* create it as a new object. If an object already exists, server MUST
|
||||
* replace the existing object with the submitted object
|
||||
*/
|
||||
@Test
|
||||
public void createOrReplaceSubmitObjectsWithExistantObjectSucceeds()
|
||||
public void createOrReplaceWithExistantObjectSucceeds()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
|
@ -169,7 +189,7 @@ public class LifecycleManagerSubmitObjectsTest extends AbstractRegistryTest {
|
|||
* replace the existing object with the submitted object
|
||||
*/
|
||||
@Test
|
||||
public void createOrReplaceSubmitObjectsWithExistantObjectReplacesExisting()
|
||||
public void createOrReplaceWithExistantObjectReplacesExisting()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
|
@ -195,7 +215,7 @@ public class LifecycleManagerSubmitObjectsTest extends AbstractRegistryTest {
|
|||
* object using the state of the submitted object
|
||||
*/
|
||||
@Test
|
||||
public void createOrVersionSubmitObjectsWithNonExistantObjectSucceeds()
|
||||
public void createOrVersionWithNonExistantObjectSucceeds()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
|
@ -216,7 +236,7 @@ public class LifecycleManagerSubmitObjectsTest extends AbstractRegistryTest {
|
|||
* object using the state of the submitted object
|
||||
*/
|
||||
@Test
|
||||
public void createOrVersionSubmitObjectsWithExistantObjectVersionsExisting()
|
||||
public void createOrVersionWithExistantObjectVersionsExisting()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
|
@ -235,4 +255,205 @@ public class LifecycleManagerSubmitObjectsTest extends AbstractRegistryTest {
|
|||
assertThat(registryObjects, hasSize(2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribute checkReferences - true - Specifies that a server MUST check
|
||||
* submitted objects and make sure that all references via reference
|
||||
* attributes and slots to other RegistryObjects are resolvable. If a
|
||||
* reference does not resolve then the server MUST return
|
||||
* UnresolvedReferenceException
|
||||
*/
|
||||
@Test
|
||||
public void checkReferencesTrueWithNonExistantAssociationFails()
|
||||
throws MsgRegistryException {
|
||||
|
||||
final ClassificationType classificationType = new ClassificationType();
|
||||
classificationType.setId("someClassificationId");
|
||||
|
||||
final Set<ClassificationType> classifications = Sets
|
||||
.<ClassificationType> newHashSet();
|
||||
classifications.add(classificationType);
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE,
|
||||
Mode.CREATE_OR_VERSION);
|
||||
submitObjectsRequest.setCheckReferences(true);
|
||||
|
||||
final RegistryObjectType registryObject = submitObjectsRequest
|
||||
.getRegistryObjects().iterator().next();
|
||||
registryObject.setClassification(classifications);
|
||||
|
||||
expectFaultException(submitObjectsRequest,
|
||||
UnresolvedReferenceExceptionType.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribute checkReferences - false - Specifies that a server MUST NOT
|
||||
* check submitted objects to make sure that all references via reference
|
||||
* attributes and slots to other RegistryObjects are resolvable. If a
|
||||
* reference does not resolve then the server MUST NOT return
|
||||
* UnresolvedReferenceException
|
||||
*/
|
||||
@Test
|
||||
public void checkReferencesFalseWithNonExistantAssociationSucceeds()
|
||||
throws MsgRegistryException {
|
||||
|
||||
final ClassificationType classificationType = new ClassificationType();
|
||||
classificationType.setId("someClassificationId");
|
||||
|
||||
final Set<ClassificationType> classifications = Sets
|
||||
.<ClassificationType> newHashSet();
|
||||
classifications.add(classificationType);
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE,
|
||||
Mode.CREATE_OR_VERSION);
|
||||
submitObjectsRequest.setCheckReferences(false);
|
||||
|
||||
final RegistryObjectType registryObject = submitObjectsRequest
|
||||
.getRegistryObjects().iterator().next();
|
||||
registryObject.setClassification(classifications);
|
||||
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* id - MUST be specified by client or else server MUST return
|
||||
* InvalidRequestException
|
||||
*/
|
||||
@Test
|
||||
public void createOrReplaceWithoutIdFails() throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE,
|
||||
Mode.CREATE_OR_REPLACE);
|
||||
submitObjectsRequest.getRegistryObjects().iterator().next().setId(null);
|
||||
|
||||
expectFaultException(submitObjectsRequest,
|
||||
InvalidRequestExceptionType.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* id - MUST be specified by client or else server MUST return
|
||||
* InvalidRequestException
|
||||
*/
|
||||
@Test
|
||||
public void createOrVersionWithoutIdFails() throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE,
|
||||
Mode.CREATE_OR_VERSION);
|
||||
submitObjectsRequest.getRegistryObjects().iterator().next().setId(null);
|
||||
|
||||
expectFaultException(submitObjectsRequest,
|
||||
InvalidRequestExceptionType.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* id - If unspecified Server MUST generate UUID URN
|
||||
*/
|
||||
@Test
|
||||
public void createOnlyWithoutIdCreatesUUID() throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE, Mode.CREATE_ONLY);
|
||||
submitObjectsRequest.getRegistryObjects().iterator().next().setId(null);
|
||||
|
||||
final RegistryResponseType response = lifecycleManager
|
||||
.submitObjects(submitObjectsRequest);
|
||||
|
||||
final String id = response.getObjectRefList().getObjectRef().iterator()
|
||||
.next().getId();
|
||||
|
||||
// Make sure it can be parsed as a UUID
|
||||
UUID.fromString(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* id - If id does not exists, server MUST create new object using that id
|
||||
* (create)
|
||||
*/
|
||||
@Test
|
||||
public void createOnlyWithIdUsesGivenId() throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE, Mode.CREATE_ONLY);
|
||||
submitObjectsRequest.getRegistryObjects().iterator().next().setId(null);
|
||||
|
||||
final RegistryResponseType response = lifecycleManager
|
||||
.submitObjects(submitObjectsRequest);
|
||||
|
||||
assertThat(response.getObjectRefList().getObjectRef().iterator().next()
|
||||
.getId(), is(submitObjectsRequest.getRegistryObjects()
|
||||
.iterator().next().getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* lid - MUST be specified by client or else server MUST return
|
||||
* InvalidRequestException
|
||||
*/
|
||||
@Test
|
||||
public void createOrReplaceWithoutLidFails() throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE,
|
||||
Mode.CREATE_OR_REPLACE);
|
||||
submitObjectsRequest.getRegistryObjects().iterator().next()
|
||||
.setLid(null);
|
||||
|
||||
expectFaultException(submitObjectsRequest,
|
||||
InvalidRequestExceptionType.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* lid - MUST be specified by client or else server MUST return
|
||||
* InvalidRequestException
|
||||
*/
|
||||
@Test
|
||||
public void createOrVersionWithoutLidFails() throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE,
|
||||
Mode.CREATE_OR_VERSION);
|
||||
submitObjectsRequest.getRegistryObjects().iterator().next()
|
||||
.setLid(null);
|
||||
|
||||
expectFaultException(submitObjectsRequest,
|
||||
InvalidRequestExceptionType.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* lid - MUST be specified by client or else server MUST return
|
||||
* InvalidRequestException
|
||||
*/
|
||||
@Test
|
||||
public void createOnlyWithoutLidFails() throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE, Mode.CREATE_ONLY);
|
||||
submitObjectsRequest.getRegistryObjects().iterator().next()
|
||||
.setLid(null);
|
||||
|
||||
expectFaultException(submitObjectsRequest,
|
||||
InvalidRequestExceptionType.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* lid - MUST NOT exist or else server MUST return ObjectExistsException
|
||||
*/
|
||||
@Test
|
||||
public void createOrVersionWithExistingLidFails()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, REGISTRY_OBJECT_TYPE, Mode.CREATE_ONLY);
|
||||
submitObjectsRequest.getRegistryObjects().iterator().next().setId(null);
|
||||
submitObjectsRequest.getRegistryObjects().iterator().next()
|
||||
.setLid("goingToSubmitTheSameLidTwice");
|
||||
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
|
||||
submitObjectsRequest.getRegistryObjects().iterator().next().setId(null);
|
||||
expectFaultException(submitObjectsRequest,
|
||||
ObjectExistsExceptionType.class);
|
||||
}
|
||||
}
|
||||
|
|
1
tests/resources/unit-test-db-beans.properties
Normal file
1
tests/resources/unit-test-db-beans.properties
Normal file
|
@ -0,0 +1 @@
|
|||
unit.test.jdbc.url=jdbc:h2:mem:unit-testing
|
|
@ -7,15 +7,13 @@
|
|||
http://www.springframework.org/schema/tx
|
||||
http://www.springframework.org/schema/tx/spring-tx.xsd">
|
||||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
|
||||
destroy-method="close">
|
||||
<property name="driverClassName" value="org.h2.Driver" />
|
||||
<property name="url" value="jdbc:h2:mem:unit-testing:;INIT=create schema IF NOT EXISTS ebxml" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="" />
|
||||
<property name="defaultAutoCommit" value="false" />
|
||||
<bean
|
||||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location">
|
||||
<value>classpath:/unit-test-db-beans.properties</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<import resource="classpath:/unit-test-db-session.xml" />
|
||||
|
||||
</beans>
|
1
tests/resources/unit-test-db-beans2.properties
Normal file
1
tests/resources/unit-test-db-beans2.properties
Normal file
|
@ -0,0 +1 @@
|
|||
unit.test.jdbc.url=jdbc:h2:mem:unit-testing2
|
|
@ -10,13 +10,11 @@
|
|||
<!-- Used in the case where a second in-memory database needs to be started
|
||||
in the same unit test -->
|
||||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
|
||||
destroy-method="close">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbc.JDBCDriver" />
|
||||
<property name="url" value="jdbc:hsqldb:mem:unit-testing2" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="" />
|
||||
<property name="defaultAutoCommit" value="false" />
|
||||
<bean
|
||||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location">
|
||||
<value>classpath:/unit-test-db-beans2.properties</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<import resource="classpath:/unit-test-db-session.xml" />
|
||||
|
|
|
@ -31,5 +31,14 @@
|
|||
|
||||
<!-- Register the application context with EDEXUtil -->
|
||||
<bean class="com.raytheon.uf.edex.core.EDEXUtil" />
|
||||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
|
||||
destroy-method="close">
|
||||
<property name="driverClassName" value="org.h2.Driver" />
|
||||
<property name="url" value="${unit.test.jdbc.url}:;INIT=create schema IF NOT EXISTS ebxml" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="" />
|
||||
<property name="defaultAutoCommit" value="false" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
Loading…
Add table
Reference in a new issue