mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-2526 Fix NPE found by integration tests.
This commit is contained in:
@@ -70,7 +70,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
{
|
{
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(DispositionServiceImpl.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(DispositionServiceImpl.class);
|
||||||
|
|
||||||
/** Transaction mode for setting next action */
|
/** Transaction mode for setting next action */
|
||||||
public enum WriteMode {READ_ONLY, DATE_ONLY, DATE_AND_NAME};
|
public enum WriteMode {READ_ONLY, DATE_ONLY, DATE_AND_NAME};
|
||||||
|
|
||||||
@@ -265,28 +265,28 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
if (isRecord(nodeRef))
|
if (isRecord(nodeRef))
|
||||||
{
|
{
|
||||||
final NextActionFromDisposition dsNextAction = getDispositionActionByNameForRecord(nodeRef);
|
final NextActionFromDisposition dsNextAction = getDispositionActionByNameForRecord(nodeRef);
|
||||||
|
|
||||||
if (dsNextAction != null && !dsNextAction.getWriteMode().equals(WriteMode.READ_ONLY))
|
if (dsNextAction != null && !dsNextAction.getWriteMode().equals(WriteMode.READ_ONLY))
|
||||||
{
|
{
|
||||||
final NodeRef action = dsNextAction.getNextActionNodeRef();
|
final NodeRef action = dsNextAction.getNextActionNodeRef();
|
||||||
final String dispositionActionName = dsNextAction.getNextActionName();
|
final String dispositionActionName = dsNextAction.getNextActionName();
|
||||||
final Date dispositionActionDate = dsNextAction.getNextActionDateAsOf();
|
final Date dispositionActionDate = dsNextAction.getNextActionDateAsOf();
|
||||||
|
|
||||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Void doWork()
|
||||||
{
|
{
|
||||||
@Override
|
nodeService.setProperty(action, PROP_DISPOSITION_AS_OF, dispositionActionDate);
|
||||||
public Void doWork()
|
if (dsNextAction.getWriteMode().equals(WriteMode.DATE_AND_NAME))
|
||||||
{
|
{
|
||||||
nodeService.setProperty(action, PROP_DISPOSITION_AS_OF, dispositionActionDate);
|
nodeService.setProperty(action, PROP_DISPOSITION_ACTION_NAME, dispositionActionName);
|
||||||
if (dsNextAction.getWriteMode().equals(WriteMode.DATE_AND_NAME))
|
|
||||||
{
|
|
||||||
nodeService.setProperty(action, PROP_DISPOSITION_ACTION_NAME, dispositionActionName);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dsNodeRef = dsNextAction.getDispositionNodeRef();
|
||||||
}
|
}
|
||||||
dsNodeRef = dsNextAction.getDispositionNodeRef();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -298,12 +298,12 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
{
|
{
|
||||||
ds = new DispositionScheduleImpl(serviceRegistry, nodeService, dsNodeRef);
|
ds = new DispositionScheduleImpl(serviceRegistry, nodeService, dsNodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ds;
|
return ds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns a NodeRef
|
* This method returns a NodeRef
|
||||||
@@ -909,7 +909,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
// Get the current action
|
// Get the current action
|
||||||
String currentADId = (String) nodeService.getProperty(currentDispositionAction, PROP_DISPOSITION_ACTION_ID);
|
String currentADId = (String) nodeService.getProperty(currentDispositionAction, PROP_DISPOSITION_ACTION_ID);
|
||||||
currentDispositionActionDefinition = di.getDispositionActionDefinition(currentADId);
|
currentDispositionActionDefinition = di.getDispositionActionDefinition(currentADId);
|
||||||
|
|
||||||
// When the record has multiple disposition schedules the current disposition action may not be found by id
|
// When the record has multiple disposition schedules the current disposition action may not be found by id
|
||||||
// In this case it will be searched by name
|
// In this case it will be searched by name
|
||||||
if(currentDispositionActionDefinition == null)
|
if(currentDispositionActionDefinition == null)
|
||||||
@@ -1076,21 +1076,21 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate next disposition action for a record
|
* Calculate next disposition action for a record
|
||||||
*
|
*
|
||||||
* @param record
|
* @param record
|
||||||
* @return next disposition action (name, date) and the disposition associated
|
* @return next disposition action (name, date) and the disposition associated
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected NextActionFromDisposition getDispositionActionByNameForRecord(NodeRef record)
|
protected NextActionFromDisposition getDispositionActionByNameForRecord(NodeRef record)
|
||||||
{
|
{
|
||||||
List<NodeRef> recordFolders = recordFolderService.getRecordFolders(record);
|
List<NodeRef> recordFolders = recordFolderService.getRecordFolders(record);
|
||||||
DispositionAction nextDispositionAction = getNextDispositionAction(record);
|
DispositionAction nextDispositionAction = getNextDispositionAction(record);
|
||||||
|
|
||||||
if (nextDispositionAction == null)
|
if (nextDispositionAction == null)
|
||||||
{
|
{
|
||||||
return getFirstDispositionAction(recordFolders);
|
return getFirstDispositionAction(recordFolders);
|
||||||
@@ -1113,7 +1113,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
Date recordNextDispositionActionDate = nextDispositionAction.getAsOfDate();
|
Date recordNextDispositionActionDate = nextDispositionAction.getAsOfDate();
|
||||||
Date nextDispositionActionDate = null;
|
Date nextDispositionActionDate = null;
|
||||||
NodeRef dispositionNodeRef = null;
|
NodeRef dispositionNodeRef = null;
|
||||||
|
|
||||||
for (NodeRef folder : recordFolders)
|
for (NodeRef folder : recordFolders)
|
||||||
{
|
{
|
||||||
NodeRef dsNodeRef = getDispositionScheduleImpl(folder);
|
NodeRef dsNodeRef = getDispositionScheduleImpl(folder);
|
||||||
@@ -1132,7 +1132,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
WriteMode mode = null;
|
WriteMode mode = null;
|
||||||
if (!nextDispositionActionDate.equals(recordNextDispositionActionDate)
|
if (!nextDispositionActionDate.equals(recordNextDispositionActionDate)
|
||||||
&& recordNextDispositionActionDate.before(nextDispositionActionDate))
|
&& recordNextDispositionActionDate.before(nextDispositionActionDate))
|
||||||
{
|
{
|
||||||
mode = WriteMode.DATE_ONLY;
|
mode = WriteMode.DATE_ONLY;
|
||||||
@@ -1141,7 +1141,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
{
|
{
|
||||||
mode = WriteMode.READ_ONLY;
|
mode = WriteMode.READ_ONLY;
|
||||||
}
|
}
|
||||||
return new NextActionFromDisposition(dispositionNodeRef, nextDispositionAction.getNodeRef(),
|
return new NextActionFromDisposition(dispositionNodeRef, nextDispositionAction.getNodeRef(),
|
||||||
recordNextDispositionActionName, nextDispositionActionDate, mode);
|
recordNextDispositionActionName, nextDispositionActionDate, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1156,7 +1156,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
String newDispositionActionName = null;
|
String newDispositionActionName = null;
|
||||||
Date newDispositionActionDateAsOf = null;
|
Date newDispositionActionDateAsOf = null;
|
||||||
NodeRef dispositionNodeRef = null;
|
NodeRef dispositionNodeRef = null;
|
||||||
for (NodeRef folder : recordFolders)
|
for (NodeRef folder : recordFolders)
|
||||||
{
|
{
|
||||||
NodeRef folderDS = getDispositionScheduleImpl(folder);
|
NodeRef folderDS = getDispositionScheduleImpl(folder);
|
||||||
if (folderDS != null)
|
if (folderDS != null)
|
||||||
@@ -1166,13 +1166,13 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
{
|
{
|
||||||
NodeRef firstAction = assocs.get(0).getChildRef();
|
NodeRef firstAction = assocs.get(0).getChildRef();
|
||||||
DispositionAction firstDispositionAction = new DispositionActionImpl(serviceRegistry, firstAction);
|
DispositionAction firstDispositionAction = new DispositionActionImpl(serviceRegistry, firstAction);
|
||||||
|
|
||||||
if (newAction == null)
|
if (newAction == null)
|
||||||
{
|
{
|
||||||
newAction = firstAction;
|
newAction = firstAction;
|
||||||
newDispositionActionName = (String)nodeService.getProperty(newAction, PROP_DISPOSITION_ACTION_NAME);
|
newDispositionActionName = (String)nodeService.getProperty(newAction, PROP_DISPOSITION_ACTION_NAME);
|
||||||
newDispositionActionDateAsOf = getDispositionActionDate(folderDS, newDispositionActionName);
|
newDispositionActionDateAsOf = getDispositionActionDate(folderDS, newDispositionActionName);
|
||||||
}
|
}
|
||||||
else if (firstDispositionAction.getAsOfDate() != null && newDispositionActionDateAsOf.before(firstDispositionAction.getAsOfDate()))
|
else if (firstDispositionAction.getAsOfDate() != null && newDispositionActionDateAsOf.before(firstDispositionAction.getAsOfDate()))
|
||||||
{
|
{
|
||||||
newDispositionActionName = (String)nodeService.getProperty(firstAction, PROP_DISPOSITION_ACTION_NAME);
|
newDispositionActionName = (String)nodeService.getProperty(firstAction, PROP_DISPOSITION_ACTION_NAME);
|
||||||
@@ -1182,12 +1182,12 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newDispositionActionName == null || newDispositionActionDateAsOf == null
|
if (newDispositionActionName == null || newDispositionActionDateAsOf == null
|
||||||
|| dispositionNodeRef == null || newAction == null)
|
|| dispositionNodeRef == null || newAction == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new NextActionFromDisposition(dispositionNodeRef, newAction,
|
return new NextActionFromDisposition(dispositionNodeRef, newAction,
|
||||||
newDispositionActionName, newDispositionActionDateAsOf, WriteMode.DATE_AND_NAME);
|
newDispositionActionName, newDispositionActionDateAsOf, WriteMode.DATE_AND_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user