InvalidRelationIdException, RelationTypeNotFoundException, InvalidRoleValueException
{
isActive();
if (relationId == null) throw new IllegalArgumentException("Null Relation Id");
if (relationTypeName == null) throw new IllegalArgumentException("Null Relation Type Name");
Logger logger = getLogger();
if (logger.isEnabledFor(Logger.DEBUG))
{
logger.debug("Creating an InternalRelation with ID: " + relationId + " and relationType name: " + relationTypeName);
}
// creating InternalRelation to represent the internal relations
InternalRelation internalRelation = new InternalRelation(relationId, m_relationServiceObjectName,
relationTypeName, roleList);
try
{
if (getRelationObject(relationId) != null)
{
logger.warn("There is a Relation already registered in the RelationServcie with ID: " + relationId);
throw new InvalidRelationIdException("There is already a relation with id: " + relationId);
}
}
catch (RelationNotFoundException ex)
{/*Do nothing as should not be found*/
}
RelationType relationType = getRelationType(relationTypeName);
ArrayList roleInfoList = (ArrayList)(buildRoleInfoList(relationType, roleList));
if (!(roleInfoList.isEmpty()))
{
initializeMissingCreateRoles(roleInfoList, internalRelation, relationId, relationTypeName);
}
synchronized (m_relationIdToRelationObject)
{
m_relationIdToRelationObject.put(relationId, internalRelation);
}
addRelationId(relationId, relationTypeName);
addRelationTypeName(relationId, relationTypeName);
updateRoles(roleList, relationId);
try
{
if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("sending RelationCreation notification to all listeners");
sendRelationCreationNotification(relationId);
}
catch (RelationNotFoundException ex)
{
throw new RuntimeOperationsException(null, "Unable to send notification as Relation not found");