use of org.wso2.carbon.attachment.mgt.stub.AttachmentMgtServiceStub in project carbon-business-process by wso2.
the class SampleAttachmentMgtClient method uploadAttachment.
private static String uploadAttachment() throws RemoteException, AttachmentMgtException {
AttachmentMgtServiceStub stub = new AttachmentMgtServiceStub();
Options options = new Options();
options.setTo(new EndpointReference("http://127.0.0.1:9763/services/AttachmentMgtService/"));
options.setProperty(Constants.Configuration.ENABLE_MTOM, Boolean.TRUE);
stub._getServiceClient().setOptions(options);
TAttachment att = new TAttachment();
// att.setId("ContentId");
// att.setCreatedTime(Calendar.getInstance());
att.setName("ContentName");
att.setCreatedBy("DenisAuthor");
att.setContentType("text/plain");
// FileDataSource dataSource = new FileDataSource(new File("/home/denis/Desktop/note.txt"));
FileDataSource dataSource = new FileDataSource(new File("/home/denis/Desktop/fromSoapUI.xml"));
DataHandler fileDataHandler = new DataHandler(dataSource);
att.setContent(fileDataHandler);
String id = stub.add(att);
if (log.isDebugEnabled()) {
log.debug("Attachment uploaded with id: " + id);
}
return id;
}
use of org.wso2.carbon.attachment.mgt.stub.AttachmentMgtServiceStub in project carbon-business-process by wso2.
the class SampleAttachmentMgtClient method getAttachmentInfo.
private static void getAttachmentInfo(String id) throws RemoteException, AttachmentMgtException {
AttachmentMgtServiceStub stub = new AttachmentMgtServiceStub();
Options options = new Options();
options.setTo(new EndpointReference("http://127.0.0.1:9763/services/AttachmentMgtService/"));
options.setProperty(Constants.Configuration.ENABLE_MTOM, Boolean.TRUE);
stub._getServiceClient().setOptions(options);
TAttachment attachment = stub.getAttachmentInfo(id);
if (log.isDebugEnabled()) {
log.debug("Attachment details received. Id: " + attachment.getId());
}
}
use of org.wso2.carbon.attachment.mgt.stub.AttachmentMgtServiceStub in project carbon-business-process by wso2.
the class SampleAttachmentMgtClient method removeAttachment.
private static void removeAttachment(String id) throws RemoteException, AttachmentMgtException {
AttachmentMgtServiceStub stub = new AttachmentMgtServiceStub();
Options options = new Options();
options.setTo(new EndpointReference("http://127.0.0.1:9763/services/AttachmentMgtService/"));
options.setProperty(Constants.Configuration.ENABLE_MTOM, Boolean.TRUE);
stub._getServiceClient().setOptions(options);
if (log.isDebugEnabled()) {
log.debug("Attachment removed status:" + stub.remove(id));
}
}
Aggregations