use of org.cristalise.kernel.utils.CastorXMLUtility in project kernel by cristal-ise.
the class ItemProxy method initialise.
/**
* Initialise the new Item with instance data which is normally is created from descriptions
*
* @param agentId the Agent who is creating the Item
* @param itemProps initial list of Properties of the Item
* @param workflow new Lifecycle of the Item
* @param colls the initial state of the Item's collections
*
* @throws AccessRightsException Agent does not the rights to create an Item
* @throws InvalidDataException data was invalid
* @throws PersistencyException there was a database probles during Item initialisation
* @throws ObjectNotFoundException Object not found
* @throws MarshalException there was a problem converting those objects to XML
* @throws ValidationException XML was not valid
* @throws IOException IO errors
* @throws MappingException errors in XML marshall/unmarshall mapping
* @throws InvalidCollectionModification invalid Collection
*/
public void initialise(AgentPath agentId, PropertyArrayList itemProps, CompositeActivity workflow, CollectionArrayList colls) throws AccessRightsException, InvalidDataException, PersistencyException, ObjectNotFoundException, MarshalException, ValidationException, IOException, MappingException, InvalidCollectionModification {
Logger.msg(7, "ItemProxy.initialise() - started");
CastorXMLUtility xml = Gateway.getMarshaller();
if (itemProps == null)
throw new InvalidDataException("ItemProxy.initialise() - No initial properties supplied");
String propString = xml.marshall(itemProps);
String wfString = "";
if (workflow != null)
wfString = xml.marshall(workflow);
String collString = "";
if (colls != null)
collString = xml.marshall(colls);
getItem().initialise(agentId.getSystemKey(), propString, wfString, collString);
}
use of org.cristalise.kernel.utils.CastorXMLUtility in project kernel by cristal-ise.
the class Gateway method init.
/**
* Initialises the Gateway and all of the client objects it holds, with
* the exception of the Lookup, which is initialised during connect()
*
* @param props - java.util.Properties containing all application properties.
* If null, the java system properties are used
* @param res - ResourceLoader for the kernel to use to resolve all class resource requests
* such as for bootstrap descriptions and version information
* @throws InvalidDataException - invalid properties caused a failure in initialisation
*/
public static void init(Properties props, ResourceLoader res) throws InvalidDataException {
// Init properties & resources
mC2KProps.clear();
orbDestroyed = false;
mResource = res;
if (mResource == null)
mResource = new Resource();
// report version info
Logger.msg("Gateway.init() - Kernel version: " + getKernelVersion());
// the application to be able to configure castor
try {
mMarshaller = new CastorXMLUtility(mResource, props, mResource.getKernelResourceURL("mapFiles/"));
} catch (MalformedURLException e1) {
throw new InvalidDataException("Invalid Resource Location");
}
Properties allModuleProperties;
// init module manager
try {
mModules = new ModuleManager(AbstractMain.isServer);
allModuleProperties = mModules.loadModules(mResource.getModuleDefURLs());
} catch (Exception e) {
Logger.error(e);
throw new InvalidDataException("Could not load module definitions.");
}
// merge in module props
for (Enumeration<?> e = allModuleProperties.propertyNames(); e.hasMoreElements(); ) {
String propName = (String) e.nextElement();
mC2KProps.put(propName, allModuleProperties.get(propName));
}
// Overwrite with argument props
if (props != null)
mC2KProps.putAll(props);
// dump properties
Logger.msg("Gateway.init() - DONE");
dumpC2KProps(7);
}
use of org.cristalise.kernel.utils.CastorXMLUtility in project kernel by cristal-ise.
the class CastorXMLTest method testCastorItemPath.
@Test
public void testCastorItemPath() throws Exception {
CastorXMLUtility marshaller = Gateway.getMarshaller();
ItemPath item = new ItemPath(UUID.randomUUID(), ior);
ItemPath itemPrime = (ItemPath) marshaller.unmarshall(marshaller.marshall(item));
assertEquals(item.getUUID(), itemPrime.getUUID());
assertEquals(item.getIORString(), itemPrime.getIORString());
Logger.msg(marshaller.marshall(itemPrime));
}
use of org.cristalise.kernel.utils.CastorXMLUtility in project kernel by cristal-ise.
the class CastorXMLTest method testCastorDomainPath_Context.
@Test
public void testCastorDomainPath_Context() throws Exception {
CastorXMLUtility marshaller = Gateway.getMarshaller();
DomainPath domain = new DomainPath("/domain/path");
DomainPath domainPrime = (DomainPath) marshaller.unmarshall(marshaller.marshall(domain));
assertEquals(domain.getStringPath(), domainPrime.getStringPath());
Logger.msg(marshaller.marshall(domainPrime));
}
use of org.cristalise.kernel.utils.CastorXMLUtility in project kernel by cristal-ise.
the class CastorXMLTest method testCastorDomainPath_WithTarget.
@Test
public void testCastorDomainPath_WithTarget() throws Exception {
CastorXMLUtility marshaller = Gateway.getMarshaller();
DomainPath domain = new DomainPath("/domain/path", new ItemPath());
DomainPath domainPrime = (DomainPath) marshaller.unmarshall(marshaller.marshall(domain));
assertEquals(domain.getStringPath(), domainPrime.getStringPath());
assertEquals(domain.getTargetUUID(), domainPrime.getTargetUUID());
Logger.msg(marshaller.marshall(domainPrime));
}
Aggregations