use of org.cristalise.kernel.common.AccessRightsException in project kernel by cristal-ise.
the class ItemProxy method setProperty.
/**
* Sets the vlaue of the given Property
*
* @param agent the Agent who is setting the Property
* @param name the name of the Property
* @param value the value of the Property
* @throws AccessRightsException Agent does not the rights to execute this operation
* @throws PersistencyException there was a database problems during this operations
* @throws InvalidDataException data was invalid
*/
public void setProperty(AgentProxy agent, String name, String value) throws AccessRightsException, PersistencyException, InvalidDataException {
try {
String[] params = { name, value };
agent.execute(this, "WriteProperty", params);
} catch (AccessRightsException | PersistencyException | InvalidDataException e) {
throw (e);
} catch (Exception e) {
Logger.error(e);
throw new PersistencyException("Could not store property:" + e.getMessage());
}
}
use of org.cristalise.kernel.common.AccessRightsException in project kernel by cristal-ise.
the class Transition method getPerformingRole.
public String getPerformingRole(Activity act, AgentPath agent) throws ObjectNotFoundException, AccessRightsException {
// check available
if (!isEnabled(act))
throw new AccessRightsException("Trans:" + toString() + " is disabled by the '" + enabledProp + "' property.");
// check active
if (isRequiresActive() && !act.getActive())
throw new AccessRightsException("Activity must be active to perform trans:" + toString());
String overridingRole = getRoleOverride(act.getProperties());
boolean override = overridingRole != null;
boolean isOwner = false, isOwned = true;
// Check agent name
String agentName = act.getCurrentAgentName();
if (StringUtils.isNotBlank(agentName)) {
if (agent.getAgentName().equals(agentName))
isOwner = true;
} else
isOwned = false;
List<RolePath> roles = new ArrayList<RolePath>();
// determine transition role
if (override) {
roles.add(Gateway.getLookup().getRolePath(overridingRole));
} else {
String actRole = act.getCurrentAgentRole();
if (StringUtils.isNotBlank(actRole)) {
for (String role : actRole.split(",")) {
roles.add(Gateway.getLookup().getRolePath(role.trim()));
}
}
}
// Decide the access
if (isOwned && !override && !isOwner)
throw new AccessRightsException("Agent '" + agent.getAgentName() + "' cannot perform this trans:" + toString() + " because the activity '" + act.getName() + "' is currently owned by " + agentName);
if (roles.size() != 0) {
RolePath matchingRole = agent.getFirstMatchingRole(roles);
if (matchingRole != null)
return matchingRole.getName();
else if (agent.hasRole("Admin"))
return "Admin";
else
throw new AccessRightsException("Agent '" + agent.getAgentName() + "' does not hold a suitable role '" + act.getCurrentAgentRole() + "' for the activity " + act.getName());
} else
return null;
}
use of org.cristalise.kernel.common.AccessRightsException in project kernel by cristal-ise.
the class CreateItemFromDescription method initialiseItem.
/**
* @param agent
* @param descItemPath
* @param locker
* @param input
* @param newName
* @param descVer
* @param context
* @param newItemPath
* @param newItem
* @throws ObjectCannotBeUpdated
* @throws CannotManageException
* @throws InvalidDataException
* @throws ObjectAlreadyExistsException
* @throws PersistencyException
* @throws ObjectNotFoundException
*/
protected void initialiseItem(ItemOperations newItem, AgentPath agent, ItemPath descItemPath, PropertyArrayList initProps, String newName, String descVer, DomainPath context, ItemPath newItemPath, Object locker) throws ObjectCannotBeUpdated, CannotManageException, InvalidDataException, ObjectAlreadyExistsException, PersistencyException, ObjectNotFoundException {
// initialise it with its properties and workflow
Logger.msg(3, "CreateItemFromDescription.initialiseItem() - Initializing Item:" + newName);
try {
PropertyArrayList newProps = instantiateProperties(descItemPath, descVer, initProps, newName, agent, locker);
CollectionArrayList newColls = instantiateCollections(descItemPath, descVer, newProps, locker);
CompositeActivity newWorkflow = instantiateWorkflow(descItemPath, descVer, locker);
newItem.initialise(agent.getSystemKey(), Gateway.getMarshaller().marshall(newProps), Gateway.getMarshaller().marshall(newWorkflow), Gateway.getMarshaller().marshall(newColls));
} catch (MarshalException | ValidationException | AccessRightsException | IOException | MappingException | InvalidCollectionModification e) {
Logger.error(e);
Gateway.getLookupManager().delete(newItemPath);
throw new InvalidDataException("CreateItemFromDescription: Problem initializing new Item. See log: " + e.getMessage());
} catch (InvalidDataException | ObjectNotFoundException | PersistencyException e) {
Logger.error(e);
Gateway.getLookupManager().delete(newItemPath);
throw e;
}
// add its domain path
Logger.msg(3, "CreateItemFromDescription - Creating " + context);
context.setItemPath(newItemPath);
Gateway.getLookupManager().add(context);
}
Aggregations