use of org.wso2.carbon.apimgt.api.doc.model.Operation in project carbon-business-process by wso2.
the class HumanTaskPackageManagementSkeleton method listTasksInPackage.
/**
* Lists the tasks in the given package name.
*
* @param packageName : The name of the package to list task definitions.
* @return : The Task_type0 array containing the task definition information.
*/
public Task_type0[] listTasksInPackage(String packageName) throws PackageManagementException {
if (StringUtils.isEmpty(packageName)) {
throw new IllegalArgumentException("The provided package name is empty!");
}
try {
List<SimpleTaskDefinitionInfo> taskDefsInPackage = getTenantTaskStore().getTaskConfigurationInfoListForPackage(packageName);
Task_type0[] taskDefArray = new Task_type0[taskDefsInPackage.size()];
int i = 0;
for (SimpleTaskDefinitionInfo taskDefinitionInfo : taskDefsInPackage) {
taskDefArray[i] = createTaskTypeObject(taskDefinitionInfo);
i++;
}
return taskDefArray;
} catch (Exception ex) {
String errMsg = "listTasksInPackage operation failed";
log.error(errMsg, ex);
throw new PackageManagementException(errMsg, ex);
}
}
use of org.wso2.carbon.apimgt.api.doc.model.Operation in project carbon-business-process by wso2.
the class CallBackServiceImpl method sendProtocolMessage.
private void sendProtocolMessage(long taskID, String headerValue, String value) throws AxisFault {
final MessageContext mctx = new MessageContext();
ServiceInvocationContext invocationContext = new ServiceInvocationContext();
invocationContext.setInMessageContext(mctx);
invocationContext.setUep(uep);
invocationContext.setService(serviceName);
invocationContext.setPort(portName);
invocationContext.setCaller(taskName.getLocalPart());
invocationContext.setWsdlBindingForCurrentMessageFlow(binding);
invocationContext.setOperationName(operation);
if (mctx.getEnvelope() == null) {
mctx.setEnvelope(getSoapFactory().createSOAPEnvelope());
}
if (mctx.getEnvelope().getBody() == null) {
getSoapFactory().createSOAPBody(mctx.getEnvelope());
}
if (mctx.getEnvelope().getHeader() == null) {
getSoapFactory().createSOAPHeader(mctx.getEnvelope());
}
// Creating Dummy Element
// Extracting MessageName
List bindingOperations = binding.getBindingOperations();
String messageName = "";
OMNamespace serviceNS = null;
BindingOperation oper;
for (int i = 0; i < bindingOperations.size(); i++) {
oper = (BindingOperation) bindingOperations.get(i);
if (operation.equals(oper.getName())) {
Message message = oper.getOperation().getInput().getMessage();
messageName = message.getQName().getLocalPart();
for (Object ob : message.getParts().keySet()) {
// Here we don't support RPC messages.
Part part = (Part) message.getParts().get(ob);
serviceNS = OMAbstractFactory.getSOAP11Factory().createOMNamespace(part.getElementName().getNamespaceURI(), part.getElementName().getPrefix());
break;
}
break;
}
}
OMElement payload = OMAbstractFactory.getOMFactory().createOMElement(messageName, serviceNS);
mctx.getEnvelope().getBody().addChild(payload);
OMNamespace htpNS = OMAbstractFactory.getSOAP11Factory().createOMNamespace(HumanTaskConstants.HT_PROTOCOL_NAMESPACE, HumanTaskConstants.HT_PROTOCOL_DEFAULT_PREFIX);
SOAPHeaderBlock protocolHeader = mctx.getEnvelope().getHeader().addHeaderBlock(headerValue, htpNS);
protocolHeader.setText(value);
protocolHeader.addAttribute(HumanTaskConstants.B4P_CORRELATION_HEADER_ATTRIBUTE, Long.toString(taskID), htpNS);
OMNamespace b4pNS = OMAbstractFactory.getSOAP11Factory().createOMNamespace(HumanTaskConstants.B4P_NAMESPACE, "b4p");
SOAPHeaderBlock header = mctx.getEnvelope().getHeader().addHeaderBlock(HumanTaskConstants.B4P_CORRELATION_HEADER, b4pNS);
header.addAttribute(HumanTaskConstants.B4P_CORRELATION_HEADER_ATTRIBUTE, Long.toString(taskID), b4pNS);
AxisServiceUtils.invokeService(invocationContext, HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(tenantId).getConfigContext());
}
use of org.wso2.carbon.apimgt.api.doc.model.Operation in project carbon-business-process by wso2.
the class CallBackServiceImpl method invoke.
@Override
public void invoke(OMElement payload, long taskId) throws AxisFault {
final MessageContext mctx = new MessageContext();
ServiceInvocationContext invocationContext = new ServiceInvocationContext();
invocationContext.setInMessageContext(mctx);
invocationContext.setUep(uep);
invocationContext.setService(serviceName);
invocationContext.setPort(portName);
invocationContext.setCaller(taskName.getLocalPart());
invocationContext.setWsdlBindingForCurrentMessageFlow(binding);
invocationContext.setOperationName(operation);
if (mctx.getEnvelope() == null) {
mctx.setEnvelope(getSoapFactory().createSOAPEnvelope());
}
if (mctx.getEnvelope().getBody() == null) {
getSoapFactory().createSOAPBody(mctx.getEnvelope());
}
if (mctx.getEnvelope().getHeader() == null) {
getSoapFactory().createSOAPHeader(mctx.getEnvelope());
}
mctx.getEnvelope().getBody().addChild(payload);
OMNamespace ns = OMAbstractFactory.getSOAP11Factory().createOMNamespace(HumanTaskConstants.B4P_NAMESPACE, "b4p");
SOAPHeaderBlock header = mctx.getEnvelope().getHeader().addHeaderBlock(HumanTaskConstants.B4P_CORRELATION_HEADER, ns);
header.addAttribute(HumanTaskConstants.B4P_CORRELATION_HEADER_ATTRIBUTE, Long.toString(taskId), ns);
AxisServiceUtils.invokeService(invocationContext, HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(tenantId).getConfigContext());
}
use of org.wso2.carbon.apimgt.api.doc.model.Operation in project carbon-business-process by wso2.
the class AttachmentMgtDAOFactoryImpl method removeAttachment.
@Override
public boolean removeAttachment(final String id) throws AttachmentMgtException {
try {
boolean isRemoved = false;
isRemoved = jobExecutor.execTransaction(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
Query query = entityManager.createQuery("DELETE FROM org.wso2.carbon.attachment.mgt.core.dao.impl" + ".jpa.openjpa.entity.AttachmentDAOImpl x WHERE x.id = " + ":attachmentID");
query.setParameter("attachmentID", Long.parseLong(id));
int noOfRowsUpdated = query.executeUpdate();
// entityManager.remove(getAttachmentInfo(id));
if (noOfRowsUpdated == 1) {
return true;
} else {
return false;
}
}
});
return isRemoved;
} catch (Exception e) {
String errorMsg = "org.wso2.carbon.attachment.mgt.core.dao.impl.hibernate.AttachmentMgtDAOFactoryImpl.removeAttachment operation failed. " + "Reason: " + e.getLocalizedMessage();
log.error(errorMsg, e);
throw new AttachmentMgtException(errorMsg, e);
}
}
use of org.wso2.carbon.apimgt.api.doc.model.Operation in project carbon-business-process by wso2.
the class AttachmentMgtDAOFactoryImpl method getAttachmentInfoFromURL.
@Override
public AttachmentDAO getAttachmentInfoFromURL(final String attachmentURI) throws AttachmentMgtException {
try {
AttachmentDAO resultantDAO = jobExecutor.execTransaction(new Callable<AttachmentDAO>() {
@Override
public AttachmentDAO call() throws Exception {
Query query = entityManager.createQuery("SELECT x FROM org.wso2.carbon.attachment.mgt.core.dao.impl.jpa.openjpa.entity.AttachmentDAOImpl AS x WHERE x.url = :attachmentURI");
query.setParameter("attachmentURI", attachmentURI);
List<AttachmentDAO> daoList = query.getResultList();
if (daoList.isEmpty()) {
throw new AttachmentMgtException("Attachment not found for the uri:" + attachmentURI);
} else if (daoList.size() != 1) {
String errorMsg = "There exist more than one attachment for the attachment URI:" + attachmentURI + ". org" + ".wso2.carbon.attachment.mgt.util.URLGeneratorUtil.generateURL method has generated " + "similar uris for different attachments. This has caused a major inconsistency for " + "attachment management.";
log.fatal(errorMsg);
throw new AttachmentMgtException(errorMsg);
} else {
return daoList.get(0);
}
}
});
return resultantDAO;
} catch (Exception e) {
String errorMsg = "org.wso2.carbon.attachment.mgt.core.dao.impl.hibernate.AttachmentMgtDAOFactoryImpl.getAttachmentInfoFromURL operation failed. " + "Reason: " + e.getLocalizedMessage();
log.error(errorMsg, e);
throw new AttachmentMgtException(errorMsg, e);
}
}
Aggregations