Program: 146175
Project: 146175
Buggy source:
/** 
 * @param itemPOJOPK
 * @param partPath
 * @return DroppedItemPOJOPK
 * @throws XtentisException drop an item to items-trash
 */
public static DroppedItemPOJOPK drop(ItemPOJOPK itemPOJOPK,String partPath) throws XtentisException {
  if (itemPOJOPK == null)   return null;
  if (partPath == null || partPath.equals("String_Node_Str"))   partPath="String_Node_Str";
  boolean authorized=false;
  LocalUser user=LocalUser.getLocalUser();
  if ("String_Node_Str".equals(user.getUsername()) || LocalUser.UNAUTHENTICATED_USER.equals(user.getUsername())) {
    authorized=true;
  }
 else   if (user.userCanWrite(ItemPOJO.class,itemPOJOPK.getUniqueID())) {
    authorized=true;
  }
  if (!authorized) {
    String err="String_Node_Str" + "String_Node_Str" + user.getUsername() + "String_Node_Str"+ itemPOJOPK.getUniqueID()+ "String_Node_Str";
    org.apache.log4j.Logger.getLogger(ObjectPOJO.class).error(err);
    throw new XtentisException(err);
  }
  String userName=user.getUsername();
  UniversePOJO universe=LocalUser.getLocalUser().getUniverse();
  if (universe == null) {
    String err="String_Node_Str" + LocalUser.getLocalUser().getUsername() + "String_Node_Str";
    org.apache.log4j.Logger.getLogger(ItemPOJO.class).error(err);
    throw new XtentisException(err);
  }
  String revisionID=universe.getConceptRevisionID(itemPOJOPK.getConceptName());
  XmlServerSLWrapperLocal server;
  try {
    server=((XmlServerSLWrapperLocalHome)new InitialContext().lookup(XmlServerSLWrapperLocalHome.JNDI_NAME)).create();
  }
 catch (  Exception e) {
    String err="String_Node_Str";
    org.apache.log4j.Logger.getLogger(ItemPOJO.class).error(err,e);
    throw new XtentisException(err);
  }
  try {
    if (ObjectPOJO.load(null,DataClusterPOJO.class,new DataClusterPOJOPK("String_Node_Str")) == null) {
      DataClusterPOJO dataCluster=new DataClusterPOJO("String_Node_Str","String_Node_Str",null);
      ObjectPOJOPK pk=dataCluster.store(null);
      if (pk == null)       throw new XtentisException("String_Node_Str");
      boolean exist=false;
      String[] clusters=server.getAllClusters(null);
      if (clusters != null) {
        exist=Arrays.asList(clusters).contains(pk.getUniqueId());
      }
      if (!exist)       server.createCluster(null,pk.getUniqueId());
      org.apache.log4j.Logger.getLogger(ItemPOJO.class).info("String_Node_Str");
    }
    String dataClusterName=itemPOJOPK.getDataClusterPOJOPK().getUniqueId();
    String uniqueID=getFilename(itemPOJOPK);
    StringBuffer xmlDocument=new StringBuffer();
    Document sourceDoc=null;
    NodeList toDeleteNodeList=null;
    String xml=server.getDocumentAsString(revisionID,dataClusterName,uniqueID,null);
    if (xml == null)     return null;
    if (partPath.equals("String_Node_Str")) {
      xmlDocument.append(xml);
    }
 else {
      String xPath="String_Node_Str" + partPath;
      sourceDoc=Util.parse(xml);
      toDeleteNodeList=Util.getNodeList(sourceDoc,xPath);
      if (toDeleteNodeList.getLength() == 0)       throw new XtentisException("String_Node_Str");
      for (int i=0; i < toDeleteNodeList.getLength(); i++) {
        Node node=toDeleteNodeList.item(i);
        xmlDocument.append(Util.nodeToString(node));
      }
    }
    if (partPath.equals("String_Node_Str")) {
    }
 else {
      if (toDeleteNodeList != null) {
        Node lastParentNode=null;
        Node formatSiblingNode=null;
        for (int i=0; i < toDeleteNodeList.getLength(); i++) {
          Node node=toDeleteNodeList.item(i);
          lastParentNode=node.getParentNode();
          formatSiblingNode=node.getNextSibling();
          if (lastParentNode != null) {
            lastParentNode.removeChild(node);
          }
          if (formatSiblingNode != null && formatSiblingNode.getNodeValue() != null && formatSiblingNode.getNodeValue().matches("String_Node_Str")) {
            lastParentNode.removeChild(formatSiblingNode);
          }
        }
      }
      String leftSourceDoc=Util.nodeToString(sourceDoc);
      ItemPOJO itemPOJO=parse(leftSourceDoc);
      if (itemPOJO.getDataModelName() != null) {
        DataModelPOJO dataModelPOJO=ObjectPOJO.load(itemPOJO.getDataModelRevision(),DataModelPOJO.class,new DataModelPOJOPK(itemPOJO.getDataModelName()));
        if (dataModelPOJO != null)         Util.validate(sourceDoc.getDocumentElement(),dataModelPOJO.getSchema());
      }
    }
    DroppedItemPOJO droppedItemPOJO=new DroppedItemPOJO(revisionID,itemPOJOPK.getDataClusterPOJOPK(),uniqueID,itemPOJOPK.getConceptName(),itemPOJOPK.getIds(),partPath,xmlDocument.toString(),userName,new Long(System.currentTimeMillis()));
    StringWriter sw=new StringWriter();
    Marshaller.marshal(droppedItemPOJO,sw);
    long res=server.putDocumentFromString(sw.toString(),droppedItemPOJO.obtainDroppedItemPK().getUniquePK(),"String_Node_Str",null);
    if (res == -1)     return null;
    try {
      if (partPath.equals("String_Node_Str")) {
        server.deleteDocument(revisionID,dataClusterName,uniqueID);
      }
 else {
        server.putDocumentFromString(Util.nodeToString(sourceDoc),uniqueID,dataClusterName,revisionID);
      }
    }
 catch (    Exception e) {
      e.printStackTrace();
      server.deleteDocument(null,"String_Node_Str",droppedItemPOJO.obtainDroppedItemPK().getUniquePK());
      return null;
    }
    return droppedItemPOJO.obtainDroppedItemPK();
  }
 catch (  SAXException e) {
    String err="String_Node_Str" + e.getLocalizedMessage();
    throw new XtentisException(err);
  }
catch (  Exception e) {
    String err="String_Node_Str" + itemPOJOPK.getUniqueID() + "String_Node_Str"+ e.getClass().getName()+ "String_Node_Str"+ e.getLocalizedMessage();
    org.apache.log4j.Logger.getLogger(ItemPOJO.class).error(err,e);
    throw new XtentisException(err);
  }
}

Fixed version (ground truth):
/** 
 * @param itemPOJOPK
 * @param partPath
 * @return DroppedItemPOJOPK
 * @throws XtentisException drop an item to items-trash
 */
public static DroppedItemPOJOPK drop(ItemPOJOPK itemPOJOPK,String partPath) throws XtentisException {
  if (itemPOJOPK == null)   return null;
  if (partPath == null || partPath.equals("String_Node_Str"))   partPath="String_Node_Str";
  boolean authorized=false;
  LocalUser user=LocalUser.getLocalUser();
  if ("String_Node_Str".equals(user.getUsername()) || LocalUser.UNAUTHENTICATED_USER.equals(user.getUsername())) {
    authorized=true;
  }
 else   if (user.userCanWrite(ItemPOJO.class,itemPOJOPK.getUniqueID())) {
    authorized=true;
  }
  if (!authorized) {
    String err="String_Node_Str" + "String_Node_Str" + user.getUsername() + "String_Node_Str"+ itemPOJOPK.getUniqueID()+ "String_Node_Str";
    org.apache.log4j.Logger.getLogger(ObjectPOJO.class).error(err);
    throw new XtentisException(err);
  }
  String userName=user.getUsername();
  UniversePOJO universe=LocalUser.getLocalUser().getUniverse();
  if (universe == null) {
    String err="String_Node_Str" + LocalUser.getLocalUser().getUsername() + "String_Node_Str";
    org.apache.log4j.Logger.getLogger(ItemPOJO.class).error(err);
    throw new XtentisException(err);
  }
  String revisionID=universe.getConceptRevisionID(itemPOJOPK.getConceptName());
  XmlServerSLWrapperLocal server;
  try {
    server=((XmlServerSLWrapperLocalHome)new InitialContext().lookup(XmlServerSLWrapperLocalHome.JNDI_NAME)).create();
  }
 catch (  Exception e) {
    String err="String_Node_Str";
    org.apache.log4j.Logger.getLogger(ItemPOJO.class).error(err,e);
    throw new XtentisException(err);
  }
  try {
    if (ObjectPOJO.load(null,DataClusterPOJO.class,new DataClusterPOJOPK("String_Node_Str")) == null) {
      DataClusterPOJO dataCluster=new DataClusterPOJO("String_Node_Str","String_Node_Str",null);
      ObjectPOJOPK pk=dataCluster.store(null);
      if (pk == null)       throw new XtentisException("String_Node_Str");
      boolean exist=false;
      String[] clusters=server.getAllClusters(null);
      if (clusters != null) {
        exist=Arrays.asList(clusters).contains(pk.getUniqueId());
      }
      if (!exist)       server.createCluster(null,pk.getUniqueId());
      org.apache.log4j.Logger.getLogger(ItemPOJO.class).info("String_Node_Str");
    }
    String dataClusterName=itemPOJOPK.getDataClusterPOJOPK().getUniqueId();
    String uniqueID=getFilename(itemPOJOPK);
    StringBuffer xmlDocument=new StringBuffer();
    Document sourceDoc=null;
    NodeList toDeleteNodeList=null;
    String xml=server.getDocumentAsString(revisionID,dataClusterName,uniqueID,null);
    if (xml == null)     return null;
    if (partPath.equals("String_Node_Str")) {
      xmlDocument.append(xml);
    }
 else {
      String xPath="String_Node_Str" + partPath;
      sourceDoc=Util.parse(xml);
      toDeleteNodeList=Util.getNodeList(sourceDoc,xPath);
      if (toDeleteNodeList.getLength() == 0)       throw new XtentisException("String_Node_Str");
      for (int i=0; i < toDeleteNodeList.getLength(); i++) {
        Node node=toDeleteNodeList.item(i);
        xmlDocument.append(Util.nodeToString(node));
      }
    }
    if (partPath.equals("String_Node_Str")) {
    }
 else {
      if (toDeleteNodeList != null) {
        Node lastParentNode=null;
        Node formatSiblingNode=null;
        for (int i=0; i < toDeleteNodeList.getLength(); i++) {
          Node node=toDeleteNodeList.item(i);
          lastParentNode=node.getParentNode();
          formatSiblingNode=node.getNextSibling();
          if (lastParentNode != null) {
            lastParentNode.removeChild(node);
          }
          if (formatSiblingNode != null && formatSiblingNode.getNodeValue() != null && formatSiblingNode.getNodeValue().matches("String_Node_Str")) {
            lastParentNode.removeChild(formatSiblingNode);
          }
        }
      }
      String leftSourceDoc=Util.nodeToString(sourceDoc);
      ItemPOJO itemPOJO=parse(leftSourceDoc);
      if (itemPOJO.getDataModelName() != null) {
        DataModelPOJO dataModelPOJO=ObjectPOJO.load(itemPOJO.getDataModelRevision(),DataModelPOJO.class,new DataModelPOJOPK(itemPOJO.getDataModelName()));
        if (dataModelPOJO != null) {
          Element projection=null;
          try {
            projection=itemPOJO.getProjection();
          }
 catch (          Exception e) {
            throw new XtentisException("String_Node_Str");
          }
          if (projection != null)           Util.validate(itemPOJO.getProjection(),dataModelPOJO.getSchema());
        }
      }
    }
    DroppedItemPOJO droppedItemPOJO=new DroppedItemPOJO(revisionID,itemPOJOPK.getDataClusterPOJOPK(),uniqueID,itemPOJOPK.getConceptName(),itemPOJOPK.getIds(),partPath,xmlDocument.toString(),userName,new Long(System.currentTimeMillis()));
    StringWriter sw=new StringWriter();
    Marshaller.marshal(droppedItemPOJO,sw);
    long res=server.putDocumentFromString(sw.toString(),droppedItemPOJO.obtainDroppedItemPK().getUniquePK(),"String_Node_Str",null);
    if (res == -1)     return null;
    try {
      if (partPath.equals("String_Node_Str")) {
        server.deleteDocument(revisionID,dataClusterName,uniqueID);
      }
 else {
        server.putDocumentFromString(Util.nodeToString(sourceDoc),uniqueID,dataClusterName,revisionID);
      }
    }
 catch (    Exception e) {
      e.printStackTrace();
      server.deleteDocument(null,"String_Node_Str",droppedItemPOJO.obtainDroppedItemPK().getUniquePK());
      return null;
    }
    return droppedItemPOJO.obtainDroppedItemPK();
  }
 catch (  SAXException e) {
    String err="String_Node_Str" + e.getLocalizedMessage();
    throw new XtentisException(err);
  }
catch (  Exception e) {
    String err="String_Node_Str" + itemPOJOPK.getUniqueID() + "String_Node_Str"+ e.getClass().getName()+ "String_Node_Str"+ e.getLocalizedMessage();
    org.apache.log4j.Logger.getLogger(ItemPOJO.class).error(err,e);
    throw new XtentisException(err);
  }
}