use of alma.maciErrType.NoPermissionEx in project ACS by ACS-Community.
the class MaciSupervisor method refreshNow.
/**
* Tries to refresh the component-section, container-section, and client-section
* of the info tree model. The treemodel will be updated when things go well
* and also when things fail.
*
* A call to this method will instantly perform a refresh, possibly
* throwing an exception or blocking the current thread for a long time. Calling
* {@link #getMaciInformation()} and {@link #refreshSoon()} will shield you from
* these effects.
*
* @throws NoPermissionEx error during refresh
* @throws NotConnectedToManagerException error during refresh
* @throws CorbaTransientException
* @throws CorbaNotExistException
* @throws UnknownErrorException
*/
public synchronized void refreshNow() throws NoPermissionEx, NotConnectedToManagerException, SystemException, CorbaTransientException, CorbaNotExistException, UnknownErrorException {
log.fine(read + "retrieving acs deployment info from acs manager");
List<ComponentInfo> newComponents = Collections.EMPTY_LIST;
List<ContainerInfo> newContainers = Collections.EMPTY_LIST;
List<ClientInfo> newClientApps = Collections.EMPTY_LIST;
Map<Object, String> newAuxiliary = Collections.EMPTY_MAP;
boolean nothingChanged = false;
try {
try {
// retrieve data from manager
// -------------------------------
newComponents = Arrays.asList(this.retrieveComponentInfo("*"));
newContainers = Arrays.asList(this.retrieveContainerInfo("*"));
newClientApps = Arrays.asList(this.retrieveClientInfo("*"));
/* If the retrieval bails out it is (as far as i've seen)
* always because the manager is not reachable at all.
* thus, there's no need to try and retrieve e.g. the
* clients if the components have already failed. thus,
* one exception handler for all retrievals is enough */
} catch (NotConnectedToManagerException exc) {
log.fine(read + "problem: " + exc);
mcehandler.handleExceptionTalkingToManager(exc);
throw exc;
} catch (NoPermissionEx exc) {
log.fine(read + "problem: " + exc);
mcehandler.handleExceptionTalkingToManager(exc);
throw exc;
} catch (org.omg.CORBA.TRANSIENT exc) {
log.fine(read + "problem: " + exc);
mcehandler.handleExceptionTalkingToManager(exc);
throw new CorbaTransientException(exc);
} catch (org.omg.CORBA.OBJECT_NOT_EXIST exc) {
log.fine(read + "problem: " + exc);
mcehandler.handleExceptionTalkingToManager(exc);
throw new CorbaNotExistException(exc);
} catch (RuntimeException exc) {
log.fine(read + "problem: " + exc);
mcehandler.handleExceptionTalkingToManager(exc);
throw new UnknownErrorException(exc);
}
// 2013-05 Marcus OSF Mission -----------------------------------------
if (log.isLoggable(Level.FINER)) {
StringBuilder sb = new StringBuilder();
sb.append("\nretrieved containers (").append(newContainers.size()).append(") = | ");
for (ContainerInfo ci : newContainers) sb.append("n=").append(ci.name).append(",h=").append(ci.h).append(" | ");
sb.append("\nknown containers (").append(maciInfo.containers.size()).append(") = | ");
for (ContainerInfo ci : maciInfo.containers) sb.append("n=").append(ci.name).append(",h=").append(ci.h).append(" | ");
log.finer(read + "diffing container info" + sb);
}
// ------------------------------------------------------------------
diffComponents.diff(maciInfo.components, newComponents);
diffContainers.diff(maciInfo.containers, newContainers);
diffClientApps.diff(maciInfo.clientApps, newClientApps);
// 2013-05 Marcus OSF Mission -----------------------------------------
if (log.isLoggable(Level.FINER))
log.finer(write + "diff results: containers=" + !diffContainers.areEqual() + ", components=" + !diffComponents.areEqual() + ", clients=" + !diffClientApps.areEqual());
if (diffComponents.areEqual() && diffContainers.areEqual() && diffClientApps.areEqual()) {
log.finer(write + "no change found");
nothingChanged = true;
} else {
// we provide some additional info over what is available in the manager's
// info structs. we must compute it upfront since you need an ORB to do it.
newAuxiliary = new HashMap<Object, String>();
for (ContainerInfo info : newContainers) {
int infokey = System.identityHashCode(info);
newAuxiliary.put(infokey + ".location", extractLocation(info.reference));
}
for (ClientInfo info : newClientApps) {
int infokey = System.identityHashCode(info);
newAuxiliary.put(infokey + ".location", extractLocation(info.reference));
}
}
} finally {
if (nothingChanged == false) {
log.fine(write + "writing changes to maci-info structure");
maciInfo.setContents(newComponents, newContainers, newClientApps, newAuxiliary);
}
}
}
use of alma.maciErrType.NoPermissionEx in project ACS by ACS-Community.
the class BACIRemoteAccess method explodeRootNodeByType.
/**
* Explodes the root node and groups the devices by their types.
* Creation date: (1.11.2000 17:00:46)
* @return si.ijs.acs.objectexplorer.engine.OETreeDataNode[]
*/
private synchronized OETreeNode[] explodeRootNodeByType() {
if (manager == null)
resolveManager();
notifier.reportDebug("BACIRemoteAccess::explodeRootNodeByType", "Querying manager for all instances of all types...");
long time1 = System.currentTimeMillis();
int[] handles = new int[0];
try {
infos = manager.get_component_info(handle, handles, "*", "*", false);
} catch (NoPermissionEx npe) {
notifier.reportError("Nopermission to get component info", npe);
}
long time2 = System.currentTimeMillis();
notifier.reportDebug("BACIRemoteAccess::explodeRootNodeByType", "Query OK. Completed in " + (time2 - time1) + " ms.");
TreeMap tempTypes = new TreeMap();
TreeMap tempDomains = new TreeMap();
devices.clear();
/*
* Loop trough all the received devices and add any new devices that
* are not yet stored in Hashtable.
*/
for (int i = 0; i < infos.length; i++) {
String curl = infos[i].name;
//check if RemoteNodeCouple already exists for this device
RemoteNodeCouple rnc = (RemoteNodeCouple) devices.get(curl);
//skip the device if it does (that should not ever happen actually...)
if (rnc != null)
continue;
String cob = BACICURLResolver.resolveName(curl);
//System.out.println("DEBUG DEVICE: CURL: "+curl);
BACIRemoteNode device = new BACIRemoteNode(DEVICE, //cob2,
cob, curl, parent.getTree(), this);
device.childrenHolder = new ArrayList();
//if not, create a new one and add it to Hashtable devices
rnc = new RemoteNodeCouple(device, null);
String[] cobs = cob.split("/");
String cob2 = cobs[cobs.length - 1];
rnc.deviceByName = new DelegateRemoteNode(cob2, parent, device);
devices.put(curl, rnc);
}
/*
* now loop trough all the devices again and add them to the tree
* TODO refacture to have only one "for loop" - add to hashtable and tree at the same time
*/
for (int i = 0; i < infos.length; i++) {
String domain = BACICURLResolver.resolveDomain(infos[i].name);
if (domain.equals(BACICURLResolver.ROOT_DOMAIN)) {
BACITreeDataNode node = (BACITreeDataNode) tempTypes.get(infos[i].type);
if (node != null) {
// node.childrenHolder.add(infos[i].cob_curl);
node.childrenHolder.add(infos[i].name);
} else {
try {
node = new BACITreeDataNode(TYPE, BACIIntrospector.fullTypeToType(infos[i].type), BACIIntrospector.fullTypeToType(infos[i].type), parent.getTree(), getIcon(TYPE));
} catch (IntrospectionInconsistentException iie) {
notifier.reportError("Invalid IDL type '" + infos[i].type + "'.", iie);
continue;
}
node.childrenHolder = new ArrayList();
// node.childrenHolder.add(infos[i].cob_curl);
node.childrenHolder.add(infos[i].name);
tempTypes.put(infos[i].type, node);
}
} else {
if (domain.startsWith("/"))
domain = domain.substring(1);
int index = domain.indexOf('/');
String dpart = null;
if (index != -1)
dpart = domain.substring(0, domain.indexOf('/'));
else
dpart = domain;
BACITreeDataNode node = (BACITreeDataNode) tempDomains.get(dpart);
if (node != null) {
node.childrenHolder.add(infos[i]);
} else {
node = new BACITreeDataNode(DOMAIN, dpart, infos[i], parent.getTree(), getIcon(DOMAIN));
node.childrenHolder = new ArrayList();
node.childrenHolder.add(infos[i]);
if (index != -1)
node.domainRemainder = dpart + "/";
else
node.domainRemainder = dpart;
tempDomains.put(dpart, node);
}
}
}
BACITreeDataNode[] arrayTypes = new BACITreeDataNode[tempTypes.size()];
tempTypes.values().toArray(arrayTypes);
BACITreeDataNode[] arrayDomains = new BACITreeDataNode[tempDomains.size()];
tempDomains.values().toArray(arrayDomains);
BACITreeDataNode[] retVal = new BACITreeDataNode[arrayTypes.length + arrayDomains.length];
System.arraycopy(arrayDomains, 0, retVal, 0, arrayDomains.length);
System.arraycopy(arrayTypes, 0, retVal, arrayDomains.length, arrayTypes.length);
java.util.Arrays.sort(retVal, new java.util.Comparator() {
public int compare(Object obj1, Object obj2) {
return obj1.toString().compareTo(obj2.toString());
}
});
notifier.reportDebug("BACIRemoteAccess::explodeRootNodeByType", "Root nodes processing complete.");
return retVal;
}
use of alma.maciErrType.NoPermissionEx in project ACS by ACS-Community.
the class ManagerProxy method getComponent.
/**
* @see com.cosylab.acs.maci.Manager#getComponent(int, java.net.URI, boolean, com.cosylab.acs.maci.StatusHolder)
*/
public Component getComponent(int id, URI curl, boolean activate, StatusHolder status) throws AcsJNoPermissionEx {
try {
Component retVal = null;
org.omg.CORBA.Object object = manager.get_component(id, curl.toString(), activate);
if (object != null) {
retVal = new ComponentProxy(curl.toString(), object);
}
return retVal;
} catch (NoPermissionEx npex) {
AcsJNoPermissionEx npe = new AcsJNoPermissionEx();
npe.setReason("Remote manager has thrown no permission exception.");
npe.setID(HandleHelper.toString(id));
npe.setProtectedResource(curl.toString());
throw npe;
} catch (Exception ex) {
//throw re;
return null;
}
}
use of alma.maciErrType.NoPermissionEx in project ACS by ACS-Community.
the class ManagerProxy method getComponentInfo.
/**
* @see com.cosylab.acs.maci.Manager#getComponentInfo(int, int[], java.lang.String, java.lang.String, boolean)
*/
public ComponentInfo[] getComponentInfo(int id, int[] handles, String name_wc, String type_wc, boolean activeOnly) throws AcsJNoPermissionEx {
try {
// returned value
ComponentInfo[] retVal = null;
// transform to CORBA specific
si.ijs.maci.ComponentInfo[] infos = manager.get_component_info(id, handles, name_wc, type_wc, activeOnly);
if (infos != null) {
retVal = new ComponentInfo[infos.length];
for (int i = 0; i < infos.length; i++) {
ComponentInfo componentInfo = new ComponentInfo(infos[i].h, infos[i].name, infos[i].type, infos[i].code, new ComponentProxy(infos[i].name, infos[i].reference));
componentInfo.setContainer(infos[i].container);
componentInfo.setContainerName(infos[i].container_name);
componentInfo.setAccessRights(ContainerProxy.inverseMapAccessRights(infos[i].access));
componentInfo.setClients(new IntArray(infos[i].clients));
componentInfo.setInterfaces(infos[i].interfaces);
retVal[i] = componentInfo;
}
}
return retVal;
} catch (NoPermissionEx npex) {
AcsJNoPermissionEx npe = new AcsJNoPermissionEx();
npe.setReason("Remote manager has thrown no permission exception.");
npe.setID(HandleHelper.toString(id));
throw npe;
} catch (Exception ex) {
//throw re;
return null;
}
}
Aggregations