private String _buildPramatiXMLWebModule(String path) throws DocumentException, IOException { String contextRoot = path.substring(2, path.length() - 4); String filePath = path + "/docroot/WEB-INF/web.xml"; if (path.endsWith("-complete")) { contextRoot = "/"; filePath = path.substring(0, path.length() - 9) + "/docroot/WEB-INF/web.xml"; } FastStringBuffer sb = new FastStringBuffer(); sb.append("\t<web-module>\n"); sb.append("\t\t<name>").append(contextRoot).append("</name>\n"); sb.append("\t\t<module-name>") .append(path.substring(3, path.length())) .append(".war</module-name>\n"); SAXReader reader = new SAXReader(); reader.setEntityResolver(new EntityResolver()); Document doc = reader.read(new File(filePath)); Iterator itr = doc.getRootElement().elements("ejb-local-ref").iterator(); while (itr.hasNext()) { Element ejbLocalRef = (Element) itr.next(); sb.append("\t\t<ejb-local-ref>\n"); sb.append("\t\t\t<ejb-ref-name>") .append(ejbLocalRef.elementText("ejb-ref-name")) .append("</ejb-ref-name>\n"); sb.append("\t\t\t<ejb-link>") .append(ejbLocalRef.elementText("ejb-link")) .append("</ejb-link>\n"); sb.append("\t\t</ejb-local-ref>\n"); } itr = doc.getRootElement().elements("resource-ref").iterator(); while (itr.hasNext()) { Element resourceRef = (Element) itr.next(); sb.append("\t\t<resource-mapping>\n"); sb.append("\t\t\t<resource-name>") .append(resourceRef.elementText("res-ref-name")) .append("</resource-name>\n"); sb.append("\t\t\t<resource-type>") .append(resourceRef.elementText("res-type")) .append("</resource-type>\n"); sb.append("\t\t\t<resource-link>") .append(resourceRef.elementText("res-ref-name")) .append("</resource-link>\n"); sb.append("\t\t</resource-mapping>\n"); } sb.append("\t</web-module>\n"); return sb.toString(); }
private String _buildPramatiXMLEJBJar(String path) throws IOException { File file = new File(path + "/classes/pramati-or-map.xml"); if (file.exists()) { String content = FileUtil.read(file); int x = content.indexOf("<ejb-jar>"); int y = content.indexOf("</ejb-jar>"); if (x != -1 && y != -1) { return content.substring(x - 1, y + 11); } } FastStringBuffer sb = new FastStringBuffer(); sb.append("\t<ejb-jar>\n"); sb.append("\t\t<jar-name>") .append(path.substring(3, path.length())) .append(".jar</jar-name>\n"); sb.append("\t</ejb-jar>\n"); return sb.toString(); }
public static String getResourceProxyURL(Map params) { FastStringBuffer url = new FastStringBuffer(); url.append("/wsrp/resource_proxy/get"); if (params != null) { String paramValue = GetterUtil.getString((String) params.get(Constants.URL)); url.append(Constants.PARAMS_START); url.append("url"); url.append(Constants.EQUALS); try { paramValue = Base64.encode(ObjectSerializer.serialize(paramValue)); url.append(paramValue); } catch (Exception e) { e.printStackTrace(); } } String cookie = SimpleHTTPSender.getCurrentCookie(); try { cookie = Base64.encode(ObjectSerializer.serialize(cookie)); } catch (Exception e) { e.printStackTrace(); } url.append(Constants.NEXT_PARAM); url.append("cookie"); url.append(Constants.EQUALS); url.append(cookie); return url.toString(); }
public Object convert(String id) throws ConverterException { Whois whois = null; try { Socket socket = new Socket(WHOIS_SERVER, WHOIS_SERVER_PORT); BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream())); PrintStream out = new PrintStream(socket.getOutputStream()); out.println(_domain); FastStringBuffer sb = new FastStringBuffer(); String line = null; while ((line = br.readLine()) != null) { if (line.startsWith("Results ")) { break; } sb.append(line).append("\n"); } br.close(); socket.close(); whois = new Whois(_domain, StringUtil.replace(sb.toString().trim(), "\n\n", "\n")); } catch (Exception e) { throw new ConverterException(_domain + " " + e.toString()); } return whois; }
public static String encode(byte raw[]) { FastStringBuffer encoded = new FastStringBuffer(); for (int i = 0; i < raw.length; i += 3) { encoded.append(encodeBlock(raw, i)); } return encoded.toString(); }
private void _buildPramatiXML() throws Exception { // pramati-j2ee-server.xml FastStringBuffer sb = new FastStringBuffer(); sb.append("<?xml version=\"1.0\"?>\n"); sb.append( "<!DOCTYPE pramati-j2ee-server PUBLIC \"-//Pramati Technologies //DTD Pramati J2ee Server 3.5 SP5//EN\" \"http://www.pramati.com/dtd/pramati-j2ee-server_3_5.dtd\">\n"); sb.append("\n<pramati-j2ee-server>\n"); sb.append("\t<vhost-name>default</vhost-name>\n"); sb.append("\t<auto-start>TRUE</auto-start>\n"); sb.append("\t<realm-name>PortalRealm</realm-name>\n"); for (int i = 0; i < EJB_PATHS.length; i++) { sb.append(_buildPramatiXMLEJBModule(EJB_PATHS[i])); } for (int i = 0; i < WEB_PATHS.length; i++) { sb.append(_buildPramatiXMLWebModule(WEB_PATHS[i])); } for (int i = 0; i < EJB_PATHS.length; i++) { sb.append(_buildPramatiXMLRoleMapping(EJB_PATHS[i], "jar")); } for (int i = 0; i < WEB_PATHS.length; i++) { sb.append(_buildPramatiXMLRoleMapping(WEB_PATHS[i], "war")); } sb.append("</pramati-j2ee-server>"); File outputFile = new File("../portal-ear/modules/pramati-j2ee-server.xml"); if (!outputFile.exists() || !FileUtil.read(outputFile).equals(sb.toString())) { FileUtil.write(outputFile, sb.toString()); System.out.println(outputFile.toString()); } }
public static String toString(Properties p) { FastStringBuffer sb = new FastStringBuffer(); Enumeration enu = p.propertyNames(); while (enu.hasMoreElements()) { String key = (String) enu.nextElement(); sb.append(key); sb.append(StringPool.EQUAL); sb.append(p.getProperty(key)); sb.append("\n"); } return sb.toString(); }
private String _buildPramatiXMLRoleMapping(String path, String extension) throws IOException { FastStringBuffer sb = new FastStringBuffer(); sb.append("\t<role-mapping>\n"); sb.append("\t\t<module-name>") .append(path.substring(3, path.length())) .append(".") .append(extension) .append("</module-name>\n"); sb.append("\t\t<role-name>users</role-name>\n"); sb.append("\t\t<role-link>everybody</role-link>\n"); sb.append("\t</role-mapping>\n"); return sb.toString(); }
public void addEntry(String name, FastStringBuffer sb) throws IOException { addEntry(name, sb.toString()); }