Search in sources :

Example 1 with IntrospectionInconsistentException

use of si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException 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;
}
Also used : ArrayList(java.util.ArrayList) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException) TreeMap(java.util.TreeMap) NoPermissionEx(alma.maciErrType.NoPermissionEx) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) Comparator(java.util.Comparator)

Example 2 with IntrospectionInconsistentException

use of si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException in project ACS by ACS-Community.

the class BACIRemoteAccess method internalParentConnect.

/**
	 * Insert the method's description here.
	 * Creation date: (2.11.2000 0:35:23)
	 * @param baciNode si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode
	 */
private void internalParentConnect(BACIRemoteNode baciNode, boolean doSync) {
    /* we are using the parent to query the object as either an IDL attribute or
			   Java property accessor design pattern (returns Object type, takes no parameters)
		*/
    //	System.out.println("IPC");
    String targetName = null;
    TypeCode retType = null;
    String id = null;
    if (baciNode.getNodeType() == ATTRIBUTE) {
        AttributeDescription ad = (AttributeDescription) baciNode.getUserObject();
        try {
            id = ad.type.id();
        } catch (org.omg.CORBA.TypeCodePackage.BadKind bk) {
            throw new RemoteException("IDL: BadKind thrown on type id lookup for PROPERTY child of the remote node: " + bk);
        }
        targetName = BACIIntrospector.attributeNameToMethodName(ad.name);
        retType = ad.type;
        notifier.reportDebug("BACIRemoteAccess::internalParentConnect", "Obtaining IDL attribute reference for '" + ad.name + "'.");
    } else if (baciNode.getNodeType() == PROPERTY) {
        OperationDescription od = (OperationDescription) baciNode.getUserObject();
        try {
            id = od.result.id();
        } catch (org.omg.CORBA.TypeCodePackage.BadKind bk) {
            throw new RemoteException("IDL: BadKind thrown on type id lookup for PROPERTY child of the remote node: " + bk);
        }
        targetName = od.name;
        retType = od.result;
        notifier.reportDebug("BACIRemoteAccess::internalParentConnect", "Obtaining reference to contained object through property accessor design pattern for '" + od.name + ".");
    } else
        throw new IntrospectionInconsistentException("Devices can contain objects only as IDL attributes or property accessor design patterns. Failed on '" + baciNode + "'.");
    BACIRemoteNode parentNode = (BACIRemoteNode) baciNode.getParent();
    if (parentNode.getCORBARef() == null) {
        parentNode.connect();
        if (parentNode.getCORBARef() == null)
            throw new RemoteException("Child node is accessible although the parent node CORBA reference is null. Failed on '" + baciNode + ".");
    }
    /* begin DII stanza */
    Request req = parentNode.getCORBARef()._request(targetName);
    req.set_return_type(retType);
    notifier.reportDebug("BACIRemoteAccess::internalParentConnect", "Invoking remote call...");
    req.invoke();
    Any returnValue = req.return_value();
    if (returnValue.type().kind() != TCKind.tk_objref)
        throw new IntrospectionInconsistentException("Return type of '" + targetName + "' is not of type object reference, expected object reference because of BACI containment specifications.");
    baciNode.setCORBARef(returnValue.extract_Object());
    //
    baciNode.setIFDesc(getIFDesc(id));
    //
    if (baciNode.getCORBARef() != null)
        notifier.reportDebug("BACIRemoteAccess::internalParentConnect", "Connection to contained object OK.");
    else
        notifier.reportError("Reference returned when resolving contained object '" + targetName + "' is null.");
/* end DII stanza */
}
Also used : TypeCode(org.omg.CORBA.TypeCode) Request(org.omg.CORBA.Request) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException) Any(org.omg.CORBA.Any) OperationDescription(org.omg.CORBA.OperationDescription) AttributeDescription(org.omg.CORBA.AttributeDescription) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException)

Example 3 with IntrospectionInconsistentException

use of si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException in project ACS by ACS-Community.

the class BACIIntrospector method IDtoClassName.

/**
 * Insert the method's description here.
 * Creation date: (13.11.2000 0:59:30)
 * @return java.lang.String
 * @param ID java.lang.String
 */
public String IDtoClassName(String ID) {
    if (ID == null)
        throw new NullPointerException("ID");
    String retVal = (String) IDLtoJavaMapping.get(ID);
    if (retVal != null)
        return retVal;
    else {
        int index1 = 0;
        int index2 = 0;
        index1 = ID.indexOf(':');
        index2 = ID.lastIndexOf(':');
        if (index1 == index2)
            throw new IntrospectionInconsistentException("IDL ID '" + ID + "' is not well-formed because it contains only one ':' character");
        String partial = ID.substring(index1 + 1, index2);
        index1 = partial.lastIndexOf('/');
        index2 = partial.indexOf('/');
        if (index1 == -1 || index2 == -1)
            throw new IntrospectionInconsistentException("IDL ID '" + ID + "' is not well-formed because it does not contain module separators '/'.");
        if (index1 == index2)
            return addIDLPackagePrefix(partial.replace('/', '.'));
        String lookup = "IDL:" + partial.substring(0, index1) + ":1.0";
        if (index1 != index2) {
            // reverse order of pragma prefix
            final String delimiter = ".";
            StringTokenizer stringTokenizer = new StringTokenizer(partial.substring(0, index2), delimiter);
            String reversedPragma = stringTokenizer.nextToken();
            while (stringTokenizer.hasMoreTokens()) reversedPragma = stringTokenizer.nextToken() + delimiter + reversedPragma;
            partial = reversedPragma + partial.substring(index2);
        }
        ra.getNotifier().reportDebug("BACIIntrospector::IDtoClassName", "Analysing IDL to Java mapping of type '" + ID + "'. Querying IR for parent container '" + lookup + "'.");
        IRObject ctd = ra.lookupId(lookup);
        if (ctd == null)
            throw new IntrospectionInconsistentException("Repository does not contain container '" + lookup + "' of child '" + ID + "'.");
        if (ctd.def_kind() == DefinitionKind.dk_Module)
            retVal = addIDLPackagePrefix(partial.replace('/', '.'));
        else
            retVal = addIDLPackagePrefix(partial.substring(0, index1).replace('/', '.') + "Package." + partial.substring(index1 + 1));
        IDLtoJavaMapping.put(ID, retVal);
        return retVal;
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) IRObject(org.omg.CORBA.IRObject) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException)

Example 4 with IntrospectionInconsistentException

use of si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException in project ACS by ACS-Community.

the class BACIIntrospector method destroyInvocation.

/**
 * Insert the method's description here.
 * Creation date: (7.11.2000 21:47:04)
 * @param invoc si.ijs.acs.objectexplorer.engine.Invocation[]
 */
public static void destroyInvocation(BACIInvocation invoc) {
    if (invoc == null)
        throw new NullPointerException("invoc");
    if (invoc.isDestroyed())
        return;
    Operation[] ops = invoc.getOperations();
    Operation dest = null;
    for (int i = 0; i < ops.length; i++) {
        if (METHOD_DESTROY.equals(ops[i].getName())) {
            dest = ops[i];
            if (dest.getParameterTypes().length != 0)
                throw new IntrospectionInconsistentException("Operation " + METHOD_DESTROY + "' on a 'Subscription' instance '" + invoc + "' must take exactly 0 parameters.");
            break;
        }
    }
    if (dest == null)
        throw new IntrospectionInconsistentException("'Subscription' instance for invocation '" + invoc + "' does not declare a 'destroy()' method.");
    invoc.ra.invoke(invoc, (BACIOperation) dest, new java.lang.Object[0], null);
}
Also used : Operation(si.ijs.acs.objectexplorer.engine.Operation) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException)

Example 5 with IntrospectionInconsistentException

use of si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException in project ACS by ACS-Community.

the class BACIIntrospector method fullTypeToType.

/**
 * Insert the method's description here.
 * Creation date: (17.3.2001 19:36:18)
 * @return java.lang.String
 * @param fullType java.lang.String
 */
public static String fullTypeToType(String fullType) {
    if (fullType == null)
        throw new NullPointerException("fullType");
    int index1 = fullType.lastIndexOf('/');
    int index2 = fullType.lastIndexOf(':');
    if (index1 == -1 || index2 == -1 || index1 > index2)
        throw new IntrospectionInconsistentException("Type '" + fullType + "' is not a valid IDL ID, beginning with IDL: and ending with :1.0");
    return fullType.substring(index1 + 1, index2);
}
Also used : IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException)

Aggregations

IntrospectionInconsistentException (si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException)9 ArrayList (java.util.ArrayList)3 RemoteException (si.ijs.acs.objectexplorer.engine.RemoteException)3 TreeMap (java.util.TreeMap)2 OperationDescription (org.omg.CORBA.OperationDescription)2 DataType (si.ijs.acs.objectexplorer.engine.DataType)2 NonStickyConnectFailedRemoteException (si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException)2 NoPermissionEx (alma.maciErrType.NoPermissionEx)1 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)1 Comparator (java.util.Comparator)1 StringTokenizer (java.util.StringTokenizer)1 Any (org.omg.CORBA.Any)1 AttributeDescription (org.omg.CORBA.AttributeDescription)1 IRObject (org.omg.CORBA.IRObject)1 ParameterDescription (org.omg.CORBA.ParameterDescription)1 Request (org.omg.CORBA.Request)1 TypeCode (org.omg.CORBA.TypeCode)1 DataException (si.ijs.acs.objectexplorer.engine.DataException)1 DataStruct (si.ijs.acs.objectexplorer.engine.DataStruct)1 Operation (si.ijs.acs.objectexplorer.engine.Operation)1