Search in sources :

Example 11 with Property

use of org.cristalise.kernel.property.Property in project kernel by cristal-ise.

the class Activity method getTypeName.

public String getTypeName() {
    if (mType == null)
        return null;
    if (mTypeName == null) {
        try {
            ItemPath actType = new ItemPath(mType);
            Property nameProp = (Property) Gateway.getStorage().get(actType, ClusterType.PROPERTY + "/" + NAME, null);
            mTypeName = nameProp.getValue();
        } catch (Exception e) {
            mTypeName = mType;
        }
    }
    return mTypeName;
}
Also used : Property(org.cristalise.kernel.property.Property) WriteProperty(org.cristalise.kernel.lifecycle.instance.predefined.WriteProperty) XPathExpressionException(javax.xml.xpath.XPathExpressionException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) AccessRightsException(org.cristalise.kernel.common.AccessRightsException) InvalidTransitionException(org.cristalise.kernel.common.InvalidTransitionException) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) PersistencyException(org.cristalise.kernel.common.PersistencyException) CannotManageException(org.cristalise.kernel.common.CannotManageException) InvalidAgentPathException(org.cristalise.kernel.lookup.InvalidAgentPathException) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 12 with Property

use of org.cristalise.kernel.property.Property in project kernel by cristal-ise.

the class WriteProperty method write.

public static void write(ItemPath item, String name, String value, Object locker) throws PersistencyException, ObjectCannotBeUpdated, ObjectNotFoundException {
    Property prop = (Property) Gateway.getStorage().get(item, ClusterType.PROPERTY + "/" + name, locker);
    if (!prop.isMutable() && !value.equals(prop.getValue()))
        throw new ObjectCannotBeUpdated("WriteProperty: Property '" + name + "' is not mutable.");
    prop.setValue(value);
    Gateway.getStorage().put(item, prop, locker);
}
Also used : ObjectCannotBeUpdated(org.cristalise.kernel.common.ObjectCannotBeUpdated) Property(org.cristalise.kernel.property.Property)

Example 13 with Property

use of org.cristalise.kernel.property.Property in project kernel by cristal-ise.

the class ImportAgent method create.

@Override
public Path create(AgentPath agentPath, boolean reset) throws ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException, ObjectAlreadyExistsException {
    if (roles.isEmpty())
        throw new ObjectNotFoundException("Agent '" + name + "' must declare at least one Role ");
    AgentPath newAgent = new AgentPath(getItemPath(), name);
    ActiveEntity newAgentEnt = Gateway.getCorbaServer().createAgent(newAgent);
    Gateway.getLookupManager().add(newAgent);
    // assemble properties
    properties.add(new Property(NAME, name, true));
    properties.add(new Property(TYPE, "Agent", false));
    try {
        if (StringUtils.isNotBlank(password))
            Gateway.getLookupManager().setAgentPassword(newAgent, password);
        newAgentEnt.initialise(agentPath.getSystemKey(), Gateway.getMarshaller().marshall(new PropertyArrayList(properties)), null, null);
    } catch (Exception ex) {
        Logger.error(ex);
        throw new CannotManageException("Error initialising new agent name:" + name);
    }
    for (ImportRole role : roles) {
        RolePath thisRole = (RolePath) role.create(agentPath, reset);
        Gateway.getLookupManager().addRole(newAgent, thisRole);
    }
    return newAgent;
}
Also used : CannotManageException(org.cristalise.kernel.common.CannotManageException) AgentPath(org.cristalise.kernel.lookup.AgentPath) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) PropertyArrayList(org.cristalise.kernel.property.PropertyArrayList) Property(org.cristalise.kernel.property.Property) ActiveEntity(org.cristalise.kernel.entity.agent.ActiveEntity) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) CannotManageException(org.cristalise.kernel.common.CannotManageException) RolePath(org.cristalise.kernel.lookup.RolePath)

Example 14 with Property

use of org.cristalise.kernel.property.Property in project kernel by cristal-ise.

the class ItemProxy method getProperty.

/**
 * Retrieves the values of a named property
 *
 * @param name of the Item Property
 * @return the value of the property
 * @throws ObjectNotFoundException property was not found
 */
public String getProperty(String name) throws ObjectNotFoundException {
    Logger.msg(5, "ItemProxy.getProperty() - " + name + " from item " + mItemPath);
    Property prop = (Property) getObject(ClusterType.PROPERTY + "/" + name);
    if (prop != null)
        return prop.getValue();
    else
        throw new ObjectNotFoundException("ItemProxy.getProperty() - COULD not find property " + name + " from item " + mItemPath);
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) Property(org.cristalise.kernel.property.Property)

Example 15 with Property

use of org.cristalise.kernel.property.Property in project kernel by cristal-ise.

the class Bootstrap method createServerItem.

public static void createServerItem() throws Exception {
    LookupManager lookupManager = Gateway.getLookupManager();
    String serverName = Gateway.getProperties().getString("ItemServer.name", InetAddress.getLocalHost().getHostName());
    thisServerPath = new DomainPath("/servers/" + serverName);
    ItemPath serverItem;
    try {
        serverItem = thisServerPath.getItemPath();
    } catch (ObjectNotFoundException ex) {
        Logger.msg("Creating server item " + thisServerPath);
        serverItem = new ItemPath();
        Gateway.getCorbaServer().createItem(serverItem);
        lookupManager.add(serverItem);
        thisServerPath.setItemPath(serverItem);
        lookupManager.add(thisServerPath);
    }
    int proxyPort = Gateway.getProperties().getInt("ItemServer.Proxy.port", 1553);
    Gateway.getStorage().put(serverItem, new Property(NAME, serverName, false), null);
    Gateway.getStorage().put(serverItem, new Property(TYPE, "Server", false), null);
    Gateway.getStorage().put(serverItem, new Property(KERNEL_VERSION, Gateway.getKernelVersion(), true), null);
    Gateway.getStorage().put(serverItem, new Property("ProxyPort", String.valueOf(proxyPort), false), null);
    Gateway.getStorage().put(serverItem, new Property("ConsolePort", String.valueOf(Logger.getConsolePort()), true), null);
    Gateway.getProxyManager().connectToProxyServer(serverName, proxyPort);
}
Also used : DomainPath(org.cristalise.kernel.lookup.DomainPath) LookupManager(org.cristalise.kernel.lookup.LookupManager) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) Property(org.cristalise.kernel.property.Property) Viewpoint(org.cristalise.kernel.persistency.outcome.Viewpoint) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Aggregations

Property (org.cristalise.kernel.property.Property)19 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)10 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)6 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)6 PropertyArrayList (org.cristalise.kernel.property.PropertyArrayList)6 DomainPath (org.cristalise.kernel.lookup.DomainPath)4 ItemPath (org.cristalise.kernel.lookup.ItemPath)4 PersistencyException (org.cristalise.kernel.common.PersistencyException)3 AgentPath (org.cristalise.kernel.lookup.AgentPath)3 LookupManager (org.cristalise.kernel.lookup.LookupManager)3 Viewpoint (org.cristalise.kernel.persistency.outcome.Viewpoint)3 StringTokenizer (java.util.StringTokenizer)2 CollectionArrayList (org.cristalise.kernel.collection.CollectionArrayList)2 AccessRightsException (org.cristalise.kernel.common.AccessRightsException)2 CannotManageException (org.cristalise.kernel.common.CannotManageException)2 InvalidCollectionModification (org.cristalise.kernel.common.InvalidCollectionModification)2 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)2 CompositeActivity (org.cristalise.kernel.lifecycle.instance.CompositeActivity)2 Workflow (org.cristalise.kernel.lifecycle.instance.Workflow)2 Outcome (org.cristalise.kernel.persistency.outcome.Outcome)2