List of usage examples for javax.activation DataHandler getName
public String getName()
From source file:org.wso2.carbon.admin.service.AdminServiceResourceAdmin.java
public void addWSDL(String sessionCookie, String description, DataHandler dh) throws RemoteException, ExceptionException { String fileName;/*from w w w . j a va 2 s . c o m*/ new AuthenticateStub().authenticateStub(sessionCookie, resourceAdminServiceStub); fileName = dh.getName().substring(dh.getName().lastIndexOf('/') + 1); resourceAdminServiceStub.addResource("/" + fileName, MEDIA_TYPE_WSDL, description, dh, null); log.info("Resource Added"); }
From source file:org.wso2.carbon.admin.service.AdminServiceResourceAdmin.java
public void addSchema(String sessionCookie, String description, DataHandler dh) throws RemoteException, ExceptionException { String fileName;//w w w .jav a 2 s. c o m new AuthenticateStub().authenticateStub(sessionCookie, resourceAdminServiceStub); fileName = dh.getName().substring(dh.getName().lastIndexOf('/') + 1); resourceAdminServiceStub.addResource("/" + fileName, MEDIA_TYPE_SCHEMA, description, dh, null); log.info("Resource Added"); }
From source file:org.wso2.carbon.admin.service.AdminServiceResourceAdmin.java
public void addPolicy(String sessionCookie, String description, DataHandler dh) throws RemoteException, ExceptionException { String fileName;/* w w w . ja va2s .com*/ new AuthenticateStub().authenticateStub(sessionCookie, resourceAdminServiceStub); fileName = dh.getName().substring(dh.getName().lastIndexOf('/') + 1); resourceAdminServiceStub.addResource("/" + fileName, MEDIA_TYPE_POLICY, description, dh, null); log.info("Resource Added"); }
From source file:org.wso2.carbon.admin.service.AdminServiceResourceAdmin.java
public void uploadArtifact(String sessionCookie, String description, DataHandler dh) throws RemoteException, ExceptionException { String fileName;// w w w . jav a 2 s. c o m new AuthenticateStub().authenticateStub(sessionCookie, resourceAdminServiceStub); fileName = dh.getName().substring(dh.getName().lastIndexOf('/') + 1); resourceAdminServiceStub.addResource("/" + fileName, MEDIA_TYPE_GOVERNANCE_ARCHIVE, description, dh, null); log.info("Resource Added"); }
From source file:org.mule.transport.email.transformers.ObjectToMimeMessage.java
protected BodyPart getBodyPartForAttachment(DataHandler handler, String name) throws MessagingException { BodyPart part = new MimeBodyPart(); part.setDataHandler(handler);//from w w w . ja v a 2s. c o m part.setDescription(name); part.setFileName(StringUtils.defaultString(handler.getName(), name)); return part; }
From source file:org.wso2.ds.integration.common.clients.ResourceAdminServiceClient.java
public void addWSDL(String description, DataHandler dh) throws ResourceAdminServiceExceptionException, RemoteException { String fileName;/* www .j a va 2 s . co m*/ fileName = dh.getName().substring(dh.getName().lastIndexOf('/') + 1); log.debug(fileName); resourceAdminServiceStub.addResource("/" + fileName, MEDIA_TYPE_WSDL, description, dh, null, null); }
From source file:org.wso2.ds.integration.common.clients.ResourceAdminServiceClient.java
public void addWADL(String description, DataHandler dh) throws ResourceAdminServiceExceptionException, RemoteException { String fileName;/* w ww . j av a 2s . co m*/ fileName = dh.getName().substring(dh.getName().lastIndexOf('/') + 1); log.debug(fileName); resourceAdminServiceStub.addResource("/" + fileName, MEDIA_TYPE_WADL, description, dh, null, null); }
From source file:org.wso2.appserver.integration.common.clients.ResourceAdminServiceClient.java
public void addSwagger(String description, DataHandler dh) throws ResourceAdminServiceExceptionException, RemoteException { String fileName;/*from ww w . j av a 2s . co m*/ fileName = dh.getName().substring(dh.getName().lastIndexOf('/') + 1); resourceAdminServiceStub.addResource("/" + fileName, MEDIA_TYPE_SWAGGER, description, dh, null, null); }
From source file:se.inera.axel.shs.camel.CamelShsDataPartConverterTest.java
@DirtiesContext @Test/*from w w w. j av a2s .c o m*/ public void convertCamelMessageToDataPartWithCharsetHeaderAndFilenameInContentType() throws Exception { resultEndpoint.expectedMessageCount(1); String message = DEFAULT_TEST_BODY; Map<String, Object> headers = new HashMap<String, Object>(); headers.put(ShsHeaders.DATAPART_TRANSFERENCODING, DEFAULT_TEST_DATAPART_TRANSFERENCODING); headers.put(ShsHeaders.DATAPART_CONTENTTYPE, DEFAULT_TEST_DATAPART_CONTENTTYPE + ";name=" + DEFAULT_TEST_DATAPART_FILENAME); headers.put(ShsHeaders.DATAPART_CONTENTLENGTH, message.length()); headers.put(ShsHeaders.DATAPART_TYPE, DEFAULT_TEST_DATAPART_TYPE); headers.put(Exchange.CHARSET_NAME, "iso-8859-1"); template.sendBodyAndHeaders("direct:camelToShsConverter", message, headers); resultEndpoint.assertIsSatisfied(); List<Exchange> exchanges = resultEndpoint.getExchanges(); Exchange exchange = exchanges.get(0); Message in = exchange.getIn(); DataPart datapart = in.getMandatoryBody(DataPart.class); assertNotNull(datapart); assertEquals((long) datapart.getContentLength(), message.length()); assertTrue(datapart.getContentType().contains("charset=iso-8859-1")); assertTrue(datapart.getContentType().contains("name=" + DEFAULT_TEST_DATAPART_FILENAME)); assertEquals(datapart.getDataPartType(), DEFAULT_TEST_DATAPART_TYPE); assertEquals(datapart.getFileName(), DEFAULT_TEST_DATAPART_FILENAME); assertEquals(datapart.getTransferEncoding(), DEFAULT_TEST_DATAPART_TRANSFERENCODING); assertNotNull(datapart.getDataHandler()); DataHandler dataHandler = datapart.getDataHandler(); assertEquals(dataHandler.getName(), DEFAULT_TEST_DATAPART_FILENAME); assertEquals(dataHandler.getContent(), DEFAULT_TEST_BODY); }
From source file:de.extra_standard.namespace.webservice.ExtraServiceImpl.java
@Override @WebMethod(action = "http://www.extra-standard.de/namespace/webservice/execute") @WebResult(name = "Transport", targetNamespace = "http://www.extra-standard.de/namespace/response/1", partName = "response") public ResponseTransport execute( @WebParam(name = "Transport", targetNamespace = "http://www.extra-standard.de/namespace/request/1", partName = "request") final de.drv.dsrv.extrastandard.namespace.request.RequestTransport request) throws ExtraFault { try {/*from www . j av a2 s .c om*/ logger.info("receive Extra ResponseTransport"); final Base64CharSequenceType base64CharSequence = request.getTransportBody().getData() .getBase64CharSequence(); final DataHandler dataHandler = base64CharSequence.getValue(); final InputStream inputStream = dataHandler.getInputStream(); final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); final String dateSuffix = sdf.format(new Date(System.currentTimeMillis())); final String dataHandlerName = dataHandler.getName(); logger.info("Receiving File : " + dataHandlerName); final File receivedFile = new File(outputDirectory, dataHandlerName + "_" + dateSuffix); final FileOutputStream fileOutputStream = new FileOutputStream(receivedFile); IOUtils.copyLarge(inputStream, fileOutputStream); logger.info("Input file is stored under " + receivedFile.getAbsolutePath()); logger.info("ChecksumCRC32 " + FileUtils.checksumCRC32(receivedFile)); logger.info("Filesize: " + FileUtils.sizeOf(receivedFile)); } catch (final IOException e) { logger.error("IOException in Server:", e); } // TODO TestTransport erzeugen!! final ResponseTransport responseTransport = new ResponseTransport(); final ResponseTransportBody responseTransportBody = new ResponseTransportBody(); final DataType dataType = new DataType(); final Base64CharSequenceType base64CharSequenceType = new Base64CharSequenceType(); final DataSource ds = new FileDataSource(testDataFile); final DataHandler dataHandler = new DataHandler(ds); base64CharSequenceType.setValue(dataHandler); dataType.setBase64CharSequence(base64CharSequenceType); responseTransportBody.setData(dataType); responseTransport.setTransportBody(responseTransportBody); return responseTransport; }