Search in sources :

Example 31 with AcsJBadParameterEx

use of alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx in project ACS by ACS-Community.

the class ContainerServicesImpl method assignUniqueEntityId.

/**
	 * @see alma.acs.container.ContainerServices#assignUniqueEntityId(EntityT)
	 */
@Override
public void assignUniqueEntityId(EntityT entity) throws AcsJContainerServicesEx {
    if (entity == null) {
        AcsJBadParameterEx cause = new AcsJBadParameterEx();
        cause.setParameter("entity");
        cause.setParameterValue("null");
        throw new AcsJContainerServicesEx(cause);
    }
    if (fakeUIDsForTesting) {
        long localId = (new Random(System.currentTimeMillis())).nextLong();
        String uid = Range.generateUID("testArchiveId", "testRangeId", localId);
        entity.setEntityId(uid);
        return;
    }
    try {
        if (identifierArchive == null) {
            Identifier identRaw = IdentifierHelper.narrow(getDefaultComponent("IDL:alma/xmlstore/Identifier:1.0"));
            identifierArchive = getTransparentXmlWrapper(IdentifierJ.class, identRaw, IdentifierOperations.class);
        }
        if (uidLibrary == null) {
            uidLibrary = new UIDLibrary(m_logger);
        }
        uidLibrary.assignUniqueEntityId(entity, identifierArchive);
    } catch (Throwable thr) {
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
        String msg = "Failed to assign a UID to entity of type ";
        if (entity.getEntityTypeName() != null) {
            msg += entity.getEntityTypeName();
        } else {
            msg += entity.getClass().getSimpleName();
        }
        ex.setContextInfo(msg);
        throw ex;
    }
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) Identifier(alma.xmlstore.Identifier) Random(java.util.Random) IdentifierJ(alma.xmlstore.IdentifierJ) IdentifierOperations(alma.xmlstore.IdentifierOperations) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) UIDLibrary(alma.acs.container.archive.UIDLibrary) CBlong(alma.ACS.CBlong)

Example 32 with AcsJBadParameterEx

use of alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx in project ACS by ACS-Community.

the class ContainerServicesImpl method getComponent.

/**
	 * @see alma.acs.container.ContainerServices#getComponent(String)
	 */
public org.omg.CORBA.Object getComponent(String curl) throws AcsJContainerServicesEx {
    if (curl == null) {
        AcsJBadParameterEx cause = new AcsJBadParameterEx();
        cause.setParameter("curl");
        cause.setParameterValue("null");
        throw new AcsJContainerServicesEx(cause);
    }
    // check if our component has requested the other component before
    org.omg.CORBA.Object stub = m_usedComponentsMap.get(curl);
    if (stub != null) {
        // reusing seems ok as long as there is one separate 
        // instance of ContainerServicesImpl for each component.
        // This reuse does not cut off the manager from component access,
        // since it only happens at second or further access attempts;
        // the first time, the component reference is obtained through the manager
        // (independently of whether the components are collocated inside the same container),
        // so that the manager is aware of component dependencies.    
        m_logger.info("client '" + m_clientName + "' attempts to retrieve component '" + curl + "' more than once; will return existing reference.");
    } else {
        m_logger.fine("will retrieve remote component '" + curl + "' using ACS Manager#get_component with client handle " + getEffectiveClientHandle());
        try {
            stub = m_acsManagerProxy.get_component(getEffectiveClientHandle(), curl, true);
            m_logger.fine("component " + curl + " retrieved successfully.");
            m_usedComponentsMap.put(curl, stub);
        } catch (AcsJmaciErrTypeEx ex) {
            String msg = "Failed to retrieve component " + curl;
            // only a low-level log because the client component is supposed to log the exception which contains all context data 
            m_logger.log(Level.FINE, msg, ex);
            throw new AcsJContainerServicesEx(ex);
        } catch (Throwable thr) {
            String msg = "Failed to retrieve component " + curl + " for unexpected reasons.";
            m_logger.log(Level.FINE, msg, thr);
            AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
            ex.setContextInfo(msg);
            throw ex;
        }
    }
    return stub;
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) AcsJmaciErrTypeEx(alma.maciErrType.wrappers.AcsJmaciErrTypeEx) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 33 with AcsJBadParameterEx

use of alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx in project ACS by ACS-Community.

the class ContainerServicesImpl method getDefaultComponent.

/**
	 * @see alma.acs.container.ContainerServices#getDefaultComponent(java.lang.String)
	 */
public org.omg.CORBA.Object getDefaultComponent(String componentIDLType) throws AcsJContainerServicesEx {
    if (componentIDLType == null) {
        AcsJBadParameterEx cause = new AcsJBadParameterEx();
        cause.setParameter("componentIDLType");
        cause.setParameterValue("null");
        throw new AcsJContainerServicesEx(cause);
    }
    ComponentInfo cInfo = null;
    try {
        // the call
        cInfo = m_acsManagerProxy.get_default_component(getEffectiveClientHandle(), componentIDLType);
    } catch (AcsJmaciErrTypeEx ex) {
        String msg = "failed to retrieve default component for type " + componentIDLType;
        // higher-level log should be produced by the calling client from the exception later
        m_logger.log(Level.FINE, msg, ex);
        throw new AcsJContainerServicesEx(ex);
    } catch (Throwable thr) {
        String msg = "failed to retrieve default component for type " + componentIDLType + " for unexpected reasons!";
        m_logger.log(Level.FINE, msg, thr);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
        ex.setContextInfo(msg);
        throw ex;
    }
    // @todo check and remove this
    if (cInfo.reference == null) {
        String msg = "Default component for type '" + componentIDLType + "' could not be accessed. ";
        m_logger.info(msg);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx();
        ex.setContextInfo(msg);
        throw ex;
    }
    m_usedComponentsMap.put(cInfo.name, cInfo.reference);
    m_componentDescriptorMap.put(cInfo.name, new ComponentDescriptor(cInfo));
    return cInfo.reference;
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) ComponentDescriptor(alma.acs.component.ComponentDescriptor) ComponentInfo(si.ijs.maci.ComponentInfo) AcsJmaciErrTypeEx(alma.maciErrType.wrappers.AcsJmaciErrTypeEx) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 34 with AcsJBadParameterEx

use of alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx in project ACS by ACS-Community.

the class ContainerServicesImpl method getComponentNonSticky.

public org.omg.CORBA.Object getComponentNonSticky(String curl) throws AcsJContainerServicesEx {
    if (curl == null) {
        AcsJBadParameterEx cause = new AcsJBadParameterEx();
        cause.setParameter("curl");
        cause.setParameterValue("null");
        throw new AcsJContainerServicesEx(cause);
    }
    org.omg.CORBA.Object stub = null;
    try {
        stub = m_acsManagerProxy.get_component_non_sticky(getEffectiveClientHandle(), curl);
        m_logger.fine("Non-sticky reference to component '" + curl + "' retrieved successfully.");
        m_usedNonStickyComponentsMap.put(curl, stub);
    } catch (AcsJmaciErrTypeEx ex) {
        String msg = "Failed to retrieve non-sticky reference to component " + curl;
        // only a low-level log because the client component is supposed to log the exception which contains all context data 
        m_logger.log(Level.FINE, msg, ex);
        throw new AcsJContainerServicesEx(ex);
    } catch (Throwable thr) {
        String msg = "Failed to retrieve non-sticky reference to component '" + curl + "' for unexpected reasons.";
        m_logger.log(Level.FINE, msg, thr);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
        ex.setContextInfo(msg);
        throw ex;
    }
    return stub;
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) AcsJmaciErrTypeEx(alma.maciErrType.wrappers.AcsJmaciErrTypeEx) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Aggregations

AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)34 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)10 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)10 Component (com.cosylab.acs.maci.Component)10 ComponentInfo (com.cosylab.acs.maci.ComponentInfo)10 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)10 URI (java.net.URI)9 ClientInfo (com.cosylab.acs.maci.ClientInfo)8 URISyntaxException (java.net.URISyntaxException)8 BadParametersException (com.cosylab.acs.maci.BadParametersException)7 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)6 NoDefaultComponentException (com.cosylab.acs.maci.NoDefaultComponentException)6 RemoteException (com.cosylab.acs.maci.RemoteException)6 StatusHolder (com.cosylab.acs.maci.StatusHolder)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 AcsJmaciErrTypeEx (alma.maciErrType.wrappers.AcsJmaciErrTypeEx)4 OffShootOperations (alma.ACS.OffShootOperations)3 AcsJNullPointerEx (alma.ACSErrTypeCommon.wrappers.AcsJNullPointerEx)3 ComponentDescriptor (alma.acs.component.ComponentDescriptor)3