Search in sources :

Example 21 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class TraceableLocator method preinvoke.

/**
 ************************************************************************
 *
 *************************************************************************
 */
@Override
public org.omg.PortableServer.Servant preinvoke(byte[] oid, org.omg.PortableServer.POA poa, String operation, org.omg.PortableServer.ServantLocatorPackage.CookieHolder cookie) {
    ByteBuffer bb = ByteBuffer.wrap(oid);
    long msb = bb.getLong();
    long lsb = bb.getLong();
    ItemPath syskey = new ItemPath(new SystemKey(msb, lsb));
    Logger.msg(1, "===========================================================");
    Logger.msg(1, "Item called at " + new Timestamp(System.currentTimeMillis()) + ": " + operation + "(" + syskey + ").");
    try {
        return Gateway.getCorbaServer().getItem(syskey);
    } catch (ObjectNotFoundException ex) {
        Logger.error("ObjectNotFoundException::TraceableLocator::preinvoke() " + ex.toString());
        throw new org.omg.CORBA.OBJECT_NOT_EXIST();
    }
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ByteBuffer(java.nio.ByteBuffer) Timestamp(java.sql.Timestamp) SystemKey(org.cristalise.kernel.common.SystemKey) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 22 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class ImportItem method create.

/**
 */
@Override
public Path create(AgentPath agentPath, boolean reset) throws InvalidDataException, ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException, InvalidCollectionModification, PersistencyException {
    domainPath = new DomainPath(new DomainPath(initialPath), name);
    if (domainPath.exists()) {
        ItemPath domItem = domainPath.getItemPath();
        if (!getItemPath().equals(domItem)) {
            throw new CannotManageException("Item " + domainPath + " was found with the wrong itemPath (" + domainPath.getItemPath() + " vs " + getItemPath() + ")");
        }
    } else
        isDOMPathExists = false;
    TraceableEntity newItem = getTraceableEntitiy();
    // (re)initialise the new item with properties, workflow and collections
    try {
        newItem.initialise(agentPath.getSystemKey(), Gateway.getMarshaller().marshall(createItemProperties()), Gateway.getMarshaller().marshall(createCompositeActivity()), Gateway.getMarshaller().marshall(createCollections()));
    } catch (Exception ex) {
        Logger.error("Error initialising new item " + ns + "/" + name);
        Logger.error(ex);
        if (isNewItem)
            Gateway.getLookupManager().delete(itemPath);
        throw new CannotManageException("Problem initialising new item. See server log:" + ex.getMessage());
    }
    History hist = new History(getItemPath(), null);
    // import outcomes
    for (ImportOutcome thisOutcome : outcomes) {
        String outcomeData = thisOutcome.getData(ns);
        // load schema and state machine
        Schema schema = LocalObjectLoader.getSchema(thisOutcome.schema, thisOutcome.version);
        // parse new outcome and validate
        Outcome newOutcome = new Outcome(-1, outcomeData, schema);
        newOutcome.validateAndCheck();
        Viewpoint impView;
        try {
            impView = (Viewpoint) Gateway.getStorage().get(getItemPath(), ClusterType.VIEWPOINT + "/" + thisOutcome.schema + "/" + thisOutcome.viewname, null);
            if (newOutcome.isIdentical(impView.getOutcome())) {
                Logger.msg(5, "ImportItem.create() - View " + thisOutcome.schema + "/" + thisOutcome.viewname + " in " + ns + "/" + name + " identical, no update required");
                continue;
            } else {
                Logger.msg("ImportItem.create() - Difference found in view " + thisOutcome.schema + "/" + thisOutcome.viewname + " in " + ns + "/" + name);
                if (!reset && !impView.getEvent().getStepPath().equals("Import")) {
                    Logger.msg("ImportItem.create() - Last edit was not done by import, and reset not requested. Not overwriting.");
                    continue;
                }
            }
        } catch (ObjectNotFoundException ex) {
            Logger.msg("ImportItem.create() - View " + thisOutcome.schema + "/" + thisOutcome.viewname + " not found in " + ns + "/" + name + ". Creating.");
            impView = new Viewpoint(getItemPath(), schema, thisOutcome.viewname, -1);
        }
        // write new view/outcome/event
        Event newEvent = hist.addEvent(agentPath, null, "Admin", "Import", "Import", "Import", schema, Bootstrap.getPredefSM(), PredefinedStep.DONE, thisOutcome.viewname);
        newOutcome.setID(newEvent.getID());
        impView.setEventId(newEvent.getID());
        Gateway.getStorage().put(getItemPath(), newOutcome, null);
        Gateway.getStorage().put(getItemPath(), impView, null);
    }
    // register domain path (before collections in case of recursive collections)
    if (!isDOMPathExists) {
        domainPath.setItemPath(getItemPath());
        Gateway.getLookupManager().add(domainPath);
    }
    return domainPath;
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) CannotManageException(org.cristalise.kernel.common.CannotManageException) Schema(org.cristalise.kernel.persistency.outcome.Schema) History(org.cristalise.kernel.events.History) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) PersistencyException(org.cristalise.kernel.common.PersistencyException) CannotManageException(org.cristalise.kernel.common.CannotManageException) TraceableEntity(org.cristalise.kernel.entity.TraceableEntity) Outcome(org.cristalise.kernel.persistency.outcome.Outcome) Viewpoint(org.cristalise.kernel.persistency.outcome.Viewpoint) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) Event(org.cristalise.kernel.events.Event) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 23 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class CreateAgentFromDescription method runActivityLogic.

/**
 * Params:
 * <ol>
 * <li>Agent name</li>
 * <li>Domain context</li>
 * <li>Comma-delimited Role names to assign to the Agent</li>
 * <li>Password (optional)</li>
 * <li>Initial properties to set in the new Agent (optional)</li>
 * <li>Description version to use(optional)</li>
 * </ol>
 * @throws ObjectNotFoundException
 * @throws InvalidDataException The input parameters were incorrect
 * @throws ObjectAlreadyExistsException The Agent already exists
 * @throws CannotManageException The Agent could not be created
 * @throws ObjectCannotBeUpdated The addition of the new entries into the LookupManager failed
 * @throws PersistencyException
 * @see org.cristalise.kernel.lifecycle.instance.predefined.item.CreateItemFromDescription#runActivityLogic(AgentPath, ItemPath, int, String, Object)
 */
@Override
protected String runActivityLogic(AgentPath agentPath, ItemPath descItemPath, int transitionID, String requestData, Object locker) throws ObjectNotFoundException, InvalidDataException, ObjectAlreadyExistsException, CannotManageException, ObjectCannotBeUpdated, PersistencyException {
    String[] input = getDataList(requestData);
    String newName = input[0];
    String contextS = input[1];
    String[] roles = input[2].split(",");
    String pwd = input.length > 3 ? input[3] : "";
    String descVer = input.length > 4 ? input[4] : "last";
    PropertyArrayList initProps = input.length > 5 ? unmarshallInitProperties(input[5]) : new PropertyArrayList();
    // generate new agent path with new UUID
    Logger.msg(1, "CreateAgentFromDescription - Requesting new agent path name:" + newName);
    AgentPath newAgentPath = new AgentPath(new ItemPath(), newName);
    // check if the agent's name is already taken
    if (Gateway.getLookup().exists(newAgentPath))
        throw new ObjectAlreadyExistsException("The agent name " + newName + " exists already.");
    DomainPath context = new DomainPath(new DomainPath(contextS), newName);
    if (context.exists())
        throw new ObjectAlreadyExistsException("The path " + context + " exists already.");
    ActiveEntity newAgent = createAgentAddRoles(newAgentPath, roles, pwd);
    initialiseItem(newAgent, agentPath, descItemPath, initProps, newName, descVer, context, newAgentPath, locker);
    // censor password from outcome
    if (input.length > 3)
        input[3] = "REDACTED";
    return bundleData(input);
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) AgentPath(org.cristalise.kernel.lookup.AgentPath) PropertyArrayList(org.cristalise.kernel.property.PropertyArrayList) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) ActiveEntity(org.cristalise.kernel.entity.agent.ActiveEntity) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 24 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class ProxyManager method getProxy.

public ItemProxy getProxy(Path path) throws ObjectNotFoundException {
    ItemPath itemPath;
    if (path instanceof ItemPath)
        itemPath = (ItemPath) path;
    else
        itemPath = path.getItemPath();
    Logger.msg(8, "ProxyManager::getProxy(" + path.toString() + ")");
    return getProxy(itemPath.getIOR(), itemPath);
}
Also used : ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 25 with ItemPath

use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.

the class ProxyManager method reportCurrentProxies.

/**
 * A utility to Dump the current proxies loaded
 *
 * @param logLevel the selectd log level
 */
public void reportCurrentProxies(int logLevel) {
    if (!Logger.doLog(logLevel))
        return;
    Logger.msg(logLevel, "Current proxies: ");
    try {
        synchronized (proxyPool) {
            Iterator<ItemPath> i = proxyPool.keySet().iterator();
            for (int count = 0; i.hasNext(); count++) {
                ItemPath nextProxy = i.next();
                ItemProxy thisProxy = proxyPool.get(nextProxy);
                if (thisProxy != null) {
                    Logger.msg(logLevel, "" + count + ": " + proxyPool.get(nextProxy).getClass().getName() + ": " + nextProxy);
                }
            }
        }
    } catch (ConcurrentModificationException ex) {
        Logger.msg(logLevel, "Proxy cache modified. Aborting.");
    }
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Aggregations

ItemPath (org.cristalise.kernel.lookup.ItemPath)36 DomainPath (org.cristalise.kernel.lookup.DomainPath)16 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)14 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)10 PersistencyException (org.cristalise.kernel.common.PersistencyException)10 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)10 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)6 C2KLocalObject (org.cristalise.kernel.entity.C2KLocalObject)5 CannotManageException (org.cristalise.kernel.common.CannotManageException)4 AgentPath (org.cristalise.kernel.lookup.AgentPath)4 Test (org.junit.Test)4 Aggregation (org.cristalise.kernel.collection.Aggregation)3 TraceableEntity (org.cristalise.kernel.entity.TraceableEntity)3 Path (org.cristalise.kernel.lookup.Path)3 Property (org.cristalise.kernel.property.Property)3 PropertyDescription (org.cristalise.kernel.property.PropertyDescription)3 PropertyDescriptionList (org.cristalise.kernel.property.PropertyDescriptionList)3 ConcurrentModificationException (java.util.ConcurrentModificationException)2 StringTokenizer (java.util.StringTokenizer)2 Dependency (org.cristalise.kernel.collection.Dependency)2