RelationPreferenceConfiguration conf, String configurationName,
ACrisObject cris, boolean isItemID, String o, String action,
int priority)
{
String uuid = cris.getUuid();
RelationPreference relPref = null;
if (isItemID)
{
relPref = applicationService.getRelationPreferenceForUUIDItemID(
uuid, Integer.parseInt(o), configurationName);
}
else
{
relPref = applicationService.getRelationPreferenceForUUIDs(uuid, o,
configurationName);
}
String previousState = null;
int previousPriority = 0;
DSpaceObject dso = null;
if (isItemID)
{
try
{
dso = Item.find(context, Integer.parseInt(o));
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage(), e);
}
}
else
{
dso = applicationService.getEntityByUUID(o);
}
if (relPref == null)
{
relPref = new RelationPreference();
relPref.setRelationType(configurationName);
relPref.setSourceUUID(uuid);
relPref.setStatus(action);
relPref.setPriority(priority);
if (isItemID)
{
relPref.setItemID(Integer.parseInt(o));
}
else
{
relPref.setTargetUUID(o);
}
}
else
{
previousState = relPref.getStatus();
previousPriority = relPref.getPriority();
relPref.setStatus(action);
relPref.setPriority(priority);
}
if (action != null)
{
applicationService.saveOrUpdate(RelationPreference.class, relPref);
}
else
{
applicationService
.delete(RelationPreference.class, relPref.getId());
}
if (!conf.executeExtraAction(context, cris, dso.getID(), previousState,
previousPriority, action, priority))
{
try