use of com.cosylab.acs.maci.BadParametersException in project ACS by ACS-Community.
the class ManagerProxyImpl method get_container_info.
/**
* Get all the information that the Manager has about its known Containers.
* To invoke this method, the caller must have INTROSPECT_MANAGER access rights, or it must be the object whose info it is requesting.
* Calling this function does not affect the internal state of the Manager.
*
* @param id Identification of the caller.
* @param h Handles of the containers whose information is requested. If this is an empty sequence, the name_wc parameter is used.
* @param name_wc Wildcard that the container's name must match in order for its information to be returned.
* @return A sequence of ContainerInfo structures containing the entire Manager's knowledge about the containers.
* If access is denied to a subset of objects, the handles to those objects are set to 0.
*/
public ContainerInfo[] get_container_info(int id, int[] h, String name_wc) throws NoPermissionEx {
pendingRequests.incrementAndGet();
try {
// invalid info (replacement for null)
final ContainerInfo invalidInfo = new ContainerInfo("<invalid>", 0, null, new int[0]);
// returned value
ContainerInfo[] retVal = null;
// transform to CORBA specific
com.cosylab.acs.maci.ContainerInfo[] infos = manager.getContainerInfo(id, h, name_wc);
if (infos != null) {
retVal = new ContainerInfo[infos.length];
for (int i = 0; i < infos.length; i++) if (infos[i] == null)
retVal[i] = invalidInfo;
else
retVal[i] = new ContainerInfo(infos[i].getName(), infos[i].getHandle(), (Container) ((ContainerProxy) infos[i].getContainer()).getClient(), infos[i].getComponents().toArray());
} else
retVal = new ContainerInfo[0];
return retVal;
} catch (BadParametersException bpe) {
BadParametersException hbpe = new BadParametersException(bpe.getMessage(), bpe);
reportException(hbpe);
// rethrow CORBA specific
throw new BAD_PARAM(bpe.getMessage());
} catch (NoResourcesException nre) {
NoResourcesException hnre = new NoResourcesException(nre.getMessage(), nre);
reportException(hnre);
// rethrow CORBA specific
throw new NO_RESOURCES(nre.getMessage());
} catch (AcsJNoPermissionEx npe) {
// rethrow CORBA specific
throw npe.toNoPermissionEx();
} catch (Throwable ex) {
CoreException hce = new CoreException(ex.getMessage(), ex);
reportException(hce);
// rethrow CORBA specific
throw new UNKNOWN(ex.getMessage());
} finally {
pendingRequests.decrementAndGet();
}
}
use of com.cosylab.acs.maci.BadParametersException in project ACS by ACS-Community.
the class ManagerProxyImpl method restart_component.
/**
* Restarts an component.
* @param id identification of the caller. Called has to be an owner of the component.
* @param component_url CURL of the component to be restarted.
* @return CORBA reference of the restarted component, <code>null</code> if it fails.
*/
public Object restart_component(int id, String component_url) throws NoPermissionEx {
pendingRequests.incrementAndGet();
try {
// returned value
Object retVal = null;
// transform to CORBA specific
URI uri = null;
if (component_url != null)
uri = CURLHelper.createURI(component_url);
Component component = manager.restartComponent(id, uri);
// extract component CORBA reference
if (component != null)
retVal = (Object) component.getObject();
return retVal;
} catch (URISyntaxException usi) {
BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
reportException(hbpe);
// rethrow CORBA specific
throw new BAD_PARAM(usi.getMessage());
} catch (BadParametersException bpe) {
BadParametersException hbpe = new BadParametersException(bpe.getMessage(), bpe);
reportException(hbpe);
// rethrow CORBA specific
throw new BAD_PARAM(bpe.getMessage());
} catch (NoResourcesException nre) {
NoResourcesException hnre = new NoResourcesException(nre.getMessage(), nre);
reportException(hnre);
// rethrow CORBA specific
throw new NO_RESOURCES(nre.getMessage());
} catch (AcsJBadParameterEx bpe) {
reportException(bpe);
//throw bpe.toBadParameterEx();
throw new BAD_PARAM(bpe.getMessage());
} catch (AcsJNoPermissionEx npe) {
// rethrow CORBA specific
throw npe.toNoPermissionEx();
} catch (Throwable ex) {
CoreException hce = new CoreException(ex.getMessage(), ex);
reportException(hce);
// rethrow CORBA specific
throw new UNKNOWN(ex.getMessage());
} finally {
pendingRequests.decrementAndGet();
}
}
use of com.cosylab.acs.maci.BadParametersException in project ACS by ACS-Community.
the class ManagerImpl method releaseComponents.
/**
* Release components (using manager handle)
* @param infos components to release
*/
private void releaseComponents(ComponentInfo[] infos) throws AcsJNoPermissionEx {
if (infos.length > 0) {
// map strings to CURLs
URI[] uris = new URI[infos.length];
for (int i = 0; i < infos.length; i++) {
try {
uris[i] = CURLHelper.createURI(infos[i].getName());
} catch (URISyntaxException usi) {
BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
reportException(hbpe);
}
}
// release components
releaseComponents(getHandle(), uris);
}
}
use of com.cosylab.acs.maci.BadParametersException in project ACS by ACS-Community.
the class ManagerImpl method getDefaultComponent.
/*****************************************************************************/
/*********************** [ Dynamic (de)activation ] **************************/
/*****************************************************************************/
/**
* @see com.cosylab.acs.maci.Manager#getDefaultComponent(int, java.lang.String)
*/
// @todo MF not supported
public ComponentInfo getDefaultComponent(int id, String type) throws AcsJNoPermissionEx, NoDefaultComponentException {
if (type == null) {
// BAD_PARAM
BadParametersException af = new BadParametersException("Non-null 'type' expected.");
throw af;
}
/****************************************************************/
// check handle and NONE permissions
securityCheck(id, AccessRights.NONE);
logger.log(Level.INFO, "Getting default component for type '" + type + "'.");
ComponentInfo componentInfo = internalRequestDefaultComponent(id, type);
return componentInfo;
}
use of com.cosylab.acs.maci.BadParametersException in project ACS by ACS-Community.
the class ManagerImpl method internalNoSyncRestartComponent.
/**
* Internal method for restarting components.
*
* @param owner owner of the component.
* @param h handle of the component to be restarting.
* @return Newly restarted component, <code>null</code> if failed.
*/
// @todo MF not supported
private Component internalNoSyncRestartComponent(int owner, int h) throws AcsJNoPermissionEx {
int handle = h & HANDLE_MASK;
ComponentInfo componentInfo = null;
componentsLock.lock();
try {
if (components.isAllocated(handle))
componentInfo = (ComponentInfo) components.get(handle);
if (componentInfo == null || componentInfo.getHandle() != h) {
// invalid component handle
BadParametersException af = new BadParametersException("Invalid component handle.");
throw af;
}
// remove ownership of the component
if (!componentInfo.getClients().contains(owner)) {
// not an owner
AcsJNoPermissionEx npe = new AcsJNoPermissionEx();
npe.setReason("Restarting component that client does not own.");
npe.setID(HandleHelper.toString(owner));
npe.setProtectedResource(componentInfo.getName());
throw npe;
}
} finally {
componentsLock.unlock();
}
/****************** restart component ******************/
//
// get container
//
// search for container by its name
Container container = null;
ContainerInfo containerInfo = null;
int containerHandle = componentInfo.getContainer();
// if containerHandle equals 0, we have unavailable or registered component
if (containerHandle != 0) {
containerInfo = getContainerInfo(containerHandle);
if (containerInfo != null) {
checkContainerShutdownState(containerInfo);
container = containerInfo.getContainer();
}
// required container is not logged in
if (container == null) {
// then simply do not do the restart
String containerName;
if (containerInfo != null)
containerName = containerInfo.getName();
else
containerName = HandleHelper.toString(componentInfo.getContainer());
logger.log(Level.WARNING, "Container '" + containerName + "' required by component '" + componentInfo.getName() + "' is not logged in.");
}
}
// return value
Component component = null;
if (container != null) {
// restart component
try {
component = container.restart_component(componentInfo.getHandle());
if (component == null) {
RemoteException re = new RemoteException("Failed to restart component '" + componentInfo.getName() + "', 'null' returned.");
throw re;
}
// @todo what about notifying clients, marking component as available, updating reference...
} catch (Throwable ex) {
RemoteException re = new RemoteException("Failed to restart component '" + componentInfo.getName() + "' on container '" + containerInfo.getName() + "'.", ex);
logger.log(Level.SEVERE, re.getMessage(), re);
}
}
logger.log(Level.FINE, "Component '" + componentInfo.getName() + "' restarted.");
return component;
}
Aggregations