use of alma.maciErrType.wrappers.AcsJNoPermissionEx in project ACS by ACS-Community.
the class ManagerImplTest method internalTestGetHierarchicalComponent.
public void internalTestGetHierarchicalComponent(boolean activateOnActivation) {
try {
TestContainer container = new TestContainer("Container");
Map supportedComponents = new HashMap();
TestHierarchicalComponent mount2HierCOB = new TestHierarchicalComponent("HierarchicalCOB2", manager, new String[] { "MOUNT3" }, false, activateOnActivation);
TestHierarchicalComponent mount3HierCOB = new TestHierarchicalComponent("HierarchicalCOB3", manager, new String[] { "MOUNT4" }, false, activateOnActivation);
Component mount4COB = new TestComponent("MOUNT4");
supportedComponents.put("MOUNT2", mount2HierCOB);
supportedComponents.put("MOUNT3", mount3HierCOB);
supportedComponents.put("MOUNT4", mount4COB);
container.setSupportedComponents(supportedComponents);
// test case when container is unable to activate startup Component - MOUNT1
ClientInfo containerInfo = manager.login(container);
TestAdministrator client = new TestAdministrator(administratorName);
ClientInfo info = manager.login(client);
// test ordinary activation
URI mount2URI;
try {
mount2URI = new URI("MOUNT2");
StatusHolder status = new StatusHolder();
Component ref = manager.getComponent(info.getHandle(), mount2URI, true, status);
assertEquals(mount2HierCOB, ref);
assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
} catch (Exception ex) {
fail();
}
try {
Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
// test activated Components
// there should be all three Components activated
ComponentInfo[] infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
assertEquals(3, infos.length);
// container logout and login
manager.logout(containerInfo.getHandle());
try {
Thread.sleep(SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
// test activated Components
// there should be no Components activated
infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
assertEquals(0, infos.length);
manager.login(container);
try {
Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
// test activated Components
// there should be all three Components activated
infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
assertEquals(3, infos.length);
// logout client
manager.logout(info.getHandle());
try {
Thread.sleep(SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
} catch (AcsJNoPermissionEx e) {
fail("No permission");
}
}
use of alma.maciErrType.wrappers.AcsJNoPermissionEx in project ACS by ACS-Community.
the class ManagerImplTest method testContainerInfo.
public void testContainerInfo() {
try {
//test invalid
try {
manager.getContainerInfo(0, null, null);
fail();
} catch (BadParametersException bpe) {
System.out.println("This is OK: " + bpe.getMessage());
}
//test invalid
try {
manager.getContainerInfo(Integer.MAX_VALUE, null, null);
fail();
} catch (BadParametersException bpe) {
System.out.println("This is OK: " + bpe.getMessage());
}
//test invalid
try {
manager.getContainerInfo(dummyHandle, null, null);
fail();
} catch (BadParametersException bpe) {
System.out.println("This is OK: " + bpe.getMessage());
}
//test invalid
try {
manager.getContainerInfo(dummyHandle, new int[0], null);
fail();
} catch (BadParametersException bpe) {
System.out.println("This is OK: " + bpe.getMessage());
}
//test invalid
try {
manager.getContainerInfo(dummyHandle, new int[0], "non-null");
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
/*
//test invalid regular expression
try {
manager.getContainerInfo(dummyHandle, new int[0], ")");
fail();
}
catch (BadParametersException bpe)
{
System.out.println("This is OK: "+bpe.getMessage());
}
*/
//test valid
ClientInfo info = manager.login(new TestContainer(containerName));
int[] handles = { info.getHandle() };
ContainerInfo[] infos = manager.getContainerInfo(info.getHandle(), handles, null);
assertNotNull(infos);
assertEquals(infos.length, 1);
assertEquals(infos[0].getHandle(), info.getHandle());
manager.logout(info.getHandle());
//test inaccessible
info = manager.login(new TestContainer(containerName));
ClientInfo anotherInfo = manager.login(new TestContainer(anotherName));
handles[0] = anotherInfo.getHandle();
try {
infos = manager.getContainerInfo(info.getHandle(), handles, null);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
try {
manager.getClientInfo(info.getHandle(), new int[0], anotherName);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
manager.logout(info.getHandle());
manager.logout(anotherInfo.getHandle());
//test with INTROSPECTION_MANAGER rights
info = manager.login(new TestContainer(containerName));
ClientInfo adminInfo = manager.login(new TestAdministrator(administratorName));
handles = new int[3];
handles[0] = adminInfo.getHandle();
handles[1] = info.getHandle();
handles[2] = dummyHandle;
infos = manager.getContainerInfo(adminInfo.getHandle(), handles, null);
assertNotNull(infos);
assertNull(infos[0]);
assertEquals(infos[1].getHandle(), info.getHandle());
assertNull(infos[2]);
manager.logout(info.getHandle());
manager.logout(adminInfo.getHandle());
// test wildcard search
info = manager.login(new TestContainer("container1"));
assertNotNull(info);
ClientInfo info2 = manager.login(new TestContainer("container2a"));
assertNotNull(info2);
ClientInfo info3 = manager.login(new TestContainer("container3aa"));
assertNotNull(info3);
ClientInfo info4 = manager.login(new TestContainer("other4"));
assertNotNull(info4);
adminInfo = manager.login(new TestAdministrator("admin"));
assertNotNull(adminInfo);
//infos = manager.getContainerInfo(adminInfo.getHandle(), new int[0], "container.*");
infos = manager.getContainerInfo(adminInfo.getHandle(), new int[0], "container*");
assertNotNull(infos);
assertEquals(3, infos.length);
assertEquals(info.getHandle(), infos[0].getHandle());
assertEquals(info2.getHandle(), infos[1].getHandle());
assertEquals(info3.getHandle(), infos[2].getHandle());
manager.logout(info.getHandle());
manager.logout(info2.getHandle());
manager.logout(info3.getHandle());
manager.logout(info4.getHandle());
manager.logout(adminInfo.getHandle());
} catch (AcsJNoPermissionEx e) {
fail("No permission");
}
}
use of alma.maciErrType.wrappers.AcsJNoPermissionEx in project ACS by ACS-Community.
the class ManagerProxyImpl method get_dynamic_component.
/**
* Activation of an dynamic component.
* @param id identification of the caller.
* @param c component to be obtained.
* @param mark_as_default mark component as default component of its type.
* @return <code>ComponentInfo</code> of requested component.
*/
public ComponentInfo get_dynamic_component(int id, si.ijs.maci.ComponentSpec c, boolean mark_as_default) throws NoPermissionEx, IncompleteComponentSpecEx, InvalidComponentSpecEx, ComponentSpecIncompatibleWithActiveComponentEx, CannotGetComponentEx {
pendingRequests.incrementAndGet();
try {
// returned value
ComponentInfo retVal = null;
/*
URI uri = null;
if (c.component_name != null)
uri = CURLHelper.createURI(c.component_name);
ComponentSpec componentSpec = new ComponentSpec(uri, c.component_type, c.component_code, c.container_name);
*/
// @todo si.ijs.maci.COMPONENT_SPEC_ANY -> ComponentSpec.COMPSPEC_ANY
ComponentSpec componentSpec = new ComponentSpec(c.component_name, c.component_type, c.component_code, c.container_name);
com.cosylab.acs.maci.ComponentInfo info = manager.getDynamicComponent(id, componentSpec, mark_as_default);
// transform to CORBA specific
if (info == null || info.getComponent() == null)
throw new AcsJCannotGetComponentEx();
Object obj = null;
obj = (Object) info.getComponent().getObject();
String[] interfaces;
if (info.getInterfaces() != null)
interfaces = info.getInterfaces();
else
interfaces = new String[0];
retVal = new ComponentInfo(info.getType(), info.getCode(), obj, info.getName(), info.getClients().toArray(), info.getContainer(), info.getContainerName(), info.getHandle(), mapAccessRights(info.getAccessRights()), interfaces);
return retVal;
}/*
catch (URISyntaxException usi)
{
BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
hbpe.caughtIn(this, "get_dynamic_component");
hbpe.putValue("c.component_name", c.component_name);
// exception service will handle this
reportException(hbpe);
// rethrow CORBA specific
throw new BAD_PARAM(usi.getMessage());
}*/
catch (AcsJInvalidComponentSpecEx ics) {
// rethrow CORBA specific
throw ics.toInvalidComponentSpecEx();
} catch (AcsJIncompleteComponentSpecEx ics) {
// rethrow CORBA specific
throw ics.toIncompleteComponentSpecEx();
} catch (AcsJComponentSpecIncompatibleWithActiveComponentEx cpiwac) {
// rethrow CORBA specific
throw cpiwac.toComponentSpecIncompatibleWithActiveComponentEx();
} catch (AcsJNoPermissionEx npe) {
// rethrow CORBA specific
throw npe.toNoPermissionEx();
} 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 (AcsJCannotGetComponentEx cgce) {
reportException(cgce);
// rethrow CORBA specific
throw cgce.toCannotGetComponentEx();
} catch (Throwable ex) {
CoreException hce = new CoreException(ex.getMessage(), ex);
reportException(hce);
// rethrow CORBA specific
throw new UNKNOWN(ex.getMessage());
} finally {
pendingRequests.decrementAndGet();
}
}
Aggregations