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;
}
}
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;
}
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;
}
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;
}
Aggregations