Program: 172327
Project: 172327
Buggy source:
/** 
 * Parse and validate the parameter string and create a device context object for this instance of the shared device. The same DeviceInterface implementation may be used for multiple shares.
 * @param args ConfigElement
 * @return DeviceContext
 * @exception DeviceContextException
 */
public DeviceContext createContext(ConfigElement cfg) throws DeviceContextException {
  authComponent.setCurrentUser(authComponent.getSystemUserName());
  UserTransaction tx=transactionService.getUserTransaction(true);
  ContentContext context=null;
  try {
    if (tx != null)     tx.begin();
    ConfigElement storeElement=cfg.getChild(KEY_STORE);
    if (storeElement == null || storeElement.getValue() == null || storeElement.getValue().length() == 0) {
      throw new DeviceContextException("String_Node_Str" + KEY_STORE);
    }
    String storeValue=storeElement.getValue();
    StoreRef storeRef=new StoreRef(storeValue);
    if (!nodeService.exists(storeRef)) {
      throw new DeviceContextException("String_Node_Str" + storeRef);
    }
    NodeRef storeRootNodeRef=nodeService.getRootNode(storeRef);
    ConfigElement rootPathElement=cfg.getChild(KEY_ROOT_PATH);
    if (rootPathElement == null || rootPathElement.getValue() == null || rootPathElement.getValue().length() == 0) {
      throw new DeviceContextException("String_Node_Str" + KEY_ROOT_PATH);
    }
    String rootPath=rootPathElement.getValue();
    List<NodeRef> nodeRefs=searchService.selectNodes(storeRootNodeRef,rootPath,null,namespaceService,false);
    NodeRef rootNodeRef=null;
    if (nodeRefs.size() > 1) {
      throw new DeviceContextException("String_Node_Str" + "String_Node_Str" + rootPath + "String_Node_Str"+ "String_Node_Str"+ nodeRefs);
    }
 else     if (nodeRefs.size() == 0) {
      throw new DeviceContextException("String_Node_Str" + "String_Node_Str" + rootPath);
    }
 else {
      rootNodeRef=nodeRefs.get(0);
    }
    ConfigElement relativePathElement=cfg.getChild(KEY_RELATIVE_PATH);
    if (relativePathElement != null) {
      String relPath=relativePathElement.getValue().replace('/',FileName.DOS_SEPERATOR);
      NodeRef relPathNode=cifsHelper.getNodeRef(rootNodeRef,relPath);
      if (cifsHelper.isDirectory(relPathNode) == false)       throw new DeviceContextException("String_Node_Str" + relativePathElement.getValue());
      rootNodeRef=relPathNode;
    }
    tx.commit();
    tx=null;
    context=new ContentContext(storeValue,rootPath,rootNodeRef);
    context.setDiskInformation(new SrvDiskInfo(2560,64,512,2304));
    context.setFilesystemAttributes(FileSystem.CasePreservedNames);
  }
 catch (  Exception ex) {
    logger.error("String_Node_Str",ex);
  }
 finally {
    if (tx != null) {
      try {
        tx.rollback();
      }
 catch (      Exception ex) {
        logger.warn("String_Node_Str",ex);
      }
    }
  }
  try {
    Object ioctlObj=Class.forName("String_Node_Str").newInstance();
    if (ioctlObj instanceof IOControlHandler) {
      m_ioHandler=(IOControlHandler)ioctlObj;
      m_ioHandler.initialize(this,cifsHelper,transactionService,nodeService,checkInOutService);
    }
    if (m_ioHandler != null) {
      ConfigElement dragDropElem=cfg.getChild("String_Node_Str");
      if (dragDropElem != null) {
        ConfigElement pseudoName=dragDropElem.getChild("String_Node_Str");
        ConfigElement appPath=dragDropElem.getChild("String_Node_Str");
        if (pseudoName != null && appPath != null) {
          URL appURL=this.getClass().getClassLoader().getResource(appPath.getValue());
          if (appURL == null)           throw new DeviceContextException("String_Node_Str" + appPath.getValue());
          File appFile=new File(appURL.getFile());
          if (appFile.exists() == false)           throw new DeviceContextException("String_Node_Str" + appPath.getValue());
          PseudoFile dragDropPseudo=new LocalPseudoFile(pseudoName.getValue(),appFile.getAbsolutePath());
          context.setDragAndDropApp(dragDropPseudo);
        }
      }
    }
  }
 catch (  Exception ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str");
  }
  ConfigElement urlFileElem=cfg.getChild("String_Node_Str");
  if (urlFileElem != null) {
    ConfigElement pseudoName=urlFileElem.getChild("String_Node_Str");
    ConfigElement webPath=urlFileElem.getChild("String_Node_Str");
    if (pseudoName != null && webPath != null) {
      String path=webPath.getValue();
      if (path.endsWith("String_Node_Str") == false)       path=path + "String_Node_Str";
      if (pseudoName.getValue().endsWith("String_Node_Str") == false)       throw new DeviceContextException("String_Node_Str" + pseudoName.getValue());
      context.setURLFileName(pseudoName.getValue());
      context.setURLPrefix(path);
    }
  }
  if (context.hasDragAndDropApp() || context.hasURLFile()) {
    m_pseudoFiles=new ContentPseudoFileImpl();
  }
  ConfigElement offlineFiles=cfg.getChild("String_Node_Str");
  if (offlineFiles != null) {
    cifsHelper.setMarkLockedFilesAsOffline(true);
    logger.info("String_Node_Str");
  }
  return context;
}

Fixed version (ground truth):
/** 
 * Parse and validate the parameter string and create a device context object for this instance of the shared device. The same DeviceInterface implementation may be used for multiple shares.
 * @param args ConfigElement
 * @return DeviceContext
 * @exception DeviceContextException
 */
public DeviceContext createContext(ConfigElement cfg) throws DeviceContextException {
  authComponent.setCurrentUser(authComponent.getSystemUserName());
  UserTransaction tx=transactionService.getUserTransaction(true);
  ContentContext context=null;
  try {
    if (tx != null)     tx.begin();
    ConfigElement storeElement=cfg.getChild(KEY_STORE);
    if (storeElement == null || storeElement.getValue() == null || storeElement.getValue().length() == 0) {
      throw new DeviceContextException("String_Node_Str" + KEY_STORE);
    }
    String storeValue=storeElement.getValue();
    StoreRef storeRef=new StoreRef(storeValue);
    if (!nodeService.exists(storeRef)) {
      throw new DeviceContextException("String_Node_Str" + storeRef);
    }
    NodeRef storeRootNodeRef=nodeService.getRootNode(storeRef);
    ConfigElement rootPathElement=cfg.getChild(KEY_ROOT_PATH);
    if (rootPathElement == null || rootPathElement.getValue() == null || rootPathElement.getValue().length() == 0) {
      throw new DeviceContextException("String_Node_Str" + KEY_ROOT_PATH);
    }
    String rootPath=rootPathElement.getValue();
    List<NodeRef> nodeRefs=searchService.selectNodes(storeRootNodeRef,rootPath,null,namespaceService,false);
    NodeRef rootNodeRef=null;
    if (nodeRefs.size() > 1) {
      throw new DeviceContextException("String_Node_Str" + "String_Node_Str" + rootPath + "String_Node_Str"+ "String_Node_Str"+ nodeRefs);
    }
 else     if (nodeRefs.size() == 0) {
      throw new DeviceContextException("String_Node_Str" + "String_Node_Str" + rootPath);
    }
 else {
      rootNodeRef=nodeRefs.get(0);
    }
    ConfigElement relativePathElement=cfg.getChild(KEY_RELATIVE_PATH);
    if (relativePathElement != null) {
      String relPath=relativePathElement.getValue().replace('/',FileName.DOS_SEPERATOR);
      NodeRef relPathNode=cifsHelper.getNodeRef(rootNodeRef,relPath);
      if (cifsHelper.isDirectory(relPathNode) == false)       throw new DeviceContextException("String_Node_Str" + relativePathElement.getValue());
      rootNodeRef=relPathNode;
    }
    tx.commit();
    tx=null;
    context=new ContentContext(storeValue,rootPath,rootNodeRef);
    context.setDiskInformation(new SrvDiskInfo(2560000,64,512,2304000));
    context.setFilesystemAttributes(FileSystem.CasePreservedNames);
  }
 catch (  Exception ex) {
    logger.error("String_Node_Str",ex);
  }
 finally {
    if (tx != null) {
      try {
        tx.rollback();
      }
 catch (      Exception ex) {
        logger.warn("String_Node_Str",ex);
      }
    }
  }
  ConfigElement dragDropElem=cfg.getChild("String_Node_Str");
  if (dragDropElem != null) {
    ConfigElement pseudoName=dragDropElem.getChild("String_Node_Str");
    ConfigElement appPath=dragDropElem.getChild("String_Node_Str");
    if (pseudoName != null && appPath != null) {
      URL appURL=this.getClass().getClassLoader().getResource(appPath.getValue());
      if (appURL == null)       throw new DeviceContextException("String_Node_Str" + appPath.getValue());
      File appFile=new File(appURL.getFile());
      if (appFile.exists() == false)       throw new DeviceContextException("String_Node_Str" + appPath.getValue());
      PseudoFile dragDropPseudo=new LocalPseudoFile(pseudoName.getValue(),appFile.getAbsolutePath());
      context.setDragAndDropApp(dragDropPseudo);
    }
    try {
      m_ioHandler=new ContentIOControlHandler();
      m_ioHandler.initialize(this,cifsHelper,transactionService,nodeService,checkInOutService);
    }
 catch (    Exception ex) {
      logger.error("String_Node_Str",ex);
      throw new DeviceContextException("String_Node_Str");
    }
  }
  ConfigElement urlFileElem=cfg.getChild("String_Node_Str");
  if (urlFileElem != null) {
    ConfigElement pseudoName=urlFileElem.getChild("String_Node_Str");
    ConfigElement webPath=urlFileElem.getChild("String_Node_Str");
    if (pseudoName != null && webPath != null) {
      String path=webPath.getValue();
      if (path.endsWith("String_Node_Str") == false)       path=path + "String_Node_Str";
      if (pseudoName.getValue().endsWith("String_Node_Str") == false)       throw new DeviceContextException("String_Node_Str" + pseudoName.getValue());
      context.setURLFileName(pseudoName.getValue());
      context.setURLPrefix(path);
    }
  }
  if (context.hasDragAndDropApp() || context.hasURLFile()) {
    m_pseudoFiles=new ContentPseudoFileImpl();
  }
  ConfigElement offlineFiles=cfg.getChild("String_Node_Str");
  if (offlineFiles != null) {
    cifsHelper.setMarkLockedFilesAsOffline(true);
    logger.info("String_Node_Str");
  }
  return context;
}