Package org.apache.axiom.attachments

Examples of org.apache.axiom.attachments.ByteArrayDataSource


    private void performTestNewDataHandlerArray(StandardTypesServiceClient serviceClient) throws IOException {
        DataHandler[] dha = new DataHandler[3];
        dha[0] = new DataHandler("Some data", "text/plain");
        dha[1] = new DataHandler(this.getClass().getClassLoader().getResource("standard-types-service.composite"));
        dha[2] = new DataHandler(new ByteArrayDataSource("Some data2".getBytes()));

        DataHandler[] actual = serviceClient.getNewDataHandlerArrayForward(dha);
        Assert.assertEquals(dha.length, actual.length);
        for (int i = 0; i < dha.length; ++i) {
            // Note: The DataHandler returned may use a different type of DataSource.
View Full Code Here


            Resource sampleFile = (Resource) carbonContext.getRegistry(RegistryType.SYSTEM_GOVERNANCE).
                            get(getSamplePath(sampleName));
            UploadedFileItem[] fileItems = new UploadedFileItem[1];
            fileItems[0] = new UploadedFileItem();
            fileItems[0].setDataHandler(
                    new DataHandler(new ByteArrayDataSource((byte[]) sampleFile.getContent(),
                                                            "application/octet-stream")));
            fileItems[0].setFileName(sampleName + APP_ARCHIVE_EXTENSION);
            fileItems[0].setFileType("jar");
            uploadApp(fileItems);
            return true;
View Full Code Here

    content.setSrc("foo");
    assertNotNull(content);
    assertEquals(content.getMimeType().toString(), "text/foo");
    assertEquals(content.getSrc().toString(), "foo");
    content = factory.newContent(new MimeType("text/foo"));
    content.setDataHandler(new DataHandler(new ByteArrayDataSource("foo".getBytes())));
    assertEquals(content.getValue(), "Zm9v");
    assertEquals(content.getContentType(), Content.Type.MEDIA);
    el = factory.newName();
    assertNotNull(el);
    el = factory.newName();
View Full Code Here

    @Override
    protected XMLMessage prepareMessage() throws Exception {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMElement payload = factory.createOMElement(new QName("root"));
        Attachments attachments = new Attachments();
        attachments.addDataHandler(contentID, new DataHandler(new ByteArrayDataSource(attachmentContent, "application/octet-stream")));
        return new XMLMessage(payload, XMLMessage.Type.SWA, attachments);
    }
View Full Code Here

                InputStream returnStram = in;
                this.in = null;
                return returnStram;
            } else if (in != null) {
                byte[] data = BinaryRelayBuilder.readAllFromInputSteam(in);
                cachedData = new ByteArrayDataSource(data);
                return cachedData.getInputStream();
            } else {
                throw new IOException("Input stream has being already consumed");
            }
        }
View Full Code Here

        Node importNode = ownerDocument.importNode(child, true);
        parent.addChild((OMNode) importNode);
    }

    public static void appendAsTest(byte[] base64Binary, OMElement element) {
        ByteArrayDataSource bads = new ByteArrayDataSource(base64Binary);
        DataHandler dataHandler = new DataHandler(bads);
        OMText text = new OMTextImpl(dataHandler, element.getOMFactory());
        element.addChild(text);
    }
View Full Code Here

                    factory.createOMElement(XKMS2Constants.ELE_OPAQUE_CLIENT_DATA);
            for (int i = 0; i < opaqueDataList.size(); i++) {
                OMElement opaqueDataEle = factory.createOMElement(XKMS2Constants.ELE_OPAQUE_DATA);
                OpaqueData opaqueData = (OpaqueData) opaqueDataList.get(i);
                DataHandler dataHandler =
                        new DataHandler(new ByteArrayDataSource(opaqueData.getBase64Binary()));

                OMText omText = factory.createOMText(dataHandler,false);
                opaqueDataEle.addChild(omText);
                opaqueClientDataEle.addChild(opaqueDataEle);
            }
View Full Code Here

            if (revocationCode != null) {
                OMElement revocationCodeElem = factory.createOMElement(
                        XKMS2Constants.Q_ELEM_REVOCATION_CODE,
                        revokeRequestElem);
                DataHandler dataHandler = new DataHandler(
                        new ByteArrayDataSource(revocationCode));
               
                OMText text = factory.createOMText(dataHandler, false);
                revocationCodeElem.addChild(text);
               
            } else {
View Full Code Here

            OMElement requestSignatureValueEle =
                    factory.createOMElement(XKMS2Constants.ELE_REQUEST_SIGNATURE_VALUE);

            DataHandler dataHandler =
                    new DataHandler(
                            new ByteArrayDataSource(requestSignatureValue.getBase64Binary()));
            OMTextImpl omText = new OMTextImpl(dataHandler, true, factory);
            requestSignatureValueEle.addChild(omText);
            String id = requestSignatureValue.getId();
            if (id != null) {
                requestSignatureValueEle.addAttribute(XKMS2Constants.ATTR_ID, id, emptyNs);
View Full Code Here

        OMElement opaqueClientDataEle = fac.createOMElement("OpaqueClientData",
                ns);
        validateRequestEle.addChild(opaqueClientDataEle);
        OMText omText = fac.createOMText(new DataHandler(
                new ByteArrayDataSource("junk data".getBytes())), false);
        OMElement opaqueDataEle = fac.createOMElement("OpaqueData", ns);
        opaqueDataEle.addChild(omText);
        opaqueClientDataEle.addChild(opaqueDataEle);

        OMElement respondWithEle = fac.createOMElement("RespondWith", ns);
View Full Code Here

TOP

Related Classes of org.apache.axiom.attachments.ByteArrayDataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.