Program: 188421
Project: 188421
Buggy source:
public static IndexedAIP moveAIPInHierarchy(User user,SelectedItems<IndexedAIP> selected,String parentId,String details) throws GenericException, NotFoundException, RequestNotValidException, AuthorizationDeniedException, AlreadyExistsException, ValidationException {
  Locale locale=ServerTools.parseLocale(RodaConstants.DEFAULT_EVENT_LOCALE);
  Messages messages=RodaCoreFactory.getI18NMessages(locale);
  String eventDescription=messages.getTranslation(RodaConstants.EVENT_UPDATE_ON_REPOSITORY);
  Job job=new Job();
  job.setId(UUID.randomUUID().toString());
  job.setName("String_Node_Str");
  job.setSourceObjects(selected);
  job.setPlugin(MovePlugin.class.getCanonicalName());
  job.setPluginType(PluginType.INTERNAL);
  job.setUsername(user.getName());
  Map<String,String> pluginParameters=new HashMap<>();
  pluginParameters.put(RodaConstants.PLUGIN_PARAMS_AIP_ID,parentId);
  pluginParameters.put(RodaConstants.PLUGIN_PARAMS_DETAILS,details);
  pluginParameters.put(RodaConstants.PLUGIN_PARAMS_EVENT_DESCRIPTION,eventDescription);
  job.setPluginParameters(pluginParameters);
  RodaCoreFactory.getModelService().createJob(job);
  try {
    RodaCoreFactory.getPluginOrchestrator().executeJob(job,true);
  }
 catch (  JobAlreadyStartedException e) {
    LOGGER.error("String_Node_Str",e);
  }
  IndexService index=RodaCoreFactory.getIndexService();
  index.commit(IndexedAIP.class);
  index.commit(IndexedRepresentation.class);
  index.commit(IndexedFile.class);
  return (parentId != null) ? index.retrieve(IndexedAIP.class,parentId,Arrays.asList(RodaConstants.INDEX_UUID)) : null;
}

Fixed version (ground truth):
public static IndexedAIP moveAIPInHierarchy(User user,SelectedItems<IndexedAIP> selected,String parentId,String details) throws GenericException, NotFoundException, RequestNotValidException, AuthorizationDeniedException, AlreadyExistsException, ValidationException {
  Locale locale=ServerTools.parseLocale(RodaConstants.DEFAULT_EVENT_LOCALE);
  Messages messages=RodaCoreFactory.getI18NMessages(locale);
  String eventDescription=messages.getTranslation(RodaConstants.EVENT_UPDATE_ON_REPOSITORY);
  Job job=new Job();
  job.setId(UUID.randomUUID().toString());
  job.setName("String_Node_Str");
  job.setSourceObjects(selected);
  job.setPlugin(MovePlugin.class.getCanonicalName());
  job.setPluginType(PluginType.INTERNAL);
  job.setUsername(user.getName());
  Map<String,String> pluginParameters=new HashMap<>();
  pluginParameters.put(RodaConstants.PLUGIN_PARAMS_ID,parentId);
  pluginParameters.put(RodaConstants.PLUGIN_PARAMS_DETAILS,details);
  pluginParameters.put(RodaConstants.PLUGIN_PARAMS_EVENT_DESCRIPTION,eventDescription);
  job.setPluginParameters(pluginParameters);
  RodaCoreFactory.getModelService().createJob(job);
  try {
    RodaCoreFactory.getPluginOrchestrator().executeJob(job,true);
  }
 catch (  JobAlreadyStartedException e) {
    LOGGER.error("String_Node_Str",e);
  }
  IndexService index=RodaCoreFactory.getIndexService();
  index.commit(IndexedAIP.class);
  index.commit(IndexedRepresentation.class);
  index.commit(IndexedFile.class);
  return (parentId != null) ? index.retrieve(IndexedAIP.class,parentId,Arrays.asList(RodaConstants.INDEX_UUID)) : null;
}