Program: 90751
Project: 90751
Buggy source:
public static void prepareWebArchive(String webAppsDir,String warFile) throws Exception, IOException {
  String webModule=warFile;
  if (webModule.indexOf("String_Node_Str") != -1)   webModule=webModule.substring(webModule.lastIndexOf("String_Node_Str") + 1);
  if (webModule.indexOf(dirDelim) != -1)   webModule=webModule.substring(webModule.lastIndexOf(dirDelim) + 1);
  if (webModule.endsWith("String_Node_Str"))   webModule=webModule.substring(0,webModule.lastIndexOf("String_Node_Str"));
  System.out.println("String_Node_Str" + webModule + "String_Node_Str");
  Mapping mappingPortletXml=null;
  Mapping mappingWebXml=null;
  String _portlet_mapping=webAppsDir + portalImplWebDir + "String_Node_Str"+ dirDelim+ "String_Node_Str"+ dirDelim+ "String_Node_Str"+ dirDelim+ "String_Node_Str";
  mappingPortletXml=new Mapping();
  try {
    mappingPortletXml.loadMapping(_portlet_mapping);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str" + e);
    throw new IOException("String_Node_Str" + _web_mapping + "String_Node_Str"+ e.getMessage());
  }
  File portletXml=new File(webAppsDir + webModule + webInfDir+ "String_Node_Str");
  String _web_mapping=webAppsDir + portalImplWebDir + "String_Node_Str"+ dirDelim+ "String_Node_Str"+ dirDelim+ "String_Node_Str"+ dirDelim+ "String_Node_Str";
  mappingWebXml=new Mapping();
  try {
    mappingWebXml.loadMapping(_web_mapping);
  }
 catch (  Exception e) {
    throw new IOException("String_Node_Str" + _web_mapping + "String_Node_Str"+ e.getMessage());
  }
  File webXml=new File(webAppsDir + webModule + webInfDir+ "String_Node_Str");
  try {
    org.w3c.dom.Document portletDocument=XmlParser.parsePortletXml(new FileInputStream(portletXml));
    Unmarshaller unmarshaller=new Unmarshaller(mappingPortletXml);
    unmarshaller.setIgnoreExtraElements(true);
    unmarshaller.setIgnoreExtraAttributes(true);
    PortletApplicationDefinitionImpl portletApp=(PortletApplicationDefinitionImpl)unmarshaller.unmarshal(portletDocument);
    Vector structure=new Vector();
    structure.add(webModule);
    structure.add(null);
    structure.add(null);
    portletApp.preBuild(structure);
    if (debug) {
      System.out.println(portletApp);
    }
    WebApplicationDefinitionImpl webApp=null;
    if (webXml.exists()) {
      org.w3c.dom.Document webDocument=XmlParser.parseWebXml(new FileInputStream(webXml));
      Unmarshaller unmarshallerWeb=new Unmarshaller(mappingWebXml);
      unmarshallerWeb.setIgnoreExtraElements(true);
      unmarshallerWeb.setIgnoreExtraAttributes(true);
      webApp=(WebApplicationDefinitionImpl)unmarshallerWeb.unmarshal(webDocument);
    }
 else {
      webApp=new WebApplicationDefinitionImpl();
      DisplayNameImpl dispName=new DisplayNameImpl();
      dispName.setDisplayName(webModule);
      dispName.setLocale(Locale.ENGLISH);
      DisplayNameSetImpl dispSet=new DisplayNameSetImpl();
      dispSet.add(dispName);
      webApp.setDisplayNames(dispSet);
      DescriptionImpl desc=new DescriptionImpl();
      desc.setDescription("String_Node_Str");
      desc.setLocale(Locale.ENGLISH);
      DescriptionSetImpl descSet=new DescriptionSetImpl();
      descSet.add(desc);
      webApp.setDescriptions(descSet);
    }
    org.apache.pluto.om.ControllerFactory controllerFactory=new org.apache.pluto.portalImpl.om.ControllerFactoryImpl();
    ServletDefinitionListCtrl servletDefinitionSetCtrl=(ServletDefinitionListCtrl)controllerFactory.get(webApp.getServletDefinitionList());
    Collection servletMappings=webApp.getServletMappings();
    Iterator portlets=portletApp.getPortletDefinitionList().iterator();
    while (portlets.hasNext()) {
      PortletDefinition portlet=(PortletDefinition)portlets.next();
      ServletDefinition servlet=webApp.getServletDefinitionList().get(portlet.getName());
      if (servlet != null) {
        if (!servlet.getServletClass().equals("String_Node_Str")) {
          System.out.println("String_Node_Str" + portlet.getName() + "String_Node_Str");
        }
        ServletDefinitionCtrl _servletCtrl=(ServletDefinitionCtrl)controllerFactory.get(servlet);
        _servletCtrl.setServletClass("String_Node_Str");
      }
 else {
        servlet=servletDefinitionSetCtrl.add(portlet.getName(),"String_Node_Str");
      }
      ServletDefinitionCtrl servletCtrl=(ServletDefinitionCtrl)controllerFactory.get(servlet);
      DisplayNameImpl dispName=new DisplayNameImpl();
      dispName.setDisplayName(portlet.getName() + "String_Node_Str");
      dispName.setLocale(Locale.ENGLISH);
      DisplayNameSetImpl dispSet=new DisplayNameSetImpl();
      dispSet.add(dispName);
      servletCtrl.setDisplayNames(dispSet);
      DescriptionImpl desc=new DescriptionImpl();
      desc.setDescription("String_Node_Str");
      desc.setLocale(Locale.ENGLISH);
      DescriptionSetImpl descSet=new DescriptionSetImpl();
      descSet.add(desc);
      servletCtrl.setDescriptions(descSet);
      ParameterSet parameters=servlet.getInitParameterSet();
      ParameterSetCtrl parameterSetCtrl=(ParameterSetCtrl)controllerFactory.get(parameters);
      Parameter parameter1=parameters.get("String_Node_Str");
      if (parameter1 == null) {
        parameterSetCtrl.add("String_Node_Str",portlet.getClassName());
      }
 else {
        ParameterCtrl parameterCtrl=(ParameterCtrl)controllerFactory.get(parameter1);
        parameterCtrl.setValue(portlet.getClassName());
      }
      Parameter parameter2=parameters.get("String_Node_Str");
      if (parameter2 == null) {
        parameterSetCtrl.add("String_Node_Str",portlet.getId().toString());
      }
 else {
        ParameterCtrl parameterCtrl=(ParameterCtrl)controllerFactory.get(parameter2);
        parameterCtrl.setValue(portlet.getId().toString());
      }
      boolean found=false;
      Iterator mappings=servletMappings.iterator();
      while (mappings.hasNext()) {
        ServletMappingImpl servletMapping=(ServletMappingImpl)mappings.next();
        if (servletMapping.getServletName().equals(portlet.getName())) {
          found=true;
          servletMapping.setUrlPattern("String_Node_Str" + portlet.getName().replace(' ','_') + "String_Node_Str");
        }
      }
      if (!found) {
        ServletMappingImpl servletMapping=new ServletMappingImpl();
        servletMapping.setServletName(portlet.getName());
        servletMapping.setUrlPattern("String_Node_Str" + portlet.getName().replace(' ','_') + "String_Node_Str");
        servletMappings.add(servletMapping);
      }
      SecurityRoleRefSet servletSecurityRoleRefs=((ServletDefinitionImpl)servlet).getInitSecurityRoleRefSet();
      SecurityRoleRefSetCtrl servletSecurityRoleRefSetCtrl=(SecurityRoleRefSetCtrl)controllerFactory.get(servletSecurityRoleRefs);
      SecurityRoleSet webAppSecurityRoles=webApp.getSecurityRoles();
      SecurityRoleRefSet portletSecurityRoleRefs=portlet.getInitSecurityRoleRefSet();
      Iterator p=portletSecurityRoleRefs.iterator();
      while (p.hasNext()) {
        SecurityRoleRef portletSecurityRoleRef=(SecurityRoleRef)p.next();
        if (portletSecurityRoleRef.getRoleLink() == null && webAppSecurityRoles.get(portletSecurityRoleRef.getRoleName()) == null) {
          System.out.println("String_Node_Str" + portletSecurityRoleRef.getRoleName() + "String_Node_Str"+ portlet.getName()+ "String_Node_Str");
          break;
        }
        SecurityRoleRef servletSecurityRoleRef=servletSecurityRoleRefs.get(portletSecurityRoleRef.getRoleName());
        if (null != servletSecurityRoleRef) {
          System.out.println("String_Node_Str" + portletSecurityRoleRef.getRoleName() + "String_Node_Str"+ portlet.getName()+ "String_Node_Str");
          servletSecurityRoleRefSetCtrl.remove(servletSecurityRoleRef);
        }
        servletSecurityRoleRefSetCtrl.add(portletSecurityRoleRef);
      }
    }
    if (debug) {
      System.out.println(webApp);
    }
    OutputFormat of=new OutputFormat();
    of.setIndenting(true);
    of.setIndent(4);
    of.setLineWidth(16384);
    of.setDoctype(Constants.WEB_PORTLET_PUBLIC_ID,Constants.WEB_PORTLET_DTD);
    FileWriter writer=new FileWriter(webAppsDir + webModule + System.getProperty("String_Node_Str")+ "String_Node_Str"+ System.getProperty("String_Node_Str")+ "String_Node_Str");
    XMLSerializer serializer=new XMLSerializer(writer,of);
    try {
      Marshaller marshaller=new Marshaller(serializer.asDocumentHandler());
      marshaller.setMapping(mappingWebXml);
      marshaller.marshal(webApp);
    }
 catch (    Exception e) {
      writer.close();
      e.printStackTrace(System.out);
      throw new PlutoAdminException("String_Node_Str",e);
    }
  }
 catch (  Exception e) {
    e.printStackTrace(System.out);
    throw new PlutoAdminException("String_Node_Str",e);
  }
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
public static void prepareWebArchive(String webAppsDir,String warFile) throws Exception, IOException {
  String webModule=warFile;
  if (webModule.indexOf("String_Node_Str") != -1)   webModule=webModule.substring(webModule.lastIndexOf("String_Node_Str") + 1);
  if (webModule.indexOf(dirDelim) != -1)   webModule=webModule.substring(webModule.lastIndexOf(dirDelim) + 1);
  if (webModule.endsWith("String_Node_Str"))   webModule=webModule.substring(0,webModule.lastIndexOf("String_Node_Str"));
  System.out.println("String_Node_Str" + webModule + "String_Node_Str");
  Mapping mappingPortletXml=null;
  Mapping mappingWebXml=null;
  String _portlet_mapping=webAppsDir + portalImplWebDir + "String_Node_Str"+ dirDelim+ "String_Node_Str"+ dirDelim+ "String_Node_Str"+ dirDelim+ "String_Node_Str";
  mappingPortletXml=new Mapping();
  try {
    mappingPortletXml.loadMapping(_portlet_mapping);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str" + e);
    throw new IOException("String_Node_Str" + _portlet_mapping + "String_Node_Str"+ e.getMessage());
  }
  File portletXml=new File(webAppsDir + webModule + webInfDir+ "String_Node_Str");
  String _web_mapping=webAppsDir + portalImplWebDir + "String_Node_Str"+ dirDelim+ "String_Node_Str"+ dirDelim+ "String_Node_Str"+ dirDelim+ "String_Node_Str";
  mappingWebXml=new Mapping();
  try {
    mappingWebXml.loadMapping(_web_mapping);
  }
 catch (  Exception e) {
    throw new IOException("String_Node_Str" + _web_mapping + "String_Node_Str"+ e.getMessage());
  }
  File webXml=new File(webAppsDir + webModule + webInfDir+ "String_Node_Str");
  try {
    org.w3c.dom.Document portletDocument=XmlParser.parsePortletXml(new FileInputStream(portletXml));
    Unmarshaller unmarshaller=new Unmarshaller(mappingPortletXml);
    unmarshaller.setIgnoreExtraElements(true);
    unmarshaller.setIgnoreExtraAttributes(true);
    PortletApplicationDefinitionImpl portletApp=(PortletApplicationDefinitionImpl)unmarshaller.unmarshal(portletDocument);
    Vector structure=new Vector();
    structure.add(webModule);
    structure.add(null);
    structure.add(null);
    portletApp.preBuild(structure);
    if (debug) {
      System.out.println(portletApp);
    }
    WebApplicationDefinitionImpl webApp=null;
    if (webXml.exists()) {
      org.w3c.dom.Document webDocument=XmlParser.parseWebXml(new FileInputStream(webXml));
      Unmarshaller unmarshallerWeb=new Unmarshaller(mappingWebXml);
      unmarshallerWeb.setIgnoreExtraElements(true);
      unmarshallerWeb.setIgnoreExtraAttributes(true);
      webApp=(WebApplicationDefinitionImpl)unmarshallerWeb.unmarshal(webDocument);
    }
 else {
      webApp=new WebApplicationDefinitionImpl();
      DisplayNameImpl dispName=new DisplayNameImpl();
      dispName.setDisplayName(webModule);
      dispName.setLocale(Locale.ENGLISH);
      DisplayNameSetImpl dispSet=new DisplayNameSetImpl();
      dispSet.add(dispName);
      webApp.setDisplayNames(dispSet);
      DescriptionImpl desc=new DescriptionImpl();
      desc.setDescription("String_Node_Str");
      desc.setLocale(Locale.ENGLISH);
      DescriptionSetImpl descSet=new DescriptionSetImpl();
      descSet.add(desc);
      webApp.setDescriptions(descSet);
    }
    org.apache.pluto.om.ControllerFactory controllerFactory=new org.apache.pluto.portalImpl.om.ControllerFactoryImpl();
    ServletDefinitionListCtrl servletDefinitionSetCtrl=(ServletDefinitionListCtrl)controllerFactory.get(webApp.getServletDefinitionList());
    Collection servletMappings=webApp.getServletMappings();
    Iterator portlets=portletApp.getPortletDefinitionList().iterator();
    while (portlets.hasNext()) {
      PortletDefinition portlet=(PortletDefinition)portlets.next();
      ServletDefinition servlet=webApp.getServletDefinitionList().get(portlet.getName());
      if (servlet != null) {
        if (!servlet.getServletClass().equals("String_Node_Str")) {
          System.out.println("String_Node_Str" + portlet.getName() + "String_Node_Str");
        }
        ServletDefinitionCtrl _servletCtrl=(ServletDefinitionCtrl)controllerFactory.get(servlet);
        _servletCtrl.setServletClass("String_Node_Str");
      }
 else {
        servlet=servletDefinitionSetCtrl.add(portlet.getName(),"String_Node_Str");
      }
      ServletDefinitionCtrl servletCtrl=(ServletDefinitionCtrl)controllerFactory.get(servlet);
      DisplayNameImpl dispName=new DisplayNameImpl();
      dispName.setDisplayName(portlet.getName() + "String_Node_Str");
      dispName.setLocale(Locale.ENGLISH);
      DisplayNameSetImpl dispSet=new DisplayNameSetImpl();
      dispSet.add(dispName);
      servletCtrl.setDisplayNames(dispSet);
      DescriptionImpl desc=new DescriptionImpl();
      desc.setDescription("String_Node_Str");
      desc.setLocale(Locale.ENGLISH);
      DescriptionSetImpl descSet=new DescriptionSetImpl();
      descSet.add(desc);
      servletCtrl.setDescriptions(descSet);
      ParameterSet parameters=servlet.getInitParameterSet();
      ParameterSetCtrl parameterSetCtrl=(ParameterSetCtrl)controllerFactory.get(parameters);
      Parameter parameter1=parameters.get("String_Node_Str");
      if (parameter1 == null) {
        parameterSetCtrl.add("String_Node_Str",portlet.getClassName());
      }
 else {
        ParameterCtrl parameterCtrl=(ParameterCtrl)controllerFactory.get(parameter1);
        parameterCtrl.setValue(portlet.getClassName());
      }
      Parameter parameter2=parameters.get("String_Node_Str");
      if (parameter2 == null) {
        parameterSetCtrl.add("String_Node_Str",portlet.getId().toString());
      }
 else {
        ParameterCtrl parameterCtrl=(ParameterCtrl)controllerFactory.get(parameter2);
        parameterCtrl.setValue(portlet.getId().toString());
      }
      boolean found=false;
      Iterator mappings=servletMappings.iterator();
      while (mappings.hasNext()) {
        ServletMappingImpl servletMapping=(ServletMappingImpl)mappings.next();
        if (servletMapping.getServletName().equals(portlet.getName())) {
          found=true;
          servletMapping.setUrlPattern("String_Node_Str" + portlet.getName().replace(' ','_') + "String_Node_Str");
        }
      }
      if (!found) {
        ServletMappingImpl servletMapping=new ServletMappingImpl();
        servletMapping.setServletName(portlet.getName());
        servletMapping.setUrlPattern("String_Node_Str" + portlet.getName().replace(' ','_') + "String_Node_Str");
        servletMappings.add(servletMapping);
      }
      SecurityRoleRefSet servletSecurityRoleRefs=((ServletDefinitionImpl)servlet).getInitSecurityRoleRefSet();
      SecurityRoleRefSetCtrl servletSecurityRoleRefSetCtrl=(SecurityRoleRefSetCtrl)controllerFactory.get(servletSecurityRoleRefs);
      SecurityRoleSet webAppSecurityRoles=webApp.getSecurityRoles();
      SecurityRoleRefSet portletSecurityRoleRefs=portlet.getInitSecurityRoleRefSet();
      Iterator p=portletSecurityRoleRefs.iterator();
      while (p.hasNext()) {
        SecurityRoleRef portletSecurityRoleRef=(SecurityRoleRef)p.next();
        if (portletSecurityRoleRef.getRoleLink() == null && webAppSecurityRoles.get(portletSecurityRoleRef.getRoleName()) == null) {
          System.out.println("String_Node_Str" + portletSecurityRoleRef.getRoleName() + "String_Node_Str"+ portlet.getName()+ "String_Node_Str");
          break;
        }
        SecurityRoleRef servletSecurityRoleRef=servletSecurityRoleRefs.get(portletSecurityRoleRef.getRoleName());
        if (null != servletSecurityRoleRef) {
          System.out.println("String_Node_Str" + portletSecurityRoleRef.getRoleName() + "String_Node_Str"+ portlet.getName()+ "String_Node_Str");
          servletSecurityRoleRefSetCtrl.remove(servletSecurityRoleRef);
        }
        servletSecurityRoleRefSetCtrl.add(portletSecurityRoleRef);
      }
    }
    if (debug) {
      System.out.println(webApp);
    }
    OutputFormat of=new OutputFormat();
    of.setIndenting(true);
    of.setIndent(4);
    of.setLineWidth(16384);
    of.setDoctype(Constants.WEB_PORTLET_PUBLIC_ID,Constants.WEB_PORTLET_DTD);
    FileWriter writer=new FileWriter(webAppsDir + webModule + System.getProperty("String_Node_Str")+ "String_Node_Str"+ System.getProperty("String_Node_Str")+ "String_Node_Str");
    XMLSerializer serializer=new XMLSerializer(writer,of);
    try {
      Marshaller marshaller=new Marshaller(serializer.asDocumentHandler());
      marshaller.setMapping(mappingWebXml);
      marshaller.marshal(webApp);
    }
 catch (    Exception e) {
      writer.close();
      e.printStackTrace(System.out);
      throw new PlutoAdminException("String_Node_Str",e);
    }
  }
 catch (  Exception e) {
    e.printStackTrace(System.out);
    throw new PlutoAdminException("String_Node_Str",e);
  }
  System.out.println("String_Node_Str");
}