use of org.wso2.carbon.attachment.mgt.stub.types.TAttachment in project carbon-business-process by wso2.
the class AttachmentMgtDAOBasicOperationsTest method testAttachmentDAOGetInfoFromURLTest.
/**
* This method tests whether it's possible to get the attachment-info for a given attachment url
*/
public void testAttachmentDAOGetInfoFromURLTest() {
AttachmentManagerService service = new AttachmentManagerService();
try {
// Request for the attachment using the attachment id
TAttachment attachmentFromID = service.getAttachmentInfo(attachmentID);
// request for the attachment using attachment url
TAttachment attachmentFromURL = service.getAttachmentInfoFromURL(attachmentFromID.getUrl().toString());
assertEquals(attachmentFromID.getId(), attachmentFromURL.getId());
log.info("Attachment information retrieved for uri : " + attachmentFromURL.getUrl().toString());
} catch (AttachmentMgtException e) {
log.error(e.getLocalizedMessage(), e);
Assert.fail("Attachment information retrieval failed due to reason: " + e.getLocalizedMessage());
}
}
use of org.wso2.carbon.attachment.mgt.stub.types.TAttachment in project carbon-business-process by wso2.
the class AttachmentMgtDAOBasicOperationsTest method testAttachmentDAOGetInfoTest.
/**
* This method tests whether it's possible to get the attachment-info for a given attachment id
*/
public void testAttachmentDAOGetInfoTest() {
AttachmentManagerService service = new AttachmentManagerService();
try {
TAttachment attachment = service.getAttachmentInfo(attachmentID);
dummyAttachment = createAttachment();
assertEquals(dummyAttachment.getName(), attachment.getName());
assertEquals(dummyAttachment.getCreatedBy(), attachment.getCreatedBy());
assertEquals(dummyAttachment.getContentType(), attachment.getContentType());
log.info("Attachment information retrieved for id : " + attachment.getId());
} catch (AttachmentMgtException e) {
log.error(e.getLocalizedMessage(), e);
Assert.fail("Attachment information retrieval failed due to reason: " + e.getLocalizedMessage());
}
}
use of org.wso2.carbon.attachment.mgt.stub.types.TAttachment in project carbon-business-process by wso2.
the class AttachmentManagerService method add.
/**
* {@inheritDoc}
*/
@Override
public String add(final TAttachment attachment) throws AttachmentMgtException {
if (log.isDebugEnabled() && attachment != null) {
log.debug("Saving the attachment with id " + attachment.getId());
}
try {
Attachment att = TransformerUtil.convertAttachment(attachment);
// 1. get Att-Mgt DAO Conn factory
// 2. get Att-Mgt DAO Connection
// 3. addAttachment
// getDaoConnectionFactory().getDAOConnection().addAttachment(att);
AttachmentDAO daoImpl = getDaoConnectionFactory().getDAOConnection().getAttachmentMgtDAOFactory().addAttachment(att);
return daoImpl.getID().toString();
} catch (org.wso2.carbon.attachment.mgt.core.exceptions.AttachmentMgtException ex) {
String errMsg = "org.wso2.carbon.attachment.mgt.core.service.AttachmentManagerService.add " + "operation failed. Reason:" + ex.getLocalizedMessage();
log.error(errMsg, ex);
throw new AttachmentMgtException(errMsg, ex);
}
}
use of org.wso2.carbon.attachment.mgt.stub.types.TAttachment in project carbon-business-process by wso2.
the class BPELMessageReceiver method createAttachmentDTO.
private TAttachment createAttachmentDTO(DataHandler attachmentHandler) {
TAttachment attachment = new TAttachment();
String attachmentName = attachmentHandler.getName();
attachment.setName(attachmentName);
log.warn("Couldn't determine the name of BPEL client. So the owner of the attachment:" + attachmentName + " " + "will be the default bpel client" + org.wso2.carbon.bpel.core.BPELConstants.DAFAULT_BPEL_CLIENT);
attachment.setCreatedBy(org.wso2.carbon.bpel.core.BPELConstants.DAFAULT_BPEL_CLIENT);
attachment.setContentType(attachmentHandler.getContentType());
// As well there are some other parameters to be set.
attachment.setContent(attachmentHandler);
return attachment;
}
Aggregations