javax.activation.datahandler Java Examples

The following examples show how to use javax.activation.datahandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SOAPPartImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
DataHandler getDataHandler() {
    DataSource ds = new DataSource() {
        public OutputStream getOutputStream() throws IOException {
            throw new IOException("Illegal Operation");
        }

        public String getContentType() {
            return getContentTypeString();
        }

        public String getName() {
            return getContentId();
        }

        public InputStream getInputStream() throws IOException {
            return getContentAsStream();
        }
    };
    return new DataHandler(ds);
}
 
Example #2
Source File: TorXTeeServiceImpl.java    From j-road with Apache License 2.0 6 votes vote down vote up
@Override
public UploadMimeResponse uploadMime(String target, String operation, String id, DataHandler fail)
    throws XRoadServiceConsumptionException {
  UploadMime uploadMimeDocument = UploadMimeDocument.UploadMime.Factory.newInstance();

  UploadMimeType request = uploadMimeDocument.addNewRequest();
  request.setTarget(target);
  request.setOperation(operation);
  Props props = request.addNewProps();
  Prop prop = props.addNewProp();
  prop.setKey(UPLOAD_ID);
  prop.setStringValue(id);

  XmlBeansXRoadMessage<UploadMimeDocument.UploadMime> XRoadMessage =
      new XmlBeansXRoadMessage<UploadMimeDocument.UploadMime>(uploadMimeDocument);
  List<XRoadAttachment> attachments = XRoadMessage.getAttachments();

  String failCid = AttachmentUtil.getUniqueCid();
  request.addNewFile().setHref("cid:" + failCid);
  attachments.add(new XRoadAttachment(failCid, fail));

  XRoadMessage<UploadMimeResponse> response = send(XRoadMessage, METHOD_UPLOAD_MIME, V1, new TorCallback(), null);

  return response.getContent();
}
 
Example #3
Source File: ServerLogicalHandlerTube.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
void callHandlersOnResponse(MessageUpdatableContext context, boolean handleFault) {
    //Lets copy all the MessageContext.OUTBOUND_ATTACHMENT_PROPERTY to the message
    Map<String, DataHandler> atts = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
    AttachmentSet attSet = context.packet.getMessage().getAttachments();
    for (Entry<String, DataHandler> entry : atts.entrySet()) {
        String cid = entry.getKey();
        Attachment att = new DataHandlerAttachment(cid, atts.get(cid));
        attSet.add(att);
    }

    try {
        //SERVER-SIDE
        processor.callHandlersResponse(HandlerProcessor.Direction.OUTBOUND, context, handleFault);

    } catch (WebServiceException wse) {
        //no rewrapping
        throw wse;
    } catch (RuntimeException re) {
        throw re;
    }
}
 
Example #4
Source File: BookCatalog.java    From cxf with Apache License 2.0 6 votes vote down vote up
@POST
@Consumes("multipart/form-data")
public Response addBook(final MultipartBody body) throws Exception {
    for (final Attachment attachment: body.getAllAttachments()) {
        final DataHandler handler = attachment.getDataHandler();

        if (handler != null) {
            final String source = handler.getName();
            final LuceneDocumentMetadata metadata = new LuceneDocumentMetadata()
                .withSource(source)
                .withField("modified", Date.class);

            final Document document = extractor.extract(handler.getInputStream(), metadata);
            if (document != null) {
                try (IndexWriter writer = getIndexWriter()) {
                    writer.addDocument(document);
                    writer.commit();
                }
            }
        }
    }

    return Response.ok().build();
}
 
Example #5
Source File: IterateRegistryAsTargetTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.esb", description = "Tests for sequence from governors registry ")
public void testGovernersSequence() throws Exception {
    URL url =
            new URL("file:///" + getESBResourceLocation() + "/mediatorconfig/iterate/iterateLogAndSendSequence.xml");
    resourceAdminServiceClient.addResource("/_system/governance/sequences/iterate/iterateLogAndSendSequence",
                                           "application/vnd.wso2.sequence", "configuration",
                                           setEndpoints(new DataHandler(url)));
    String response = client.getMultipleResponse(
            getProxyServiceURLHttp("iterateWithTargetGovernanceTestProxy"), "WSO2",
            2);
    Assert.assertNotNull(response);
    OMElement envelope = client.toOMElement(response);
    OMElement soapBody = envelope.getFirstElement();
    Iterator iterator =
            soapBody.getChildrenWithName(new QName("http://services.samples",
                                                   "getQuoteResponse"));
    int i = 0;
    while (iterator.hasNext()) {
        i++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("WSO2"));
    }
    Assert.assertEquals(i, 2, "Child Element count mismatched");
    resourceAdminServiceClient.deleteResource("/_system/governance/sequences/iterate/iterateLogAndSendSequence");
}
 
Example #6
Source File: EndpointArgumentsBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an AttachmentBuilder based on the parameter type
 *
 * @param param
 *      runtime Parameter that abstracts the annotated java parameter
 * @param setter
 *      specifies how the obtained value is set into the argument. Takes
 *      care of Holder arguments.
 */
public static EndpointArgumentsBuilder createAttachmentBuilder(ParameterImpl param, EndpointValueSetter setter) {
    Class type = (Class)param.getTypeInfo().type;
    if (DataHandler.class.isAssignableFrom(type)) {
        return new DataHandlerBuilder(param, setter);
    } else if (byte[].class==type) {
        return new ByteArrayBuilder(param, setter);
    } else if(Source.class.isAssignableFrom(type)) {
        return new SourceBuilder(param, setter);
    } else if(Image.class.isAssignableFrom(type)) {
        return new ImageBuilder(param, setter);
    } else if(InputStream.class==type) {
        return new InputStreamBuilder(param, setter);
    } else if(isXMLMimeType(param.getBinding().getMimeType())) {
        return new JAXBBuilder(param, setter);
    } else if(String.class.isAssignableFrom(type)) {
        return new StringBuilder(param, setter);
    } else {
        throw new UnsupportedOperationException("Unknown Type="+type+" Attachment is not mapped.");
    }
}
 
Example #7
Source File: EndpointArgumentsBuilder.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an AttachmentBuilder based on the parameter type
 *
 * @param param
 *      runtime Parameter that abstracts the annotated java parameter
 * @param setter
 *      specifies how the obtained value is set into the argument. Takes
 *      care of Holder arguments.
 */
public static EndpointArgumentsBuilder createAttachmentBuilder(ParameterImpl param, EndpointValueSetter setter) {
    Class type = (Class)param.getTypeInfo().type;
    if (DataHandler.class.isAssignableFrom(type)) {
        return new DataHandlerBuilder(param, setter);
    } else if (byte[].class==type) {
        return new ByteArrayBuilder(param, setter);
    } else if(Source.class.isAssignableFrom(type)) {
        return new SourceBuilder(param, setter);
    } else if(Image.class.isAssignableFrom(type)) {
        return new ImageBuilder(param, setter);
    } else if(InputStream.class==type) {
        return new InputStreamBuilder(param, setter);
    } else if(isXMLMimeType(param.getBinding().getMimeType())) {
        return new JAXBBuilder(param, setter);
    } else if(String.class.isAssignableFrom(type)) {
        return new StringBuilder(param, setter);
    } else {
        throw new UnsupportedOperationException("Unknown Type="+type+" Attachment is not mapped.");
    }
}
 
Example #8
Source File: WSDLOptionsPickedFromRegistryTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private void uploadResourcesToConfigRegistry() throws Exception {

        ResourceAdminServiceClient resourceAdminServiceStub =
                new ResourceAdminServiceClient(context.getContextUrls().getBackEndUrl(), getSessionCookie());

        resourceAdminServiceStub.deleteResource("/_system/config/proxy");
        resourceAdminServiceStub.addCollection("/_system/config/", "proxy", "",
                                               "Contains test proxy tests files");

        resourceAdminServiceStub.addResource(
                "/_system/config/proxy/sample_proxy_1.wsdl", "application/wsdl+xml", "wsdl+xml files",
                new DataHandler(new URL("file:///" + getESBResourceLocation() +
                                        "/proxyconfig/proxy/utils/sample_proxy_1.wsdl")));

        Thread.sleep(1000);

    }
 
Example #9
Source File: ServerLogicalHandlerTube.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void callHandlersOnResponse(MessageUpdatableContext context, boolean handleFault) {
    //Lets copy all the MessageContext.OUTBOUND_ATTACHMENT_PROPERTY to the message
    Map<String, DataHandler> atts = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
    AttachmentSet attSet = context.packet.getMessage().getAttachments();
    for (Entry<String, DataHandler> entry : atts.entrySet()) {
        String cid = entry.getKey();
        Attachment att = new DataHandlerAttachment(cid, atts.get(cid));
        attSet.add(att);
    }

    try {
        //SERVER-SIDE
        processor.callHandlersResponse(HandlerProcessor.Direction.OUTBOUND, context, handleFault);

    } catch (WebServiceException wse) {
        //no rewrapping
        throw wse;
    } catch (RuntimeException re) {
        throw re;
    }
}
 
Example #10
Source File: IterateWithRegistriesAsTargetEndpointsTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.esb", description = "Tests for sequence from configuration registry")
public void testConfigurationEndPoint() throws Exception {
    URL url =
            new URL("file:///" + getESBResourceLocation() + "/mediatorconfig/iterate/iterateEndpoint.xml");
    endPointAdminClient.addDynamicEndPoint("conf:/myEndpoint/iterateEndpoint", setEndpoints(new DataHandler(url)));
    String response = client.getMultipleResponse(
            getProxyServiceURLHttp("iterateWithConfigurationEndpoint"), "WSO2", 2);
    Assert.assertNotNull(response);
    OMElement envelope = client.toOMElement(response);
    OMElement soapBody = envelope.getFirstElement();
    Iterator iterator =
            soapBody.getChildrenWithName(new QName("http://services.samples",
                                                   "getQuoteResponse"));
    int i = 0;
    while (iterator.hasNext()) {
        i++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("WSO2"));
    }
    Assert.assertEquals(i, 2, "Child Element count mismatched");
    endPointAdminClient.deleteDynamicEndpoint("conf:/myEndpoint/iterateEndpoint");
}
 
Example #11
Source File: ArtifactServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * return the artifact by name and type
 * @param token. The token.
 * @param user. The user.
 * @param name. The artifact's name.
 * @param type. The artifact's type.
 * @return the content of the artifact.
 */
public DataHandler getArtifactContentByNameAndType(String token,String user, String name, String type){
	logger.debug("IN");
	Monitor monitor = MonitorFactory
			.start("spagobi.service.artifact.getArtifactContentByNameAndType");
	try {
		validateTicket(token, user);
		this.setTenantByUserId(user);
		ArtifactServiceImplSupplier supplier = new ArtifactServiceImplSupplier();			
		return supplier.getArtifactContentByNameAndType(name, type);
	} catch (Exception e) {
		logger.error("Exception", e);
		return null;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}				
}
 
Example #12
Source File: Mail.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addAttachedFilePart( FileObject file ) throws Exception {
  // create a data source

  MimeBodyPart files = new MimeBodyPart();
  // create a data source
  URLDataSource fds = new URLDataSource( file.getURL() );
  // get a data Handler to manipulate this file type;
  files.setDataHandler( new DataHandler( fds ) );
  // include the file in the data source
  files.setFileName( file.getName().getBaseName() );
  // insist on base64 to preserve line endings
  files.addHeader( "Content-Transfer-Encoding", "base64" );
  // add the part with the file in the BodyPart();
  data.parts.addBodyPart( files );
  if ( isDetailed() ) {
    logDetailed( BaseMessages.getString( PKG, "Mail.Log.AttachedFile", fds.getName() ) );
  }

}
 
Example #13
Source File: ResponseBuilder.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an AttachmentBuilder based on the parameter type
 *
 * @param param
 *      runtime Parameter that abstracts the annotated java parameter
 * @param setter
 *      specifies how the obtained value is set into the argument. Takes
 *      care of Holder arguments.
 */
public static ResponseBuilder createAttachmentBuilder(ParameterImpl param, ValueSetter setter) {
    Class type = (Class)param.getTypeInfo().type;
    if (DataHandler.class.isAssignableFrom(type)) {
        return new DataHandlerBuilder(param, setter);
    } else if (byte[].class==type) {
        return new ByteArrayBuilder(param, setter);
    } else if(Source.class.isAssignableFrom(type)) {
        return new SourceBuilder(param, setter);
    } else if(Image.class.isAssignableFrom(type)) {
        return new ImageBuilder(param, setter);
    } else if(InputStream.class==type) {
        return new InputStreamBuilder(param, setter);
    } else if(isXMLMimeType(param.getBinding().getMimeType())) {
        return new JAXBBuilder(param, setter);
    } else if(String.class.isAssignableFrom(type)) {
        return new StringBuilder(param, setter);
    } else {
        throw new UnsupportedOperationException("Unexpected Attachment type ="+type);
    }
}
 
Example #14
Source File: WSDLOptionsPickedFromRegistryTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private void uploadResourcesToConfigRegistry() throws Exception {

        ResourceAdminServiceClient resourceAdminServiceStub =
                new ResourceAdminServiceClient(context.getContextUrls().getBackEndUrl(), getSessionCookie());

        resourceAdminServiceStub.deleteResource("/_system/config/proxy");
        resourceAdminServiceStub.addCollection("/_system/config/", "proxy", "",
                                               "Contains test proxy tests files");

        resourceAdminServiceStub.addResource(
                "/_system/config/proxy/sample_proxy_1.wsdl", "application/wsdl+xml", "wsdl+xml files",
                new DataHandler(new URL("file:///" + getESBResourceLocation() +
                                        "/proxyconfig/proxy/utils/sample_proxy_1.wsdl")));

        Thread.sleep(1000);

    }
 
Example #15
Source File: MtomCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("resource")
private void writeNonMtomAttachments(AttachmentSet attachments,
        OutputStream out, String boundary) throws IOException {

    for (Attachment att : attachments) {

        DataHandler dh = att.asDataHandler();
        if (dh instanceof StreamingDataHandler) {
            StreamingDataHandler sdh = (StreamingDataHandler) dh;
            // If DataHandler has href Content-ID, it is MTOM, so skip.
            if (sdh.getHrefCid() != null)
                continue;
        }

        // build attachment frame
        writeln("--" + boundary, out);
        writeMimeHeaders(att.getContentType(), att.getContentId(), out);
        att.writeTo(out);
        writeln(out); // write \r\n
    }
}
 
Example #16
Source File: MTOMSwASampleService.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public void oneWayUploadUsingMTOM(OMElement element) throws Exception {

        OMText binaryNode = (OMText) element.getFirstOMChild();
        DataHandler dataHandler = (DataHandler) binaryNode.getDataHandler();
        InputStream is = dataHandler.getInputStream();

        File tempFile = File.createTempFile("mtom-", ".gif");
        FileOutputStream fos = new FileOutputStream(tempFile);
        BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER);

        byte data[] = new byte[BUFFER];
        int count;
        while ((count = is.read(data, 0, BUFFER)) != -1) {
            dest.write(data, 0, count);
        }

        dest.flush();
        dest.close();
        System.out.println("Wrote to file : " + tempFile.getAbsolutePath());
    }
 
Example #17
Source File: TstRecursiveImport.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void importDocument(File file, long parentId) throws Exception {

		String fileExt = FilenameUtils.getExtension(file.getName());
		if (!allowedExtensions.contains(fileExt.toLowerCase())) 
			return;
		
		DataSource ds = new FileDataSource(file);
		DataHandler content = new DataHandler(ds);

		WSDocument document = new WSDocument();
		document.setFolderId(parentId);
		document.setFileName(file.getName());

		WSDocument docRes = dclient.create(sid, document, content);

		System.out.println("documentID = " + docRes.getId());
	}
 
Example #18
Source File: EmailSender.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected MimeBodyPart createAttachmentPart(SendingAttachment attachment) throws MessagingException {
    DataSource source = new MyByteArrayDataSource(attachment.getContent());

    String mimeType = FileTypesHelper.getMIMEType(attachment.getName());

    String contentId = attachment.getContentId();
    if (contentId == null) {
        contentId = generateAttachmentContentId(attachment.getName());
    }

    String disposition = attachment.getDisposition() != null ? attachment.getDisposition() : Part.INLINE;
    String charset = MimeUtility.mimeCharset(attachment.getEncoding() != null ?
            attachment.getEncoding() : StandardCharsets.UTF_8.name());
    String contentTypeValue = String.format("%s; charset=%s; name=\"%s\"", mimeType, charset, attachment.getName());

    MimeBodyPart attachmentPart = new MimeBodyPart();
    attachmentPart.setDataHandler(new DataHandler(source));
    attachmentPart.setHeader("Content-ID", "<" + contentId + ">");
    attachmentPart.setHeader("Content-Type", contentTypeValue);
    attachmentPart.setFileName(attachment.getName());
    attachmentPart.setDisposition(disposition);

    return attachmentPart;
}
 
Example #19
Source File: Jaxb2Marshaller.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
public DataHandler getAttachmentAsDataHandler(String contentId) {
	if (contentId.startsWith(CID)) {
		contentId = contentId.substring(CID.length());
		try {
			contentId = URLDecoder.decode(contentId, "UTF-8");
		}
		catch (UnsupportedEncodingException ex) {
			// ignore
		}
		contentId = '<' + contentId + '>';
	}
	DataHandler dataHandler = this.mimeContainer.getAttachment(contentId);
	if (dataHandler == null) {
		throw new IllegalArgumentException("No attachment found for " + contentId);
	}
	return dataHandler;
}
 
Example #20
Source File: BPMNUploaderClient.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private UploadedFileItem getUploadedFileItem(DataHandler dataHandler, String fileName,
                                             String fileType) {
    UploadedFileItem uploadedFileItem = new UploadedFileItem();
    uploadedFileItem.setDataHandler(dataHandler);
    uploadedFileItem.setFileName(fileName);
    uploadedFileItem.setFileType(fileType);

    return uploadedFileItem;
}
 
Example #21
Source File: ServiceInterface.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
@WebMethod(action = "checkinInitiatedSync")
SLongCheckinActionState checkinInitiatedSync(
	@WebParam(name = "topicId", partName = "checkinInitiated.topicId") Long topicId,
	@WebParam(name = "poid", partName = "checkinInitiated.poid") Long poid,
	@WebParam(name = "comment", partName = "checkinInitiated.comment") String comment,
	@WebParam(name = "deserializerOid", partName = "checkinInitiated.deserializerOid") Long deserializerOid,
	@WebParam(name = "fileSize", partName = "checkinInitiated.fileSize") Long fileSize,
	@WebParam(name = "fileName", partName = "checkinInitiated.fileName") String fileName,
	@WebParam(name = "data", partName = "checkinInitiated.data") @XmlMimeType("application/octet-stream") DataHandler data,
	@WebParam(name = "merge", partName = "checkinInitiated.merge") Boolean merge) throws ServerException, UserException;
 
Example #22
Source File: DTPBatchRequestSampleTestcase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void initialize() throws Exception {
    super.init();
    serverEpr = getServiceUrlHttp(serviceName);
    String resourceFileLocation = getResourceLocation();
    deployService(serviceName, new DataHandler(
            new URL("file:///" + resourceFileLocation + File.separator + "samples" + File.separator + "dbs"
                    + File.separator + "rdbms" + File.separator + "DTPBatchRequestService.dbs")));
    log.info(serviceName + " uploaded");
}
 
Example #23
Source File: ESBJAVA3269_StatisticsCloneTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
protected void initialize() throws Exception {
    super.init();
    carbonAppUploaderClient = new CarbonAppUploaderClient(contextUrls.getBackEndUrl(), getSessionCookie());
    carbonAppUploaderClient.uploadCarbonAppArtifact("TestCloneStatsCappProj_1.0.0.car", new DataHandler(
            new URL("file:" + File.separator + File.separator + getESBResourceLocation() + File.separator + "car"
                    + File.separator + "TestCloneStatsCappProj_1.0.0.car")));
    isCarFileUploaded = true;
    applicationAdminClient = new ApplicationAdminClient(contextUrls.getBackEndUrl(), getSessionCookie());
    Assert.assertTrue(isCarFileDeployed(carFileName), "Artifact Car deployment failed");
    TimeUnit.SECONDS.sleep(5);
}
 
Example #24
Source File: ValidateIntegrationNegativeTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private void uploadConfig()
            throws RemoteException, ResourceAdminServiceExceptionException, MalformedURLException,
            InterruptedException, XPathExpressionException {
        ResourceAdminServiceClient resourceAdminServiceStub = new ResourceAdminServiceClient(contextUrls.getBackEndUrl(), context.getContextTenant().getContextUser().getUserName()
, context.getContextTenant().getContextUser().getPassword());
        resourceAdminServiceStub.deleteResource("/_system/config/validate");
        resourceAdminServiceStub.addCollection("/_system/config/", "validate", "", "Contains test schema files");

        resourceAdminServiceStub.addResource("/_system/config/validate/schema.xml", "application/xml",
                                             "schema files", new DataHandler(new URL("file:///" +
                                                                                     getESBResourceLocation() + "/mediatorconfig/validate/schema.xml")));
    }
 
Example #25
Source File: DSSIntegrationTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
protected void deployService(String serviceName, DataHandler dssConfiguration) throws Exception {
    DSSTestCaseUtils dssTest = new DSSTestCaseUtils();
    Assert.assertTrue(
            dssTest.uploadArtifact(dssContext.getContextUrls().getBackEndUrl(), sessionCookie, serviceName,
                    dssConfiguration), "Service File Uploading failed");
    Assert.assertTrue(
            dssTest.isServiceDeployed(dssContext.getContextUrls().getBackEndUrl(), sessionCookie, serviceName),
            "Service Not Found, Deployment time out ");
}
 
Example #26
Source File: DynamicKeyXsltTransformationTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private void uploadResourcesToRegistry() throws Exception {
    ResourceAdminServiceClient resourceAdminServiceClient =
            new ResourceAdminServiceClient(contextUrls.getBackEndUrl(), getSessionCookie());
    PropertiesAdminServiceClient propertiesAdminServiceClient =
            new PropertiesAdminServiceClient(contextUrls.getBackEndUrl(), getSessionCookie());

    resourceAdminServiceClient.deleteResource("/_system/config/localEntries");
    resourceAdminServiceClient.addCollection("/_system/config/", "localEntries", "",
                                             "Contains dynamic sequence request entry");

    resourceAdminServiceClient.addResource(
            "/_system/config/localEntries/request_transformation_DynamicKeyXsltTransformationTestCase.txt", "text/plain", "text files",
            new DataHandler("Dynamic Sequence request transformation".getBytes(), "application/text"));
    propertiesAdminServiceClient.setProperty("/_system/config/localEntries/request_transformation_DynamicKeyXsltTransformationTestCase.txt",
                                             "resourceName", "xsltTransformRequest");

    resourceAdminServiceClient.deleteResource("/_system/governance/localEntries");
    resourceAdminServiceClient.addCollection("/_system/governance/", "localEntries", "",
                                             "Contains dynamic sequence response entry");
    resourceAdminServiceClient.addResource(
            "/_system/governance/localEntries/response_transformation_back_DynamicKeyXsltTransformationTestCase.txt", "text/plain", "text files",
            new DataHandler("Dynamic Sequence response transformation".getBytes(), "application/text"));
    propertiesAdminServiceClient.setProperty("/_system/governance/localEntries/response_transformation_back_DynamicKeyXsltTransformationTestCase.txt",
                                             "resourceName", "xsltTransformResponse");

    Thread.sleep(1000);
}
 
Example #27
Source File: ServiceInterface.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
@WebMethod(action = "checkinAsync")
Long checkinAsync(
	@WebParam(name = "poid", partName = "checkin.poid") Long poid,
	@WebParam(name = "comment", partName = "checkin.comment") String comment,
	@WebParam(name = "deserializerOid", partName = "checkin.deserializerOid") Long deserializerOid,
	@WebParam(name = "fileSize", partName = "checkin.fileSize") Long fileSize,
	@WebParam(name = "fileName", partName = "checkin.fileName") String fileName,
	@WebParam(name = "data", partName = "checkin.data") @XmlMimeType("application/octet-stream") DataHandler data,
	@WebParam(name = "merge", partName = "checkin.merge") Boolean merge) throws ServerException, UserException;
 
Example #28
Source File: ResourceAdminServiceClient.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public void uploadArtifact(String description, DataHandler dh)
        throws ResourceAdminServiceExceptionException, RemoteException {
    String fileName;
    fileName = dh.getName().substring(dh.getName().lastIndexOf('/') + 1);
    resourceAdminServiceStub
            .addResource("/" + fileName, MEDIA_TYPE_GOVERNANCE_ARCHIVE, description, dh, null, null);
}
 
Example #29
Source File: UserAdminClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public void bulkImportUsers(String userStoreDomain, String fileName, DataHandler handler, String defaultPassword)
        throws AxisFault {
    try {
        stub.bulkImportUsers(userStoreDomain, fileName, handler, defaultPassword);
    } catch (Exception e) {
        handleException(e);
    }
}
 
Example #30
Source File: EmailReportDelivery.java    From Design-Patterns-and-SOLID-Principles-with-Java with MIT License 5 votes vote down vote up
@Override
protected void doDeliver(Report.Type reportType, ExportType exportType, byte[] bytes) throws ReportDeliveryException {
    try {
        MimeBodyPart msgBodyPart = new MimeBodyPart();
        msgBodyPart.setContent(String.format("Please the attached %s report.", exportType), "text/plain");

        MimeBodyPart attachmentBodyPart = new MimeBodyPart();
        attachmentBodyPart.setDataHandler(new DataHandler(new ByteArrayDataSource(bytes, exportType.getMimeType())));
        attachmentBodyPart.setFileName(String.format("export.%s", exportType.getFileExtension()));

        Multipart multipart = new MimeMultipart();
        multipart.addBodyPart(msgBodyPart);
        multipart.addBodyPart(attachmentBodyPart);

        Session session = Session.getDefaultInstance(prop);

        Message message = new MimeMessage(session);
        message.setFrom(fromAddress);
        message.setRecipients(Message.RecipientType.TO, new InternetAddress[]{toAddress});
        message.setSubject(String.format("%s delivery", reportType.getDisplayName()));
        message.setContent(multipart);

        Transport.send(message);
    } catch (MessagingException ex) {
        throw new ReportDeliveryException("Problem while delivering report export.", ex);
    }
}