Program: 47408
Project: 47408
Buggy source:
private void internalCopyOrMove(final Serializable fileId,final String destRelPath,final String versionMessage,final boolean copy){
  if (isKioskEnabled()) {
    throw new RuntimeException(Messages.getInstance().getString("String_Node_Str"));
  }
  Assert.notNull(fileId);
  jcrTemplate.execute(new JcrCallback(){
    @Override public Object doInJcr(    final Session session) throws RepositoryException, IOException {
      RepositoryFile file=getFileById(fileId);
      RepositoryFileAcl acl=aclDao.getAcl(fileId);
      if (!accessVoterManager.hasAccess(file,RepositoryFilePermission.WRITE,acl,PentahoSessionHolder.getSession())) {
        return null;
      }
      PentahoJcrConstants pentahoJcrConstants=new PentahoJcrConstants(session);
      String destAbsPath=pathConversionHelper.relToAbs(destRelPath);
      String cleanDestAbsPath=destAbsPath;
      if (cleanDestAbsPath.endsWith(RepositoryFile.SEPARATOR)) {
        cleanDestAbsPath.substring(0,cleanDestAbsPath.length() - 1);
      }
      Node srcFileNode=session.getNodeByIdentifier(fileId.toString());
      Serializable srcParentFolderId=JcrRepositoryFileUtils.getParentId(session,fileId);
      boolean appendFileName=false;
      boolean destExists=true;
      Node destFileNode=null;
      Node destParentFolderNode=null;
      try {
        destFileNode=(Node)session.getItem(cleanDestAbsPath);
      }
 catch (      PathNotFoundException e) {
        destExists=false;
      }
      if (destExists) {
        Assert.isTrue(JcrRepositoryFileUtils.isSupportedNodeType(pentahoJcrConstants,destFileNode));
        Assert.isTrue(!(JcrRepositoryFileUtils.isPentahoFolder(pentahoJcrConstants,srcFileNode) && JcrRepositoryFileUtils.isPentahoFile(pentahoJcrConstants,destFileNode)),Messages.getInstance().getString("String_Node_Str"));
        if (JcrRepositoryFileUtils.isPentahoFolder(pentahoJcrConstants,destFileNode)) {
          appendFileName=true;
          destParentFolderNode=destFileNode;
        }
 else {
          int lastSlashIndex=cleanDestAbsPath.lastIndexOf(RepositoryFile.SEPARATOR);
          Assert.isTrue(lastSlashIndex > 1,Messages.getInstance().getString("String_Node_Str"));
          String absPathToDestParentFolder=cleanDestAbsPath.substring(0,lastSlashIndex);
          destParentFolderNode=(Node)session.getItem(absPathToDestParentFolder);
        }
      }
 else {
        int lastSlashIndex=cleanDestAbsPath.lastIndexOf(RepositoryFile.SEPARATOR);
        Assert.isTrue(lastSlashIndex > 1,Messages.getInstance().getString("String_Node_Str"));
        String absPathToDestParentFolder=cleanDestAbsPath.substring(0,lastSlashIndex);
        JcrRepositoryFileUtils.checkName(cleanDestAbsPath.substring(lastSlashIndex + 1));
        try {
          destParentFolderNode=(Node)session.getItem(absPathToDestParentFolder);
        }
 catch (        PathNotFoundException e1) {
          Assert.isTrue(false,Messages.getInstance().getString("String_Node_Str"));
        }
        Assert.isTrue(JcrRepositoryFileUtils.isPentahoFolder(pentahoJcrConstants,destParentFolderNode),Messages.getInstance().getString("String_Node_Str"));
      }
      if (!copy) {
        JcrRepositoryFileUtils.checkoutNearestVersionableFileIfNecessary(session,pentahoJcrConstants,srcParentFolderId);
      }
      JcrRepositoryFileUtils.checkoutNearestVersionableNodeIfNecessary(session,pentahoJcrConstants,destParentFolderNode);
      String finalSrcAbsPath=srcFileNode.getPath();
      String finalDestAbsPath=appendFileName && !file.isFolder() ? cleanDestAbsPath + RepositoryFile.SEPARATOR + srcFileNode.getName() : cleanDestAbsPath;
      try {
        if (copy) {
          session.getWorkspace().copy(finalSrcAbsPath,finalDestAbsPath);
        }
 else {
          session.getWorkspace().move(finalSrcAbsPath,finalDestAbsPath);
        }
      }
 catch (      ItemExistsException iae) {
        throw new UnifiedRepositoryException((file.isFolder() ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str" + cleanDestAbsPath+ "String_Node_Str");
      }
      RepositoryFile destFile=internalGetFile(session,finalDestAbsPath,true,null);
      if (!destFile.isFolder()) {
        String title=extractNameFromPath(finalDestAbsPath);
        Map<String,Properties> localePropertiesMap=destFile.getLocalePropertiesMap();
        for (        Entry<String,Properties> entry : destFile.getLocalePropertiesMap().entrySet()) {
          Properties properties=entry.getValue();
          if (properties.containsKey("String_Node_Str")) {
            properties.setProperty("String_Node_Str",title);
          }
          if (properties.containsKey("String_Node_Str")) {
            properties.setProperty("String_Node_Str",title);
          }
        }
        String contentType=null;
        if (destFile.getId() != null) {
          Node nodeToBeUpdated=session.getNodeByIdentifier(destFile.getId().toString());
          contentType=nodeToBeUpdated.getProperty(pentahoJcrConstants.getPHO_CONTENTTYPE()).getString();
        }
        RepositoryFile updatedFile=new RepositoryFile.Builder(destFile).localePropertiesMap(localePropertiesMap).title(title).build();
        internalUpdateFile(session,pentahoJcrConstants,updatedFile,getData(destFile.getId(),null,((contentType != null && contentType.equals(IRepositoryFileData.NODE_CONTENT_TYPE)) ? NodeRepositoryFileData.class : SimpleRepositoryFileData.class)),"String_Node_Str");
      }
      JcrRepositoryFileUtils.checkinNearestVersionableNodeIfNecessary(session,pentahoJcrConstants,destParentFolderNode,versionMessage);
      if (!copy && !destParentFolderNode.getIdentifier().equals(srcParentFolderId.toString())) {
        JcrRepositoryFileUtils.checkinNearestVersionableFileIfNecessary(session,pentahoJcrConstants,srcParentFolderId,versionMessage);
      }
      return null;
    }
  }
);
}

Fixed version (ground truth):
private void internalCopyOrMove(final Serializable fileId,final String destRelPath,final String versionMessage,final boolean copy){
  if (isKioskEnabled()) {
    throw new RuntimeException(Messages.getInstance().getString("String_Node_Str"));
  }
  Assert.notNull(fileId);
  jcrTemplate.execute(new JcrCallback(){
    @Override public Object doInJcr(    final Session session) throws RepositoryException, IOException {
      RepositoryFile file=getFileById(fileId);
      RepositoryFileAcl acl=aclDao.getAcl(fileId);
      if (!accessVoterManager.hasAccess(file,RepositoryFilePermission.WRITE,acl,PentahoSessionHolder.getSession())) {
        return null;
      }
      PentahoJcrConstants pentahoJcrConstants=new PentahoJcrConstants(session);
      String destAbsPath=pathConversionHelper.relToAbs(destRelPath);
      String cleanDestAbsPath=destAbsPath;
      if (cleanDestAbsPath.endsWith(RepositoryFile.SEPARATOR)) {
        cleanDestAbsPath.substring(0,cleanDestAbsPath.length() - 1);
      }
      Node srcFileNode=session.getNodeByIdentifier(fileId.toString());
      Serializable srcParentFolderId=JcrRepositoryFileUtils.getParentId(session,fileId);
      boolean appendFileName=false;
      boolean destExists=true;
      Node destFileNode=null;
      Node destParentFolderNode=null;
      try {
        destFileNode=(Node)session.getItem(cleanDestAbsPath);
      }
 catch (      PathNotFoundException e) {
        destExists=false;
      }
      if (destExists) {
        Assert.isTrue(JcrRepositoryFileUtils.isSupportedNodeType(pentahoJcrConstants,destFileNode));
        Assert.isTrue(!(JcrRepositoryFileUtils.isPentahoFolder(pentahoJcrConstants,srcFileNode) && JcrRepositoryFileUtils.isPentahoFile(pentahoJcrConstants,destFileNode)),Messages.getInstance().getString("String_Node_Str"));
        if (JcrRepositoryFileUtils.isPentahoFolder(pentahoJcrConstants,destFileNode)) {
          appendFileName=true;
          destParentFolderNode=destFileNode;
        }
 else {
          int lastSlashIndex=cleanDestAbsPath.lastIndexOf(RepositoryFile.SEPARATOR);
          Assert.isTrue(lastSlashIndex > 1,Messages.getInstance().getString("String_Node_Str"));
          String absPathToDestParentFolder=cleanDestAbsPath.substring(0,lastSlashIndex);
          destParentFolderNode=(Node)session.getItem(absPathToDestParentFolder);
        }
      }
 else {
        int lastSlashIndex=cleanDestAbsPath.lastIndexOf(RepositoryFile.SEPARATOR);
        Assert.isTrue(lastSlashIndex > 1,Messages.getInstance().getString("String_Node_Str"));
        String absPathToDestParentFolder=cleanDestAbsPath.substring(0,lastSlashIndex);
        JcrRepositoryFileUtils.checkName(cleanDestAbsPath.substring(lastSlashIndex + 1));
        try {
          destParentFolderNode=(Node)session.getItem(absPathToDestParentFolder);
        }
 catch (        PathNotFoundException e1) {
          Assert.isTrue(false,Messages.getInstance().getString("String_Node_Str"));
        }
        Assert.isTrue(JcrRepositoryFileUtils.isPentahoFolder(pentahoJcrConstants,destParentFolderNode),Messages.getInstance().getString("String_Node_Str"));
      }
      if (!copy) {
        JcrRepositoryFileUtils.checkoutNearestVersionableFileIfNecessary(session,pentahoJcrConstants,srcParentFolderId);
      }
      JcrRepositoryFileUtils.checkoutNearestVersionableNodeIfNecessary(session,pentahoJcrConstants,destParentFolderNode);
      String finalSrcAbsPath=srcFileNode.getPath();
      String finalDestAbsPath=appendFileName && !file.isFolder() ? cleanDestAbsPath + RepositoryFile.SEPARATOR + srcFileNode.getName() : cleanDestAbsPath;
      try {
        if (copy) {
          session.getWorkspace().copy(finalSrcAbsPath,finalDestAbsPath);
        }
 else {
          session.getWorkspace().move(finalSrcAbsPath,finalDestAbsPath);
        }
      }
 catch (      ItemExistsException iae) {
        throw new UnifiedRepositoryException((file.isFolder() ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str" + cleanDestAbsPath+ "String_Node_Str");
      }
      JcrRepositoryFileUtils.checkinNearestVersionableNodeIfNecessary(session,pentahoJcrConstants,destParentFolderNode,versionMessage);
      if (!copy && !destParentFolderNode.getIdentifier().equals(srcParentFolderId.toString())) {
        JcrRepositoryFileUtils.checkinNearestVersionableFileIfNecessary(session,pentahoJcrConstants,srcParentFolderId,versionMessage);
      }
      return null;
    }
  }
);
}