use of org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException in project carbon-business-process by wso2.
the class AttachmentMgtDAOTransformerFactoryImpl method convertAttachment.
@Override
public AttachmentDAO convertAttachment(Attachment attachment) throws AttachmentMgtException {
AttachmentDAO attachmentDAO = new AttachmentDAOImpl();
attachmentDAO.setName(attachment.getName());
attachmentDAO.setCreatedBy(attachment.getCreatedBy());
attachmentDAO.setContent(attachment.getContent());
attachmentDAO.setContentType(attachment.getContentType());
return attachmentDAO;
}
use of org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException in project carbon-business-process by wso2.
the class AttachmentManagerService method getAttachmentInfoFromURL.
/**
* {@inheritDoc}
*/
@Override
public TAttachment getAttachmentInfoFromURL(final String attachmentURL) throws AttachmentMgtException {
try {
// Extracting the attachment uri
String attachmentUniqueID = attachmentURL.substring(attachmentURL.lastIndexOf("/") + 1);
AttachmentDAO attachmentDAO = getDaoConnectionFactory().getDAOConnection().getAttachmentMgtDAOFactory().getAttachmentInfoFromURL(attachmentUniqueID);
Attachment attachment = getDaoTransformFactory().convertAttachment(attachmentDAO);
return TransformerUtil.convertAttachment(attachment);
} catch (org.wso2.carbon.attachment.mgt.core.exceptions.AttachmentMgtException e) {
String errorMsg = "org.wso2.carbon.attachment.mgt.core.service.AttachmentManagerService.getAttachmentInfoFromURL operation failed. " + "Reason:" + e.getLocalizedMessage();
log.error(errorMsg, e);
throw new AttachmentMgtException(errorMsg, e);
}
}
use of org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException in project carbon-business-process by wso2.
the class AttachmentManagerService method getAttachmentInfo.
/**
* {@inheritDoc}
*/
@Override
public TAttachment getAttachmentInfo(final String id) throws AttachmentMgtException {
try {
AttachmentDAO attachmentDAO = getDaoConnectionFactory().getDAOConnection().getAttachmentMgtDAOFactory().getAttachmentInfo(id);
Attachment attachment = getDaoTransformFactory().convertAttachment(attachmentDAO);
return TransformerUtil.convertAttachment(attachment);
} catch (org.wso2.carbon.attachment.mgt.core.exceptions.AttachmentMgtException e) {
String errorMsg = "org.wso2.carbon.attachment.mgt.core.service" + ".AttachmentManagerService.getAttachmentInfo operation failed. " + "Reason:" + e.getLocalizedMessage();
log.error(errorMsg, e);
throw new AttachmentMgtException(errorMsg, e);
}
}
use of org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException in project carbon-business-process by wso2.
the class AttachmentUploadClient method addUploadedFileItem.
public void addUploadedFileItem(FileItemData fileItemData) throws AttachmentMgtException, RemoteException {
DataHandler handler = fileItemData.getDataHandler();
TAttachment attachment = new TAttachment();
attachment.setName(handler.getName());
attachment.setContentType(handler.getContentType());
// TODO: Remove this hard-coded value
attachment.setCreatedBy("DummyUser");
attachment.setContent(fileItemData.getDataHandler());
String attachmentID = stub.add(attachment);
log.info("Attachment was uploaded with id:" + attachmentID);
}
use of org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException 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;
}
Aggregations