List of usage examples for java.lang StringBuffer setLength
@Override public synchronized void setLength(int newLength)
From source file:com.panet.imeta.cluster.SlaveServer.java
public String sendXML(String xml, String service) throws Exception { // The content // /* w w w . j a v a 2 s . c om*/ byte[] content = xml.getBytes(Const.XML_ENCODING); // Prepare HTTP put // String urlString = constructUrl(service); log.logDebug(toString(), Messages.getString("SlaveServer.DEBUG_ConnectingTo", urlString)); //$NON-NLS-1$ PutMethod put = new PutMethod(urlString); // Request content will be retrieved directly from the input stream // RequestEntity entity = new ByteArrayRequestEntity(content); put.setRequestEntity(entity); put.setDoAuthentication(true); put.addRequestHeader(new Header("Content-Type", "text/xml;charset=" + Const.XML_ENCODING)); // post.setContentChunked(true); // Get HTTP client // HttpClient client = new HttpClient(); addCredentials(client); // Execute request // try { int result = client.executeMethod(put); // The status code log.logDebug(toString(), Messages.getString("SlaveServer.DEBUG_ResponseStatus", Integer.toString(result))); //$NON-NLS-1$ // the response InputStream inputStream = new BufferedInputStream(put.getResponseBodyAsStream(), 1000); StringBuffer bodyBuffer = new StringBuffer(); int c; while ((c = inputStream.read()) != -1) bodyBuffer.append((char) c); inputStream.close(); String bodyTmp = bodyBuffer.toString(); switch (result) { case 401: // Security problem: authentication required // Non-internationalized message String message = "Authentication failed" + Const.DOSCR + Const.DOSCR + bodyTmp; //$NON-NLS-1$ WebResult webResult = new WebResult(WebResult.STRING_ERROR, message); bodyBuffer.setLength(0); bodyBuffer.append(webResult.getXML()); break; } String body = bodyBuffer.toString(); // String body = post.getResponseBodyAsString(); log.logDebug(toString(), Messages.getString("SlaveServer.DEBUG_ResponseBody", body)); //$NON-NLS-1$ return body; } finally { // Release current connection to the connection pool once you are done put.releaseConnection(); log.logDetailed(toString(), Messages.getString("SlaveServer.DETAILED_SentXmlToService", service, hostname)); //$NON-NLS-1$ } }
From source file:com.tremolosecurity.scale.register.RegisterController.java
private void executeWorkflow(WFCall wfcall) throws Exception { // touch to ensure the session is alive StringBuffer callURL = new StringBuffer(); callURL.append(this.registerConfig.getServiceConfiguration().getUnisonURL() + "/services/wf/login"); HttpGet httpget = new HttpGet(callURL.toString()); HttpResponse response = scaleSession.getHttp().execute(httpget); BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); String line = null;// w ww .ja v a2 s .c om StringBuffer json = new StringBuffer(); while ((line = in.readLine()) != null) { json.append(line); } httpget.abort(); Gson gson = new Gson(); ProvisioningResult pres = gson.fromJson(json.toString(), ProvisioningResult.class); if (!pres.isSuccess()) { errors.add("We could not submit your request at this time, please try again later"); System.err.println(pres.getError().getError()); return; } // Execute workflow callURL.setLength(0); callURL.append(this.registerConfig.getServiceConfiguration().getUnisonURL() + "/services/wf/execute"); if (logger.isDebugEnabled()) logger.debug("URL for wf : '" + callURL.toString() + "'"); String sjson = gson.toJson(wfcall); HttpPost post = new HttpPost(callURL.toString()); List<NameValuePair> urlParameters = new ArrayList<NameValuePair>(); urlParameters.add(new BasicNameValuePair("wfcall", sjson)); post.setEntity(new UrlEncodedFormEntity(urlParameters)); response = scaleSession.getHttp().execute(post); in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); line = null; json.setLength(0); while ((line = in.readLine()) != null) { json.append(line); } pres = gson.fromJson(json.toString(), ProvisioningResult.class); if (!pres.isSuccess()) { errors.add("We could not submit your request at this time, please try again later"); System.err.println(pres.getError().getError()); return; } }
From source file:org.mitre.dsmiley.httpproxy.ProxyServlet.java
/** * For a redirect response from the target server, this translates * {@code theUrl} to redirect to and translates it to one the original * client can use./*from w w w .j a v a 2s . com*/ */ protected String rewriteUrlFromResponse(HttpServletRequest servletRequest, String theUrl) { // TODO document example paths final String targetUri = getTargetUri(servletRequest); if (theUrl.startsWith(targetUri)) { /*- * The URL points back to the back-end server. * Instead of returning it verbatim we replace the target path with our * source path in a way that should instruct the original client to * request the URL pointed through this Proxy. * We do this by taking the current request and rewriting the path part * using this servlet's absolute path and the path from the returned URL * after the base target URL. */ StringBuffer curUrl = servletRequest.getRequestURL();// no query int pos; // Skip the protocol part if ((pos = curUrl.indexOf("://")) >= 0) { // Skip the authority part // + 3 to skip the separator between protocol and authority if ((pos = curUrl.indexOf("/", pos + 3)) >= 0) { // Trim everything after the authority part. curUrl.setLength(pos); } } // Context path starts with a / if it is not blank curUrl.append(servletRequest.getContextPath()); // Servlet path starts with a / if it is not blank curUrl.append(servletRequest.getServletPath()); curUrl.append(theUrl, targetUri.length(), theUrl.length()); theUrl = curUrl.toString(); } return theUrl; }
From source file:edu.cornell.mannlib.vitro.webapp.search.solr.IndividualToSolrDocument.java
private void addAllText(Individual ind, SolrInputDocument doc, StringBuffer classPublicNames, StringBuffer objectNames) { String t = null;/* w w w .j a va2 s . c o m*/ //ALLTEXT, all of the 'full text' StringBuffer allTextValue = new StringBuffer(); //collecting data property statements List<DataPropertyStatement> dataPropertyStatements = ind.getDataPropertyStatements(); if (dataPropertyStatements != null) { Iterator<DataPropertyStatement> dataPropertyStmtIter = dataPropertyStatements.iterator(); while (dataPropertyStmtIter.hasNext()) { DataPropertyStatement dataPropertyStmt = dataPropertyStmtIter.next(); if (dataPropertyStmt.getDatapropURI().equals(label)) { // we don't want label to be added to alltext continue; } allTextValue.append(" "); allTextValue.append(((t = dataPropertyStmt.getData()) == null) ? "" : t); } } allTextValue.append(objectNames.toString()); allTextValue.append(' '); allTextValue.append(classPublicNames); try { String stripped = Jsoup.parse(allTextValue.toString()).text(); allTextValue.setLength(0); allTextValue.append(stripped); } catch (Exception e) { log.debug("Could not strip HTML during search indexing. " + e); } String alltext = allTextValue.toString(); doc.addField(term.ALLTEXT, alltext); doc.addField(term.ALLTEXTUNSTEMMED, alltext); doc.addField(term.ALLTEXT_PHONETIC, alltext); }
From source file:com.osafe.events.CheckOutEvents.java
public static String splitShipGroupByShipOptions(HttpServletRequest request, HttpServletResponse response) { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); Delegator delegator = (Delegator) request.getAttribute("delegator"); Locale locale = UtilHttp.getLocale(request); ShoppingCart cart = ShoppingCartEvents.getCartObject(request); try {// ww w .j a v a2s.c o m List<CartShipInfo> lCartShipGroups = cart.getShipGroups(); for (int i = 0; i < lCartShipGroups.size(); i++) { CartShipInfo shipGroupShipInfo = cart.getShipInfo(i); Set shipItems = shipGroupShipInfo.getShipItems(); if (UtilValidate.isNotEmpty(shipItems) && shipItems.size() > 1) { StringBuffer sbProductStoreShipMethIdKey = new StringBuffer(); Map<String, String> mShipGroupTempIndexShipMethods = FastMap.newInstance(); Map<String, String> mShipMethodKeys = FastMap.newInstance(); Iterator shipItemsIterator = shipItems.iterator(); int iShipItemIdx = 0; while (shipItemsIterator.hasNext()) { ShoppingCartItem cartItem = (ShoppingCartItem) shipItemsIterator.next(); BigDecimal cartItemQty = cart.getItemShipGroupQty(cartItem, i); /* Create a temp ShipGroup to send to the Shipping Estimate Wrapper * with just the single item in the group */ int iTempShipGroupIndex = cart.addShipInfo(); CartShipInfo tempCartShipInfo = cart.getShipInfo(iTempShipGroupIndex); tempCartShipInfo.setContactMechId(shipGroupShipInfo.getContactMechId()); cart.positionItemToGroup(cartItem, cartItemQty, i, iTempShipGroupIndex, false); sbProductStoreShipMethIdKey.setLength(0); ShippingEstimateWrapper shippingEstWrapper = new ShippingEstimateWrapper(dispatcher, cart, iTempShipGroupIndex); List<GenericValue> lCarrierShipmentMethods = shippingEstWrapper.getShippingMethods(); for (GenericValue carrierShipmentMethod : lCarrierShipmentMethods) { sbProductStoreShipMethIdKey .append(carrierShipmentMethod.getString("productStoreShipMethId")); } String sProductStoreShipMethIdKey = sbProductStoreShipMethIdKey.toString(); if (iShipItemIdx == 0) { cart.positionItemToGroup(cartItem, cartItemQty, iTempShipGroupIndex, i, false); mShipGroupTempIndexShipMethods.put(sProductStoreShipMethIdKey, "" + i); } else { if (mShipGroupTempIndexShipMethods.containsKey(sProductStoreShipMethIdKey)) { String sTempShipGroupIndex = mShipGroupTempIndexShipMethods .get(sProductStoreShipMethIdKey); cart.positionItemToGroup(cartItem, cartItemQty, iTempShipGroupIndex, Integer.valueOf(sTempShipGroupIndex).intValue(), false); } else { mShipGroupTempIndexShipMethods.put(sProductStoreShipMethIdKey, "" + iTempShipGroupIndex); } } iShipItemIdx++; } /* Clean Up any empty Ship Groups */ cart.cleanUpShipGroups(); } } lCartShipGroups = cart.getShipGroups(); if (UtilValidate.isNotEmpty(lCartShipGroups) && (lCartShipGroups.size() > 1)) { return "multiShipGroups"; } } catch (Exception e) { Debug.logError(e, "Error: splitShipGroupbyShipOptions", module); } return "success"; }
From source file:org.eredlab.g4.ccl.net.nntp.NewGroupsOrNewsQuery.java
/*** * Creates a new query using the given time as a reference point. * <p>/*from ww w .j a va 2 s.co m*/ * @param date The date since which new groups or news have arrived. * @param gmt True if the date should be considered as GMT, false if not. ***/ public NewGroupsOrNewsQuery(Calendar date, boolean gmt) { int num; String str; StringBuffer buffer; __distributions = null; __newsgroups = null; __isGMT = gmt; buffer = new StringBuffer(); // Get year num = date.get(Calendar.YEAR); str = Integer.toString(num); num = str.length(); if (num >= 2) buffer.append(str.substring(num - 2)); else buffer.append("00"); // Get month num = date.get(Calendar.MONTH) + 1; str = Integer.toString(num); num = str.length(); if (num == 1) { buffer.append('0'); buffer.append(str); } else if (num == 2) buffer.append(str); else buffer.append("01"); // Get day num = date.get(Calendar.DAY_OF_MONTH); str = Integer.toString(num); num = str.length(); if (num == 1) { buffer.append('0'); buffer.append(str); } else if (num == 2) buffer.append(str); else buffer.append("01"); __date = buffer.toString(); buffer.setLength(0); // Get hour num = date.get(Calendar.HOUR_OF_DAY); str = Integer.toString(num); num = str.length(); if (num == 1) { buffer.append('0'); buffer.append(str); } else if (num == 2) buffer.append(str); else buffer.append("00"); // Get minutes num = date.get(Calendar.MINUTE); str = Integer.toString(num); num = str.length(); if (num == 1) { buffer.append('0'); buffer.append(str); } else if (num == 2) buffer.append(str); else buffer.append("00"); // Get seconds num = date.get(Calendar.SECOND); str = Integer.toString(num); num = str.length(); if (num == 1) { buffer.append('0'); buffer.append(str); } else if (num == 2) buffer.append(str); else buffer.append("00"); __time = buffer.toString(); }
From source file:com.hangum.tadpole.engine.sql.util.export.SQLExporter.java
public static String makeFileBatchInsertStatment(String tableName, QueryExecuteResultDTO rsDAO, int intLimitCount, int commit) throws Exception { String strTmpDir = PublicTadpoleDefine.TEMP_DIR + tableName + System.currentTimeMillis() + PublicTadpoleDefine.DIR_SEPARATOR; String strFile = tableName + ".sql"; String strFullPath = strTmpDir + strFile; boolean isFirst = true; final String INSERT_INTO_STMT = "INSERT INTO " + tableName + " (%s) VALUES (%S)"; final String NEXT_INSERT_INTO_STMT = ", (%S)"; // ?./* w w w. j a v a 2s . c o m*/ String strColumns = ""; Map<Integer, String> mapTable = rsDAO.getColumnLabelName(); for (int i = 1; i < mapTable.size(); i++) { if (i != (mapTable.size() - 1)) strColumns += mapTable.get(i) + ","; else strColumns += mapTable.get(i); } // ?? . StringBuffer sbInsertInto = new StringBuffer(); int DATA_COUNT = 1000; List<Map<Integer, Object>> dataList = rsDAO.getDataList().getData(); Map<Integer, Integer> mapColumnType = rsDAO.getColumnType(); String strResult = new String(); for (int i = 0; i < dataList.size(); i++) { Map<Integer, Object> mapColumns = dataList.get(i); strResult = ""; for (int j = 1; j < mapColumnType.size(); j++) { Object strValue = mapColumns.get(j); strValue = strValue == null ? "" : strValue; if (!RDBTypeToJavaTypeUtils.isNumberType(mapColumnType.get(j))) { strValue = StringEscapeUtils.escapeSql(strValue.toString()); strValue = StringHelper.escapeSQL(strValue.toString()); strValue = SQLUtil.makeQuote(strValue.toString()); } if (j != (mapTable.size() - 1)) strResult += strValue + ","; else strResult += strValue; } if (isFirst) { isFirst = false; sbInsertInto.append(String.format(INSERT_INTO_STMT, strColumns, strResult)); } else { sbInsertInto.append(String.format(NEXT_INSERT_INTO_STMT, strResult)); } if (dataList.size() > 1 && i > 1 && (i % DATA_COUNT) == 0) { isFirst = true; sbInsertInto.append(PublicTadpoleDefine.SQL_DELIMITER); sbInsertInto.append(PublicTadpoleDefine.LINE_SEPARATOR); if (commit > 0) { sbInsertInto.append( "COMMIT" + PublicTadpoleDefine.SQL_DELIMITER + PublicTadpoleDefine.LINE_SEPARATOR); } FileUtils.writeStringToFile(new File(strFullPath), sbInsertInto.toString(), true); sbInsertInto.setLength(0); } if (intLimitCount == i) { return sbInsertInto.toString(); } } if (sbInsertInto.length() > 0) { sbInsertInto.append(PublicTadpoleDefine.SQL_DELIMITER); sbInsertInto.append(PublicTadpoleDefine.LINE_SEPARATOR); if (commit > 0) { sbInsertInto .append("COMMIT" + PublicTadpoleDefine.SQL_DELIMITER + PublicTadpoleDefine.LINE_SEPARATOR); } FileUtils.writeStringToFile(new File(strFullPath), sbInsertInto.toString(), true); } return strFullPath; }
From source file:com.pureinfo.srm.product.action.Product3indexListAction.java
public String getTailedButtons() throws PureException { if (isAddAuthor()) { StringBuffer sbuff = new StringBuffer(); try {// ww w.j av a2s.c o m sbuff.append("<BUTTON type=\"button\" class=\"img_button\" onclick=\""); sbuff.append(" mainForm.action='../product/productChooseScenery.do?type="); sbuff.append(ProductConstants.PRODUCT_FORM_3INDEX).append("&dp_3indexId="); sbuff.append(request.getParameter("Nproduct0Id")); sbuff.append(" ';mainForm.submit();this.disabled=true;\">"); sbuff.append("</button> "); sbuff.append("<BUTTON type=\"button\" class=\"img_button\" onclick=\"history.go(-1)\">"); sbuff.append("<IMG src=\"../images/return.gif\" border=0 align=\"absMiddle\"> </BUTTON>"); return sbuff.toString(); } finally { sbuff.setLength(0); } } IAuth2Mgr authMgr = Auth2Helper.getManager(); Product product = (Product) this.getSearchBean(); int nActionIndex = authMgr.indexOfAction("batchEdit", true); boolean bCanBatchEdit = authMgr.hasRight(loginUser, product, nActionIndex, false); StringBuffer sbuff = new StringBuffer(); boolean bFromTemp = !request.getBoolean("audit"); try { if (bCanBatchEdit && !request.getBoolean("audit")) { sbuff.append("<BUTTON class=\"img_button\" onClick=\"if(count()<1)alert('');"); sbuff.append("else{"); sbuff.append("mainForm.action='../product/product-3index-batch-edit.jsp?bFromTemp=" + bFromTemp); sbuff.append("';mainForm.target='_blank';this.disabled='true';mainForm.submit();}\">"); sbuff.append("<img src=\"../images/edit.gif\"></button> "); } nActionIndex = authMgr.indexOfAction("delete", true); bCanBatchEdit = authMgr.hasRight(loginUser, product, nActionIndex, false); if (bCanBatchEdit && !request.getBoolean("audit")) { sbuff.append("<BUTTON type=\"button\" class=\"img_button\""); sbuff.append("onclick=\"if(count()==0){alert('');}else{"); sbuff.append( "if(confirm('')){ mainForm.action='productAction.do?action=del3index&product0Ids='+getProduct0IdsForNotAudit3index();"); sbuff.append("mainForm.submit();this.disabled=true;}}\">"); sbuff.append("<IMG src=\"../images/delete.gif\" border=0 align=\"absMiddle\"> </button>"); } // SRMUser currUser = (SRMUser) loginUser; String sEmailButton = null; if (!request.getBoolean("audit") && (currUser.isProductAdmin() || currUser.isAdmin1())) { sEmailButton = SRMWebHelper.getEmailButton("", "", "EmailRemindProduct.do"); } if (sEmailButton != null) { sbuff.append(" ").append(sEmailButton); } if (isFromTemp()) { if (SRMAuthHelper.getLevel((SRMUser) loginUser) > SRMUserConstants.LEVEL_ADMIN2) { sbuff.append("<BUTTON type=\"button\" class=\"img_button\""); sbuff.append(" onclick=\"if(count()==0){alert('');}else{"); sbuff.append( "if(confirm('')){ mainForm.action='product3IndexDuplicateSaveAction.do?action=Product3indexList&audit=false&oper=save';"); sbuff.append(";mainForm.target='_blank';mainForm.submit();this.disabled=true;}}\">"); sbuff.append( "<IMG src=\"../images/newgroup.gif\" border=0 align=\"absMiddle\"> </button> "); sbuff.append("<BUTTON type=\"button\" class=\"img_button\""); sbuff.append(" onclick=\"if(count()==0){alert('');}else{"); sbuff.append( "if(confirm('')){ mainForm.action='product3IndexDuplicateSaveAction.do?action=Product3indexList&audit=false&oper=regret';"); sbuff.append(";mainForm.target='_blank';mainForm.submit();this.disabled=true;}}\">"); sbuff.append( "<IMG src=\"../images/break-group.gif\" border=0 align=\"absMiddle\"> </button>"); } } else { if (SRMAuthHelper.getLevel((SRMUser) loginUser) > SRMUserConstants.LEVEL_ADMIN2) { sbuff.append("<BUTTON class=\"img_button\" onClick=\"if(count()<1)alert('');"); sbuff.append("else{"); sbuff.append( "mainForm.action='../product/product-3index-batch-edit.jsp?bFromTemp=" + bFromTemp); sbuff.append("';mainForm.target='_blank';this.disabled='true';mainForm.submit();}\">"); sbuff.append("<img src=\"../images/edit.gif\"></button> "); sbuff.append("<BUTTON type=\"button\" class=\"img_button\""); sbuff.append("onclick=\"if(count()==0){alert('');}else{"); sbuff.append( "if(confirm('')){ mainForm.action='product3IndexDuplicateSaveAction.do?action=Product3indexList&audit=true&oper=regret';"); sbuff.append(";mainForm.target='_blank';mainForm.submit();this.disabled=true;}}\">"); sbuff.append( "<IMG src=\"../images/newgroup.gif\" border=0 align=\"absMiddle\"> </button>"); sbuff.append(" "); sbuff.append("<BUTTON type=\"button\" class=\"img_button\""); sbuff.append("onclick=\"if(count()==0){alert('');}else{"); sbuff.append( "if(confirm('')){ mainForm.action='product3IndexDuplicateSaveAction.do?action=Product3indexList&audit=false&oper=regret';"); sbuff.append(" ;mainForm.target='_blank'; mainForm.submit();this.disabled=true;}}\">"); sbuff.append( "<IMG src=\"../images/break-group.gif\" border=0 align=\"absMiddle\"> </button>"); } } return sbuff.toString(); } finally { sbuff.setLength(0); } }
From source file:net.fenyo.gnetwatch.activities.Capture.java
/** * Reads tethereal standard output and extracts frames one by one. * @param none./*from www. j ava 2 s . c om*/ * @return void. */ // Capture thread public void run() { final StringBuffer packet = new StringBuffer(); try { cmd.fork(); forked = true; while (!config.isEnd() && !must_end) { // on doit pouvoir optimiser en utilisant un StringBuffer pour str final String str = cmd.readLineStdout(); if (str == null) break; packet.append(str); // log.debug("[" + str + "]"); // replaces invalid XML characters with ' ' for (int idx = 0; idx < packet.length(); idx++) // http://www.w3.org/TR/REC-xml/#charsets if (packet.charAt(idx) != 9 && packet.charAt(idx) != 10 && packet.charAt(idx) != 13 && packet.charAt(idx) < 32) packet.setCharAt(idx, ' '); if (str.contains("</packet>")) { try { handlePacket(packet); } catch (final DocumentException ex) { log.warn("Exception", ex); } packet.setLength(0); } } } catch (final IOException ex) { log.warn("Exception", ex); } catch (final InterruptedException ex) { // terminate the thread } finally { forked = true; } }
From source file:org.jbpm.bpel.tools.WsdlServiceTool.java
public void generateWsdlService(BpelProcessDefinition process) { // generate the binding and service documents ServiceDefinitionBuilder serviceDefinitionBuilder = new ServiceDefinitionBuilder(); serviceDefinitionBuilder.visit(process); // write required interface files WSDLWriter wsdlWriter = WsdlUtil.getFactory().newWSDLWriter(); Map interfaceFiles = serviceDefinitionBuilder.getInterfaceFiles(); for (Iterator i = interfaceFiles.entrySet().iterator(); i.hasNext();) { Map.Entry interfaceEntry = (Map.Entry) i.next(); File interfaceFile = (File) interfaceEntry.getKey(); Definition interfaceDefinition = (Definition) interfaceEntry.getValue(); // write interface file try {//from w w w . j av a 2s.c o m WsdlUtil.writeFile(interfaceFile, interfaceDefinition, wsdlWriter); log.debug("wrote interface definition: " + interfaceFile.getName()); } catch (WSDLException e) { problemHandler.add(new Problem(Problem.LEVEL_ERROR, "could not write interface definition: " + interfaceFile, e)); } } // write binding files StringBuffer bindingFileNameBuffer = new StringBuffer(bindingFilesPrefix); int bindingCount = 0; Definition serviceDefinition = serviceDefinitionBuilder.getServiceDefinition(); for (Iterator i = serviceDefinition.getImports().values().iterator(); i.hasNext();) { List bindingImports = (List) i.next(); assert bindingImports.size() == 1 : bindingImports.size(); // format binding filename bindingFileNameBuffer.setLength(bindingFilesPrefix.length()); String bindingFileName = bindingFileNameBuffer.append(++bindingCount).append(bindingFilesSuffix) .toString(); // fill import location Import bindingImport = (Import) bindingImports.get(0); bindingImport.setLocationURI(bindingFileName); // write binding file File bindingFile = new File(wsdlDirectory, bindingFileName); try { WsdlUtil.writeFile(bindingFile, bindingImport.getDefinition(), wsdlWriter); log.debug("wrote binding definition: " + bindingFile.getName()); } catch (WSDLException e) { problemHandler.add( new Problem(Problem.LEVEL_ERROR, "could not write binding definition: " + bindingFile, e)); } } // write service file File serviceFile = new File(wsdlDirectory, serviceFileName); try { WsdlUtil.writeFile(serviceFile, serviceDefinition, wsdlWriter); log.debug("wrote service definition: " + serviceFile.getName()); } catch (WSDLException e) { problemHandler .add(new Problem(Problem.LEVEL_ERROR, "could not write service definition: " + serviceFile, e)); } // write deployment descriptor, if requested if (deploymentDescriptorFile != null) { DeploymentDescriptor deploymentDescriptor = serviceDefinitionBuilder.getDeploymentDescriptor(); // transform descriptor to xml format Element descriptorElem = XmlUtil.createElement(BpelConstants.NS_DEPLOYMENT_DESCRIPTOR, BpelConstants.ELEM_BPEL_DEPLOYMENT); DeploymentDescriptorWriter.getInstance().write(deploymentDescriptor, descriptorElem); // write descriptor file try { XmlUtil.writeFile(descriptorElem, deploymentDescriptorFile); log.debug("wrote deployment descriptor: " + deploymentDescriptorFile.getName()); } catch (IOException e) { problemHandler.add(new Problem(Problem.LEVEL_ERROR, "could not write deployment descriptor: " + deploymentDescriptorFile, e)); } } }