Search in sources :

Example 1 with Item

use of org.cristalise.kernel.entity.Item in project kernel by cristal-ise.

the class ProxyLoader method get.

/**
 * retrieve object by path
 */
@Override
public C2KLocalObject get(ItemPath thisItem, String path) throws PersistencyException {
    try {
        Item thisEntity = getIOR(thisItem);
        ClusterType type = getClusterType(path);
        // fetch the xml from the item
        String queryData = thisEntity.queryData(path);
        if (Logger.doLog(8))
            Logger.msg("ProxyLoader.get() - " + thisItem + " : " + path + " = " + queryData);
        if (queryData != null) {
            if (type == ClusterType.OUTCOME)
                return new Outcome(path, queryData);
            else
                return (C2KLocalObject) Gateway.getMarshaller().unmarshall(queryData);
        }
    } catch (ObjectNotFoundException e) {
        return null;
    } catch (Exception e) {
        Logger.error(e);
        throw new PersistencyException(e.getMessage());
    }
    return null;
}
Also used : Item(org.cristalise.kernel.entity.Item) Outcome(org.cristalise.kernel.persistency.outcome.Outcome) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) PersistencyException(org.cristalise.kernel.common.PersistencyException) ClusterType(org.cristalise.kernel.persistency.ClusterType) PersistencyException(org.cristalise.kernel.common.PersistencyException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException)

Example 2 with Item

use of org.cristalise.kernel.entity.Item in project kernel by cristal-ise.

the class ProxyLoader method getClusterContents.

/**
 * Directory listing
 */
@Override
public String[] getClusterContents(ItemPath thisItem, String path) throws PersistencyException {
    try {
        Item thisEntity = getIOR(thisItem);
        String contents = thisEntity.queryData(path + "/all");
        StringTokenizer tok = new StringTokenizer(contents, ",");
        String[] result = new String[tok.countTokens()];
        for (int i = 0; i < result.length; i++) result[i] = tok.nextToken();
        return result;
    } catch (Exception e) {
        Logger.error(e);
        throw new PersistencyException(e.getMessage());
    }
}
Also used : Item(org.cristalise.kernel.entity.Item) StringTokenizer(java.util.StringTokenizer) PersistencyException(org.cristalise.kernel.common.PersistencyException) PersistencyException(org.cristalise.kernel.common.PersistencyException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException)

Example 3 with Item

use of org.cristalise.kernel.entity.Item in project kernel by cristal-ise.

the class ProxyLoader method getIOR.

private Item getIOR(ItemPath thisPath) throws PersistencyException {
    // check the cache
    if (entities.containsKey(thisPath)) {
        Logger.msg(8, "ProxyLoader.getIOR() - " + thisPath + " cached.");
        return entities.get(thisPath);
    }
    try {
        Logger.msg(8, "ProxyLoader.getIOR() - Resolving " + thisPath + ".");
        org.omg.CORBA.Object ior = thisPath.getIOR();
        Item thisItem = null;
        try {
            thisItem = ItemHelper.narrow(ior);
        } catch (org.omg.CORBA.BAD_PARAM ex) {
            try {
                thisItem = AgentHelper.narrow(ior);
            } catch (org.omg.CORBA.BAD_PARAM ex2) {
                throw new PersistencyException("Could not narrow " + thisItem + " as a known Entity type");
            }
        }
        Logger.msg(8, "ProxyLoader.getIOR() - Found " + thisItem + ".");
        entities.put(thisPath, thisItem);
        return thisItem;
    } catch (Exception e) {
        throw new PersistencyException("Error narrowing " + thisPath + ": " + e.getMessage());
    }
}
Also used : Item(org.cristalise.kernel.entity.Item) PersistencyException(org.cristalise.kernel.common.PersistencyException) PersistencyException(org.cristalise.kernel.common.PersistencyException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException)

Aggregations

ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)3 PersistencyException (org.cristalise.kernel.common.PersistencyException)3 Item (org.cristalise.kernel.entity.Item)3 StringTokenizer (java.util.StringTokenizer)1 ClusterType (org.cristalise.kernel.persistency.ClusterType)1 Outcome (org.cristalise.kernel.persistency.outcome.Outcome)1