Search in sources :

Example 26 with StringBufferInputStream

use of java.io.StringBufferInputStream in project webtools.sourceediting by eclipse.

the class TestFragFile method testFragX.

public void testFragX() throws UnsupportedEncodingException, IOException {
    IStructuredModel model = null;
    IModelManager modelManager = StructuredModelManager.getModelManager();
    String testString = "<!--This is an internally generated file - manual changes to it will be ignored and overwritten.-->\r\n" + "<Fragment parent=\"/ejb-jar/enterprise-beans&lt;description,display-name,small-icon,large-icon\" destination=\"ejb-jar.xml\" type=\"xml\" xmlid=\"id,xmi:id\" tagSet=\"ejb\">\r\n" + "<session id=\"ejbs.TestBean\">\r\n" + "<ejb-name>Test</ejb-name>\r\n" + "<home>ejbs.TestHome</home>\r\n" + "<remote>ejbs.Test</remote>\r\n" + "<ejb-class>ejbs.TestBean</ejb-class>\r\n" + "<session-type>Stateless</session-type>\r\n" + "<transaction-type>Container</transaction-type>\r\n" + "</session>\r\n" + "</Fragment>";
    InputStream inputStream = new StringBufferInputStream(testString);
    // $NON-NLS-1$
    model = modelManager.getModelForRead("test.fragx", inputStream, null);
    System.out.println(model);
    System.out.println(model.getStructuredDocument().get());
}
Also used : StringBufferInputStream(java.io.StringBufferInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) StringBufferInputStream(java.io.StringBufferInputStream) InputStream(java.io.InputStream) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Example 27 with StringBufferInputStream

use of java.io.StringBufferInputStream in project cu-kfs by CU-CommunityApps.

the class CuElectronicInvoiceTestAction method generate.

public ActionForward generate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    checkAuthorization(form, "");
    ElectronicInvoiceTestForm testForm = (ElectronicInvoiceTestForm) form;
    String poDocNumber = testForm.getPoDocNumber();
    LOG.info("Generating Electronic Invoice XML file for Purchase Order Document " + poDocNumber);
    PurchaseOrderService poService = SpringContext.getBean(PurchaseOrderService.class);
    PurchaseOrderDocument po = null;
    if (StringUtils.isBlank(poDocNumber)) {
        GlobalVariables.getMessageMap().putError(PurapPropertyConstants.PURCHASE_ORDER_DOCUMENT_NUMBER, PurapKeyConstants.ERROR_ELECTRONIC_INVOICE_GENERATION_PURCHASE_ORDER_NUMBER_EMPTY, new String[] { poDocNumber });
        return mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
    if (!getDocumentService().documentExists(poDocNumber)) {
        GlobalVariables.getMessageMap().putError(PurapPropertyConstants.PURCHASE_ORDER_DOCUMENT_NUMBER, PurapKeyConstants.ERROR_ELECTRONIC_INVOICE_GENERATION_PURCHASE_ORDER_DOES_NOT_EXIST, poDocNumber);
        return mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
    try {
        po = poService.getPurchaseOrderByDocumentNumber(poDocNumber);
    } catch (Exception e) {
        throw e;
    }
    response.setHeader("Cache-Control", "max-age=30");
    response.setContentType("application/xml");
    StringBuffer sbContentDispValue = new StringBuffer();
    String useJavascript = request.getParameter("useJavascript");
    if (useJavascript == null || useJavascript.equalsIgnoreCase("false")) {
        sbContentDispValue.append("attachment");
    } else {
        sbContentDispValue.append("inline");
    }
    StringBuffer sbFilename = new StringBuffer();
    sbFilename.append("PO_");
    sbFilename.append(poDocNumber);
    sbFilename.append(".xml");
    sbContentDispValue.append("; filename=");
    sbContentDispValue.append(sbFilename);
    response.setHeader("Content-disposition", sbContentDispValue.toString());
    // lookup the PO and fill in the XML with valid data
    if (po != null) {
        String duns = "";
        if (po.getVendorDetail() != null) {
            duns = StringUtils.defaultString(po.getVendorDetail().getVendorDunsNumber());
        }
        DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
        // getting date in kfs format
        String currDate = ElectronicInvoiceUtils.getDateDisplayText(dateTimeService.getCurrentDate());
        String vendorNumber = po.getVendorDetail().getVendorNumber();
        String eInvoiceFile = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "\n<!-- ******Testing tool generated XML****** Version 1.2." + "\n\n  Generated On " + currDate + " for PO " + po.getPurapDocumentIdentifier() + " (Doc# " + poDocNumber + ") -->\n\n" + "<!-- All the cXML attributes are junk values -->\n" + "<cXML payloadID=\"200807260401062080.964@eai002\"\n" + "    timestamp=\"2008-07-26T04:01:06-08:00\"\n" + "    version=\"1.2.014\" xml:lang=\"en\" \n" + "    xmlns=\"http://www.kuali.org/kfs/purap/electronicInvoice\" \n" + "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + "  <Header>\n" + "      <From>\n" + "          <Credential domain=\"DUNS\">\n" + "              <Identity>" + duns + "</Identity> <!-- DUNS number from PO Vendor " + vendorNumber + "-->\n" + "          </Credential>\n" + "      </From>\n" + "      <To>\n" + "          <Credential domain=\"NetworkId\">\n" + "              <Identity>" + "IU" + "</Identity> <!-- Hardcoded --> \n" + "          </Credential>\n" + "      </To>\n" + "      <Sender>\n" + "          <Credential domain=\"DUNS\">\n" + "              <Identity>" + duns + "</Identity> <!-- DUNS number from PO Vendor " + vendorNumber + "-->\n" + "          </Credential>\n" + "          <UserAgent/>\n" + "      </Sender>\n" + "  </Header>\n" + "  <Request deploymentMode=\"production\">\n" + "      <InvoiceDetailRequest>\n" + "          <InvoiceDetailRequestHeader\n" + "              invoiceDate=\"" + currDate + "\" invoiceID=\"" + RandomUtils.nextInt() + "\" operation=\"new\" purpose=\"standard\"> <!-- invoiceID=Random unique Id, invoiceDate=Curr date -->\n" + "              <InvoiceDetailHeaderIndicator/>\n" + "              <InvoiceDetailLineIndicator/>\n" + "              <InvoicePartner>\n" + getContactXMLChunk("billTo", po) + "              </InvoicePartner>\n" + "              <InvoicePartner>\n" + "                  <Contact addressID=\"" + RandomUtils.nextInt() + "\" role=\"remitTo\"> <!-- Vendor address -->\n" + "                      <Name xml:lang=\"en\">\n" + "                          " + po.getVendorName() + "\n" + "                      </Name>\n" + "                      <PostalAddress>\n" + "                          <Street>" + StringUtils.defaultString(po.getVendorLine1Address()) + "</Street>\n" + "                          <Street>" + StringUtils.defaultString(po.getVendorLine2Address()) + "</Street>\n" + "                          <City>" + StringUtils.defaultString(po.getVendorCityName()) + "</City>\n" + "                          <State>" + StringUtils.defaultString(po.getVendorStateCode()) + "</State>\n" + "                          <PostalCode>" + StringUtils.defaultString(po.getVendorPostalCode()) + "</PostalCode>\n" + "                          <Country isoCountryCode=\"" + StringUtils.defaultString(po.getVendorCountryCode()) + "\">\n" + "                              " + StringUtils.defaultString(po.getVendorCountry().getName()) + "\n" + "                          </Country>\n" + "                      </PostalAddress>\n" + "                  </Contact>\n" + "              </InvoicePartner>\n" + getDeliveryAddressXMLChunk("shipTo", po) + getPaymentTermXML(po) + "          </InvoiceDetailRequestHeader>\n" + "          <InvoiceDetailOrder>\n" + "              <InvoiceDetailOrderInfo>\n" + "                  <OrderReference\n" + "                      orderDate=\"" + ElectronicInvoiceUtils.getDateDisplayText(dateTimeService.getCurrentDate()) + "\" orderID=\"" + po.getPurapDocumentIdentifier() + "\"> <!--orderDate=Curr date,orderID=PO#-->\n" + "                      <DocumentReference payloadID=\"NA\" /> <!--HardCoded-->\n" + "                  </OrderReference>\n" + "              </InvoiceDetailOrderInfo>\n" + "              <!-- No junk values in Items-->\n";
        for (int i = 0; i < po.getItems().size(); i++) {
            List items = po.getItems();
            PurchaseOrderItem item = (PurchaseOrderItem) items.get(i);
            if (!item.getItemType().isAdditionalChargeIndicator()) {
                eInvoiceFile = eInvoiceFile + getPOItemXMLChunk(item);
            }
        }
        KualiDecimal totalDollarAmt = po.getTotalDollarAmount() == null ? KualiDecimal.ZERO : po.getTotalDollarAmount();
        eInvoiceFile = eInvoiceFile + "          </InvoiceDetailOrder>\n" + "          <InvoiceDetailSummary>\n" + "              <SubtotalAmount>\n" + "                  <Money currency=\"USD\">" + po.getTotalPreTaxDollarAmount() + "</Money>\n" + "              </SubtotalAmount>\n" + "              <Tax>\n" + "                  <Money currency=\"USD\">" + po.getTotalTaxAmount() + "</Money>\n" + "                  <Description xml:lang=\"en\">Total Tax</Description>\n" + "              </Tax>\n" + "              <SpecialHandlingAmount>\n" + "                  <Money currency=\"USD\">0.00</Money>\n" + "              </SpecialHandlingAmount>\n" + "              <ShippingAmount>\n" + "                  <Money currency=\"USD\">0.00</Money>\n" + "              </ShippingAmount>\n" + "              <GrossAmount>\n" + "                  <Money currency=\"USD\">" + totalDollarAmt + "</Money>\n" + "              </GrossAmount>\n" + "              <InvoiceDetailDiscount>\n" + "                  <Money currency=\"USD\">0.00</Money>\n" + "                  </InvoiceDetailDiscount>\n" + "              <NetAmount>\n" + "                  <Money currency=\"USD\">" + totalDollarAmt + "</Money>\n" + "              </NetAmount>\n" + "              <DepositAmount>\n" + "                  <Money currency=\"USD\">0.00</Money>\n" + "              </DepositAmount>\n" + "              <DueAmount>\n" + "                  <Money currency=\"USD\">" + totalDollarAmt + "</Money>\n" + "              </DueAmount>\n" + "          </InvoiceDetailSummary>\n" + "      </InvoiceDetailRequest>\n" + "  </Request>\n" + "</cXML>";
        ServletOutputStream sos;
        sos = response.getOutputStream();
        ByteArrayOutputStream baOutStream = new ByteArrayOutputStream();
        StringBufferInputStream inStream = new StringBufferInputStream(eInvoiceFile);
        convert(baOutStream, inStream);
        response.setContentLength(baOutStream.size());
        baOutStream.writeTo(sos);
        sos.flush();
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PurchaseOrderService(org.kuali.kfs.module.purap.document.service.PurchaseOrderService) ServletOutputStream(javax.servlet.ServletOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PurchaseOrderItem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem) StringBufferInputStream(java.io.StringBufferInputStream) ElectronicInvoiceTestForm(org.kuali.kfs.module.purap.document.web.struts.ElectronicInvoiceTestForm) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) List(java.util.List) DateTimeService(org.kuali.rice.core.api.datetime.DateTimeService)

Example 28 with StringBufferInputStream

use of java.io.StringBufferInputStream in project groovy by apache.

the class DependencyTest method testDep.

public void testDep() {
    cu.addSource("testDep.gtest", new StringBufferInputStream("class C1 {}\n" + "class C2 {}\n" + "class C3 {}\n" + "class A1 {C1 x}\n" + "class A2 extends C2{}\n" + "class A3 {C1 foo(C2 x){new C3()}}\n"));
    cu.compile(Phases.CLASS_GENERATION);
    assertEquals(cache.get("C1").size(), 1);
    assertEquals(cache.get("C2").size(), 1);
    assertEquals(cache.get("C3").size(), 1);
    Set<String> dep = cache.get("A1");
    assertEquals(dep.size(), 2);
    assertTrue(dep.contains("C1"));
    dep = cache.get("A2");
    assertEquals(dep.size(), 2);
    assertTrue(dep.contains("C2"));
    dep = cache.get("A3");
    assertEquals(dep.size(), 4);
    assertTrue(dep.contains("C1"));
    assertTrue(dep.contains("C2"));
    assertTrue(dep.contains("C3"));
}
Also used : StringBufferInputStream(java.io.StringBufferInputStream)

Example 29 with StringBufferInputStream

use of java.io.StringBufferInputStream in project groovy by apache.

the class DependencyTest method testTransitiveDep.

public void testTransitiveDep() {
    cu.addSource("testTransitiveDep.gtest", new StringBufferInputStream("class A1 {}\n" + "class A2 extends A1{}\n" + "class A3 extends A2{}\n"));
    cu.compile(Phases.CLASS_GENERATION);
    cache.makeTransitiveHull();
    Set<String> dep = cache.get("A1");
    assertEquals(dep.size(), 1);
    dep = cache.get("A2");
    assertEquals(dep.size(), 2);
    assertTrue(dep.contains("A1"));
    dep = cache.get("A3");
    assertEquals(dep.size(), 3);
    assertTrue(dep.contains("A1"));
    assertTrue(dep.contains("A2"));
}
Also used : StringBufferInputStream(java.io.StringBufferInputStream)

Example 30 with StringBufferInputStream

use of java.io.StringBufferInputStream in project oxCore by GluuFederation.

the class SAMLMetadataParser method parseMetadata.

public EntityIDHandler parseMetadata(URL metadataURL) {
    String metadataFileContent = HTTPFileDownloader.getResource(metadataURL.toExternalForm(), "application/xml, text/xml", null, null);
    if (metadataFileContent == null) {
        return null;
    }
    InputStream is = new StringBufferInputStream(metadataFileContent);
    return parseMetadata(is);
}
Also used : StringBufferInputStream(java.io.StringBufferInputStream) StringBufferInputStream(java.io.StringBufferInputStream) InputStream(java.io.InputStream)

Aggregations

StringBufferInputStream (java.io.StringBufferInputStream)34 Test (org.junit.Test)10 InputStream (java.io.InputStream)9 SQLException (java.sql.SQLException)6 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)5 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)5 BadLocationException (org.eclipse.jface.text.BadLocationException)3 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)3 InputStreamBuilder (io.vertigo.dynamo.file.model.InputStreamBuilder)2 VFile (io.vertigo.dynamo.file.model.VFile)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 Instant (java.time.Instant)2 Matchers.anyString (org.mockito.Matchers.anyString)2 KettleException (org.pentaho.di.core.exception.KettleException)2 RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)2 Element (org.w3c.dom.Element)2 Table (com.mapr.db.Table)1 Description (io.qameta.allure.Description)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1