List of usage examples for javax.activation FileDataSource FileDataSource
public FileDataSource(String name)
From source file:org.wso2.brs.rule.test.CallChargingTestCase.java
@Test(groups = { "wso2.brs" }) public void uploadCallChargingService() throws Exception { String samplesDir = System.getProperty("samples.dir"); String CallChargingServiceAAR = samplesDir + File.separator + "callcharging.service/service/target/CallChargingService.aar"; log.info(CallChargingServiceAAR);/* w ww . ja v a 2 s. co m*/ FileDataSource fileDataSource = new FileDataSource(CallChargingServiceAAR); DataHandler dataHandler = new DataHandler(fileDataSource); getRuleServiceFileUploadClient().uploadService("CallChargingService.aar", dataHandler); }
From source file:org.wso2.carbon.appfactory.core.retrieve.RetrieveArtifactService.java
/** * * @param applicationId Application ID//w ww. j a va 2 s .co m * @param version Application Version * @param revision Application revision * @param tenantDomain Tenant domain of application * @return {@link DataHandler} */ public DataHandler retrieveArtifact(String applicationId, String version, String revision, String tenantDomain) { String fileName = null; File file = null; ArtifactStorage storage = ServiceHolder.getArtifactStorage(); try { file = storage.retrieveArtifact(applicationId, version, revision, tenantDomain); fileName = file.getAbsolutePath(); } catch (AppFactoryException e) { e.printStackTrace(); } FileDataSource dataSource = new FileDataSource(fileName); DataHandler fileDataHandler = new DataHandler(dataSource); return fileDataHandler; }
From source file:org.wso2.brs.rule.test.OrderApprovalTestCase.java
@Test(groups = { "wso2.brs" }) public void uploadOrderApprovalService() throws Exception { String samplesDir = System.getProperty("samples.dir"); String OrderApprovalServiceAAR = samplesDir + File.separator + "orderApproval.service/service/target/OrderApprovalService.aar"; log.info(OrderApprovalServiceAAR);// w w w.j a v a 2 s . c om FileDataSource fileDataSource = new FileDataSource(OrderApprovalServiceAAR); DataHandler dataHandler = new DataHandler(fileDataSource); getRuleServiceFileUploadClient().uploadService("OrderApprovalService.aar", dataHandler); }
From source file:org.wso2.brs.rule.test.GreetingServiceTestCase.java
@Test(groups = { "wso2.brs" }) public void uploadGreetingService() throws Exception { String samplesDir = System.getProperty("samples.dir"); String greetingServiceAAR = samplesDir + File.separator + "greeting.service/service/target/GreetingService.aar"; log.info(greetingServiceAAR);//from w ww .ja v a 2 s. c om FileDataSource fileDataSource = new FileDataSource(greetingServiceAAR); DataHandler dataHandler = new DataHandler(fileDataSource); getRuleServiceFileUploadClient().uploadService("GreetingService.aar", dataHandler); }
From source file:org.onesec.raven.ivr.vmail.impl.VMailBoxNodeTest.java
@Test public void addMessageTest() throws Exception { Date date = new Date(); vbox.addMessage(new NewVMailMessageImpl("123", "222", date, new FileDataSource(testFile))); String filename = new SimpleDateFormat(VMailBoxNode.DATE_PATTERN).format(date) + "-" + "222.wav"; File messFile = new File(manager.getVMailBoxDir(vbox).getNewMessagesDir() + File.separator + filename); assertTrue(messFile.exists());// w w w .j a va 2s . co m assertTrue(FileUtils.contentEquals(testFile, messFile)); }
From source file:com.yosanai.tutorial.ws.hellowebservice.WebServiceTest.java
@Test public void callUpload() throws Exception { File file = new File(); java.io.File fileToUpload = new java.io.File("src/test/resources/icons.jpg"); file.setFileName(fileToUpload.getName()); FileDataSource fileDataSource = new FileDataSource(fileToUpload); DataHandler fileContent = new DataHandler(fileDataSource); file.setFileContent(fileContent);//from w w w.ja v a 2 s .co m System.out.println(fileManagement.upload(file)); }
From source file:ebay.dts.client.FileTransferActions.java
public void uploadFile(String xmlFile, String jobId, String fileReferenceId) throws EbayConnectorException { String callName = "uploadFile"; try {/* w w w . ja v a 2 s . c o m*/ String compressedFileName = compressFileToGzip(xmlFile); if (compressedFileName == null) { logger.error("Failed to compress your XML file into gzip file. Aborted"); throw new EbayConnectorException("Failed to compress your XML file into gzip file. Aborted"); } FileTransferServicePort port = call.setFTSMessageContext(callName); UploadFileRequest request = new UploadFileRequest(); FileAttachment attachment = new FileAttachment(); File fileToUpload = new File(compressedFileName); DataHandler dh = new DataHandler(new FileDataSource(fileToUpload)); attachment.setData(dh); attachment.setSize(fileToUpload.length()); String fileFormat = "gzip"; request.setFileFormat(fileFormat); /* * For instance, the Bulk Data Exchange Service uses a job ID as a * primary identifier, so, if you're using the Bulk Data Exchange * Service, enter the job ID as the taskReferenceId. */ request.setTaskReferenceId(jobId); request.setFileReferenceId(fileReferenceId); request.setFileAttachment(attachment); // request. if (port != null && request != null) { UploadFileResponse response = port.uploadFile(request); if (response.getAck().equals(AckValue.SUCCESS)) { return; } else { logger.error(response.getErrorMessage().getError().get(0).getMessage()); throw new EbayConnectorException(response.getErrorMessage().getError().get(0).getMessage()); } } } catch (Exception e) { logger.error(e.getMessage()); throw new EbayConnectorException(e.getMessage()); } }
From source file:stg.pr.engine.mailer.SmallEmailAttachment.java
/** * Constructs an email attachment with the given name and the file. * @param name of the file that will get associated with the email. * @param file to be attached.// w w w .j a v a 2s . c om * @throws IOException */ public SmallEmailAttachment(String name, File file) throws IOException { super(name, file); //this will throw exception in case the file does not exist if (file.length() > EMailAttachment.SMALL_SIZE.longValue()) { throw new IllegalArgumentException("Small email attachments are for file size < " + EMailAttachment.SMALL_SIZE.longValue() + " bytes."); } FileDataSource fds = new FileDataSource(file); contentType = fds.getContentType(); bytes = FileUtils.readFileToByteArray(file); }
From source file:org.wso2.brs.rule.test.GetQuoteServiceTestCase.java
@Test(groups = { "wso2.brs" }) public void uploadGetQuoteService() throws Exception { String samplesDir = System.getProperty("samples.dir"); String GetQuoteServiceAAR = samplesDir + File.separator + "quotation.service/service/target/GetQuoteService.aar"; log.info(GetQuoteServiceAAR);/* w w w . j ava 2s. c o m*/ FileDataSource fileDataSource = new FileDataSource(GetQuoteServiceAAR); DataHandler dataHandler = new DataHandler(fileDataSource); getRuleServiceFileUploadClient().uploadService("GetQuoteService.aar", dataHandler); }
From source file:org.wso2.brs.rule.test.MIPCalculateServiceTestCase.java
@Test(groups = { "wso2.brs" }) public void uploadMIPCalculateService() throws Exception { String samplesDir = System.getProperty("samples.dir"); String MIPCalculateServiceAAR = samplesDir + File.separator + "MIPCalculate.service/service/target/MIPCalculateService.aar"; log.info(MIPCalculateServiceAAR);// w w w .j a va2 s . co m FileDataSource fileDataSource = new FileDataSource(MIPCalculateServiceAAR); DataHandler dataHandler = new DataHandler(fileDataSource); getRuleServiceFileUploadClient().uploadService("MIPCalculateService.aar", dataHandler); }