Search in sources :

Example 1 with CastorXMLUtility

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);
}
Also used : InvalidDataException(org.cristalise.kernel.common.InvalidDataException) CastorXMLUtility(org.cristalise.kernel.utils.CastorXMLUtility)

Example 2 with CastorXMLUtility

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);
}
Also used : MalformedURLException(java.net.MalformedURLException) Resource(org.cristalise.kernel.process.resource.Resource) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectProperties(org.cristalise.kernel.utils.ObjectProperties) Properties(java.util.Properties) ModuleManager(org.cristalise.kernel.process.module.ModuleManager) CastorXMLUtility(org.cristalise.kernel.utils.CastorXMLUtility) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) MalformedURLException(java.net.MalformedURLException) PersistencyException(org.cristalise.kernel.common.PersistencyException) CannotManageException(org.cristalise.kernel.common.CannotManageException)

Example 3 with CastorXMLUtility

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));
}
Also used : CastorXMLUtility(org.cristalise.kernel.utils.CastorXMLUtility) ItemPath(org.cristalise.kernel.lookup.ItemPath) MainTest(org.cristalise.kernel.test.process.MainTest) Test(org.junit.Test)

Example 4 with CastorXMLUtility

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));
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) CastorXMLUtility(org.cristalise.kernel.utils.CastorXMLUtility) MainTest(org.cristalise.kernel.test.process.MainTest) Test(org.junit.Test)

Example 5 with CastorXMLUtility

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));
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) CastorXMLUtility(org.cristalise.kernel.utils.CastorXMLUtility) ItemPath(org.cristalise.kernel.lookup.ItemPath) MainTest(org.cristalise.kernel.test.process.MainTest) Test(org.junit.Test)

Aggregations

CastorXMLUtility (org.cristalise.kernel.utils.CastorXMLUtility)8 MainTest (org.cristalise.kernel.test.process.MainTest)6 Test (org.junit.Test)6 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)2 DomainPath (org.cristalise.kernel.lookup.DomainPath)2 ItemPath (org.cristalise.kernel.lookup.ItemPath)2 MalformedURLException (java.net.MalformedURLException)1 Properties (java.util.Properties)1 CannotManageException (org.cristalise.kernel.common.CannotManageException)1 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)1 PersistencyException (org.cristalise.kernel.common.PersistencyException)1 GraphPoint (org.cristalise.kernel.graph.model.GraphPoint)1 GraphableEdge (org.cristalise.kernel.graph.model.GraphableEdge)1 Next (org.cristalise.kernel.lifecycle.instance.Next)1 AgentPath (org.cristalise.kernel.lookup.AgentPath)1 RolePath (org.cristalise.kernel.lookup.RolePath)1 ModuleManager (org.cristalise.kernel.process.module.ModuleManager)1 Resource (org.cristalise.kernel.process.resource.Resource)1 ObjectProperties (org.cristalise.kernel.utils.ObjectProperties)1