Program: 102740
Project: 102740
Buggy source:
/** 
 * Edit generic property of document.
 * @param propertyName property that need to edit
 * @param newValue the new 'requested property' of document
 * @param repositoryName the repository name
 * @param workspaceName the workspace name
 * @param nodeUIID the UIID of node
 * @param siteName the site name
 * @return the response
 * @throws Exception the exception
 */
public Response modifyProperty(String propertyName,String newValue,String repositoryName,String workspaceName,String nodeUIID,String siteName,String language){
  ResourceBundle resourceBundle=null;
  String messageKey="String_Node_Str";
  String message="String_Node_Str";
  Document document=null;
  Element localeMsg=null;
  try {
    Locale locale=new Locale(language);
    ResourceBundleService resourceBundleService=WCMCoreUtils.getService(ResourceBundleService.class);
    resourceBundle=resourceBundleService.getResourceBundle(localeFile,locale);
  }
 catch (  Exception ex) {
    if (LOG.isErrorEnabled()) {
      LOG.error("String_Node_Str",ex);
    }
  }
  try {
    document=DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
  }
 catch (  Exception ex) {
    if (LOG.isErrorEnabled()) {
      LOG.error("String_Node_Str",ex);
    }
  }
  CacheControl cacheControl=new CacheControl();
  cacheControl.setNoCache(true);
  cacheControl.setNoStore(true);
  try {
    SessionProvider sessionProvider=WCMCoreUtils.getUserSessionProvider();
    RepositoryService repositoryService=WCMCoreUtils.getService(RepositoryService.class);
    ManageableRepository manageableRepository=repositoryService.getCurrentRepository();
    Session session=sessionProvider.getSession(workspaceName,manageableRepository);
    try {
      localeMsg=document.createElement("String_Node_Str");
      Node node=session.getNodeByUUID(nodeUIID);
      node=(Node)session.getItem(node.getPath());
      if (canSetProperty(node)) {
        if (!sameValue(newValue,node,propertyName)) {
          if (newValue.length() > 0) {
            newValue=Text.unescapeIllegalJcrChars(newValue.trim());
            PortalContainerInfo containerInfo=WCMCoreUtils.getService(PortalContainerInfo.class);
            String containerName=containerInfo.getContainerName();
            ListenerService listenerService=WCMCoreUtils.getService(ListenerService.class,containerName);
            if (propertyName.equals(EXO_TITLE)) {
              if (!node.hasProperty(EXO_TITLE))               node.addMixin(EXO_RSS_ENABLE);
            }
            if (!propertyName.contains("String_Node_Str")) {
              if (node.hasProperty(propertyName) && node.getProperty(propertyName).getDefinition().isMultiple()) {
                Value[] currentValue=node.getProperty(propertyName).getValues();
                if (currentValue == null)                 currentValue=new Value[1];
                currentValue[0]=session.getValueFactory().createValue(newValue);
                node.setProperty(propertyName,currentValue);
              }
 else {
                node.setProperty(propertyName,newValue);
              }
            }
 else {
              int iSlash=propertyName.lastIndexOf("String_Node_Str");
              String subnodePath=propertyName.substring(0,iSlash);
              String subnodeProperty=propertyName.substring(iSlash + 1);
              Node subnode=node.getNode(subnodePath);
              if (subnode.hasProperty(subnodeProperty) && subnode.getProperty(subnodeProperty).getDefinition().isMultiple()) {
                Value[] currentValue=subnode.getProperty(subnodeProperty).getValues();
                if (currentValue == null)                 currentValue=new Value[1];
                currentValue[0]=session.getValueFactory().createValue(newValue);
                subnode.setProperty(subnodeProperty,currentValue);
              }
 else {
                subnode.setProperty(subnodeProperty,newValue);
              }
            }
            ConversationState conversationState=ConversationState.getCurrent();
            conversationState.setAttribute("String_Node_Str",siteName);
            listenerService.broadcast(POST_EDIT_CONTENT_EVENT,null,node);
            session.save();
          }
        }
      }
 else {
        messageKey="String_Node_Str";
        message=resourceBundle.getString(messageKey);
        localeMsg.setAttribute("String_Node_Str",message);
        document.appendChild(localeMsg);
        return Response.ok(new DOMSource(document),MediaType.TEXT_XML).cacheControl(cacheControl).build();
      }
    }
 catch (    AccessDeniedException ace) {
      if (LOG.isErrorEnabled()) {
        LOG.error("String_Node_Str",ace);
      }
      messageKey="String_Node_Str";
      message=resourceBundle.getString(messageKey);
      localeMsg.setAttribute("String_Node_Str",message);
      document.appendChild(localeMsg);
      return Response.ok(new DOMSource(document),MediaType.TEXT_XML).cacheControl(cacheControl).build();
    }
catch (    FileNotFoundException fie) {
      if (LOG.isErrorEnabled()) {
        LOG.error("String_Node_Str",fie);
      }
      messageKey="String_Node_Str";
      message=resourceBundle.getString(messageKey);
      localeMsg.setAttribute("String_Node_Str",message);
      document.appendChild(localeMsg);
      return Response.ok(new DOMSource(document),MediaType.TEXT_XML).cacheControl(cacheControl).build();
    }
catch (    LockException lockex) {
      if (LOG.isErrorEnabled()) {
        LOG.error("String_Node_Str",lockex);
      }
      messageKey="String_Node_Str";
      message=resourceBundle.getString(messageKey);
      localeMsg.setAttribute("String_Node_Str",message);
      document.appendChild(localeMsg);
      return Response.ok(new DOMSource(document),MediaType.TEXT_XML).cacheControl(cacheControl).build();
    }
  }
 catch (  Exception e) {
    if (LOG.isErrorEnabled()) {
      LOG.error("String_Node_Str",e);
    }
    messageKey="String_Node_Str";
    message=resourceBundle.getString(messageKey);
    localeMsg.setAttribute("String_Node_Str",message);
    document.appendChild(localeMsg);
    return Response.ok(new DOMSource(document),MediaType.TEXT_XML).cacheControl(cacheControl).build();
  }
  localeMsg.setAttribute("String_Node_Str","String_Node_Str");
  document.appendChild(localeMsg);
  return Response.ok(new DOMSource(document),MediaType.TEXT_XML).cacheControl(cacheControl).build();
}

Fixed version (ground truth):
/** 
 * Edit generic property of document.
 * @param propertyName property that need to edit
 * @param newValue the new 'requested property' of document
 * @param repositoryName the repository name
 * @param workspaceName the workspace name
 * @param nodeUIID the UIID of node
 * @param siteName the site name
 * @return the response
 */
public Response modifyProperty(String propertyName,String newValue,String repositoryName,String workspaceName,String nodeUIID,String siteName,String language){
  ResourceBundle resourceBundle=null;
  String messageKey="String_Node_Str";
  String message="String_Node_Str";
  Document document=null;
  Element localeMsg=null;
  try {
    Locale locale=new Locale(language);
    ResourceBundleService resourceBundleService=WCMCoreUtils.getService(ResourceBundleService.class);
    resourceBundle=resourceBundleService.getResourceBundle(localeFile,locale);
  }
 catch (  Exception ex) {
    if (LOG.isErrorEnabled()) {
      LOG.error("String_Node_Str",ex);
    }
  }
  try {
    document=DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
  }
 catch (  Exception ex) {
    if (LOG.isErrorEnabled()) {
      LOG.error("String_Node_Str",ex);
    }
  }
  CacheControl cacheControl=new CacheControl();
  cacheControl.setNoCache(true);
  cacheControl.setNoStore(true);
  try {
    SessionProvider sessionProvider=WCMCoreUtils.getUserSessionProvider();
    RepositoryService repositoryService=WCMCoreUtils.getService(RepositoryService.class);
    ManageableRepository manageableRepository=repositoryService.getCurrentRepository();
    Session session=sessionProvider.getSession(workspaceName,manageableRepository);
    try {
      localeMsg=document.createElement("String_Node_Str");
      Node node=session.getNodeByUUID(nodeUIID);
      node=(Node)session.getItem(node.getPath());
      if (canSetProperty(node)) {
        if (!sameValue(newValue,node,propertyName)) {
          if (newValue.length() > 0) {
            newValue=Text.unescapeIllegalJcrChars(newValue.trim());
            PortalContainerInfo containerInfo=WCMCoreUtils.getService(PortalContainerInfo.class);
            String containerName=containerInfo.getContainerName();
            ListenerService listenerService=WCMCoreUtils.getService(ListenerService.class,containerName);
            if (propertyName.equals(EXO_TITLE)) {
              if (!node.hasProperty(EXO_TITLE))               node.addMixin(EXO_RSS_ENABLE);
            }
            if (!propertyName.contains("String_Node_Str")) {
              if (node.hasProperty(propertyName) && node.getProperty(propertyName).getDefinition().isMultiple()) {
                Value[] currentValue=node.getProperty(propertyName).getValues();
                if (currentValue == null)                 currentValue=new Value[1];
                currentValue[0]=session.getValueFactory().createValue(newValue);
                node.setProperty(propertyName,currentValue);
              }
 else {
                node.setProperty(propertyName,newValue);
              }
            }
 else {
              int iSlash=propertyName.lastIndexOf("String_Node_Str");
              String subnodePath=propertyName.substring(0,iSlash);
              String subnodeProperty=propertyName.substring(iSlash + 1);
              Node subnode=node.getNode(subnodePath);
              if (subnode.hasProperty(subnodeProperty) && subnode.getProperty(subnodeProperty).getDefinition().isMultiple()) {
                Value[] currentValue=subnode.getProperty(subnodeProperty).getValues();
                if (currentValue == null)                 currentValue=new Value[1];
                currentValue[0]=session.getValueFactory().createValue(newValue);
                subnode.setProperty(subnodeProperty,currentValue);
              }
 else {
                subnode.setProperty(subnodeProperty,newValue);
              }
            }
            ConversationState conversationState=ConversationState.getCurrent();
            conversationState.setAttribute("String_Node_Str",siteName);
            listenerService.broadcast(POST_EDIT_CONTENT_EVENT,null,node);
            session.save();
          }
        }
      }
 else {
        messageKey="String_Node_Str";
        message=resourceBundle.getString(messageKey);
        localeMsg.setAttribute("String_Node_Str",message);
        document.appendChild(localeMsg);
        return Response.ok(new DOMSource(document),MediaType.TEXT_XML).cacheControl(cacheControl).build();
      }
    }
 catch (    AccessDeniedException ace) {
      if (LOG.isErrorEnabled()) {
        LOG.error("String_Node_Str",ace);
      }
      messageKey="String_Node_Str";
      message=resourceBundle.getString(messageKey);
      localeMsg.setAttribute("String_Node_Str",message);
      document.appendChild(localeMsg);
      return Response.ok(new DOMSource(document),MediaType.TEXT_XML).cacheControl(cacheControl).build();
    }
catch (    FileNotFoundException fie) {
      if (LOG.isErrorEnabled()) {
        LOG.error("String_Node_Str",fie);
      }
      messageKey="String_Node_Str";
      message=resourceBundle.getString(messageKey);
      localeMsg.setAttribute("String_Node_Str",message);
      document.appendChild(localeMsg);
      return Response.ok(new DOMSource(document),MediaType.TEXT_XML).cacheControl(cacheControl).build();
    }
catch (    LockException lockex) {
      if (LOG.isErrorEnabled()) {
        LOG.error("String_Node_Str",lockex);
      }
      messageKey="String_Node_Str";
      message=resourceBundle.getString(messageKey);
      localeMsg.setAttribute("String_Node_Str",message);
      document.appendChild(localeMsg);
      return Response.ok(new DOMSource(document),MediaType.TEXT_XML).cacheControl(cacheControl).build();
    }
  }
 catch (  Exception e) {
    if (LOG.isErrorEnabled()) {
      LOG.error("String_Node_Str",e);
    }
    messageKey="String_Node_Str";
    message=resourceBundle.getString(messageKey);
    localeMsg.setAttribute("String_Node_Str",message);
    document.appendChild(localeMsg);
    return Response.ok(new DOMSource(document),MediaType.TEXT_XML).cacheControl(cacheControl).build();
  }
  localeMsg.setAttribute("String_Node_Str","String_Node_Str");
  document.appendChild(localeMsg);
  return Response.ok(new DOMSource(document),MediaType.TEXT_XML).cacheControl(cacheControl).build();
}