use of org.wso2.carbon.apimgt.api.model.Identifier in project carbon-business-process by wso2.
the class TaskOperationsImpl method deleteOutput.
/**
* Deletes the output data of the task.
* @param taskIdURI : task identifier
* @throws IllegalStateFault
* @throws IllegalOperationFault
* @throws IllegalArgumentFault
* @throws IllegalAccessFault
*/
public void deleteOutput(final URI taskIdURI) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
try {
final Long taskId = validateTaskId(taskIdURI);
HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {
public Object call() throws Exception {
DeleteOutput deleteOutput = new DeleteOutput(getCaller(), taskId);
deleteOutput.execute();
return null;
}
});
} catch (Exception ex) {
handleException(ex);
}
}
use of org.wso2.carbon.apimgt.api.model.Identifier in project carbon-business-process by wso2.
the class RegistrationService method registerOperation.
@Override
public RegisterResponseType registerOperation(URI uri, EndpointReferenceType endpointReferenceType, OMElement[] omElements) {
if (!CoordinationConfiguration.getInstance().isRegistrationServiceEnabled()) {
log.warn("Registration request is discarded. Registration service is disabled in this server");
return null;
}
if (log.isDebugEnabled()) {
log.debug("Registration request received.");
}
URI htIdentifierURI = null;
try {
htIdentifierURI = new URI(HT_COORDINATION_PROTOCOL);
} catch (URI.MalformedURIException e) {
log.error(e);
}
if (!htIdentifierURI.equals(uri)) {
String errorMsg = "Received an invalid Protocol identifier: " + uri.toString();
log.error(errorMsg);
return null;
}
String participantProtocolService = "";
if (endpointReferenceType != null && endpointReferenceType.getAddress() != null) {
participantProtocolService = endpointReferenceType.getAddress().toString();
} else {
String errorMsg = "Received an invalid Participant Protocol Service";
log.error(errorMsg);
}
String messageID = "";
boolean foundB4PMessageID = false;
if (omElements.length > 0) {
for (OMElement omElement : omElements) {
if (B4P_NAMESPACE.equals(omElement.getNamespace().getNamespaceURI()) && B4P_IDENTIFIER.equals(omElement.getLocalName())) {
messageID = omElement.getText();
foundB4PMessageID = true;
break;
}
}
}
if (!foundB4PMessageID) {
String errorMsg = "no B4P messageID received";
log.error(errorMsg);
return null;
}
if (log.isDebugEnabled()) {
log.debug("Adding message ID: " + messageID + "-> " + participantProtocolService);
}
// Persisting data.
try {
persistData(messageID, participantProtocolService);
} catch (Exception e) {
log.error("Error occurred during persisting data", e);
return null;
}
// Sending Dummy Response.
RegisterResponseType responseType = new RegisterResponseType();
EndpointReferenceType epr = new EndpointReferenceType();
AttributedURI attributedURI = new AttributedURI();
URI b4pProtocolHandlerURI;
try {
// Setting Dummy Address here.
b4pProtocolHandlerURI = new URI(getB4PProtocolHandlerURI());
attributedURI.setAnyURI(b4pProtocolHandlerURI);
} catch (URI.MalformedURIException e) {
log.error("Error occurred while generating b4p protocol handler uri", e);
return null;
}
epr.setAddress(attributedURI);
OMFactory omFactory = OMAbstractFactory.getOMFactory();
OMNamespace b4pOMNamespace = omFactory.createOMNamespace(B4P_NAMESPACE, B4P_PREFIX);
// Dummy Endpoint
responseType.setCoordinatorProtocolService(epr);
OMElement identifierElement = omFactory.createOMElement(B4P_IDENTIFIER, b4pOMNamespace);
identifierElement.addChild(omFactory.createOMText(identifierElement, messageID));
responseType.addExtraElement(identifierElement);
return responseType;
}
use of org.wso2.carbon.apimgt.api.model.Identifier in project carbon-business-process by wso2.
the class SOAPHelper method addCoordinationContext.
/**
* Adding ws-Coordination context to soap request.
*
* @param msgCtx MessageContext
* @param messageID UUID as a WS-Coordination identifier
* @param registrationService URL of the ws-coordination registration service.
*/
public void addCoordinationContext(MessageContext msgCtx, String messageID, String registrationService) {
SOAPHeader header = msgCtx.getEnvelope().getHeader();
EndpointReference epr = new EndpointReference();
epr.setAddress(registrationService);
CoordinationContext context = new HumanTaskCoordinationContextImpl(messageID, epr);
header.addChild(context.toOM());
}
use of org.wso2.carbon.apimgt.api.model.Identifier in project carbon-business-process by wso2.
the class HTRenderingApiImpl method getRenderingInputElements.
/**
* @param taskIdentifier : interested task identifier
* @return set of input renderings wrapped within InputType
* @throws IllegalArgumentFault : error occured while retrieving renderings from task definition
* @throws IOException If an error occurred while reading from the input source
* @throws SAXException If the content in the input source is invalid
*/
private InputType getRenderingInputElements(URI taskIdentifier) throws IllegalArgumentFault, IOException, SAXException, IllegalOperationFault, IllegalAccessFault, IllegalStateFault, XPathExpressionException {
// TODO Chaching : check cache against task id for input renderings
QName renderingType = new QName(htRenderingNS, "input", "wso2");
String inputRenderings = (String) taskOps.getRendering(taskIdentifier, renderingType);
// Create input element
InputType renderingInputs = null;
// check availability of input renderings
if (inputRenderings != null && inputRenderings.length() > 0) {
// parse input renderings
Element inputRenderingsElement = DOMUtils.stringToDOM(inputRenderings);
// retrieve input elements
NodeList inputElementList = inputRenderingsElement.getElementsByTagNameNS(htRenderingNS, "element");
Element taskInputMsgElement = DOMUtils.stringToDOM((String) taskOps.getInput(taskIdentifier, null));
if (inputElementList != null && inputElementList.getLength() > 0) {
// hold number of input element
int inputElementNum = inputElementList.getLength();
InputElementType[] inputElements = new InputElementType[inputElementNum];
for (int i = 0; i < inputElementNum; i++) {
Element tempElement = (Element) inputElementList.item(i);
String label = tempElement.getElementsByTagNameNS(htRenderingNS, "label").item(0).getTextContent();
String value = tempElement.getElementsByTagNameNS(htRenderingNS, "value").item(0).getTextContent();
// if the value starts with '/' then considered as an xpath and evaluate over received Input Message
if (value.startsWith("/") && taskInputMsgElement != null) {
// value represents xpath. evaluate against the input message
String xpathValue = evaluateXPath(value, taskInputMsgElement, inputRenderingsElement.getOwnerDocument());
if (xpathValue != null) {
value = xpathValue;
}
}
inputElements[i] = new InputElementType();
inputElements[i].setLabel(label);
inputElements[i].setValue(value);
}
renderingInputs = new InputType();
renderingInputs.setElement(inputElements);
// TODO cache renderingInputs against task instance id
}
}
return renderingInputs;
}
use of org.wso2.carbon.apimgt.api.model.Identifier in project ballerina by ballerina-lang.
the class CodeGenerator method visit.
public void visit(BLangPackage pkgNode) {
if (pkgNode.completedPhases.contains(CompilerPhase.CODE_GEN)) {
if (!buildCompiledPackage) {
programFile.packageInfoMap.put(pkgNode.symbol.pkgID.bvmAlias(), pkgNode.symbol.packageInfo);
}
return;
}
// TODO Improve this design without if/else
PackageInfo packageInfo = new PackageInfo();
pkgNode.symbol.packageInfo = packageInfo;
if (buildCompiledPackage) {
// Generating the BALO
pkgNode.imports.forEach(impPkgNode -> {
int impPkgNameCPIndex = addUTF8CPEntry(packageInfo, impPkgNode.symbol.name.value);
// TODO Improve the import package version once it is available
int impPkgVersionCPIndex = addUTF8CPEntry(packageInfo, PackageID.DEFAULT.version.value);
ImportPackageInfo importPkgInfo = new ImportPackageInfo(impPkgNameCPIndex, impPkgVersionCPIndex);
packageInfo.importPkgInfoSet.add(importPkgInfo);
packageFile.packageInfo = packageInfo;
});
} else {
// Generating a BALX
// first visit all the imports
pkgNode.imports.forEach(impPkgNode -> genNode(impPkgNode, this.env));
// TODO We need to create identifier for both name and the version
programFile.packageInfoMap.put(pkgNode.symbol.pkgID.bvmAlias(), packageInfo);
}
// Add the current package to the program file
BPackageSymbol pkgSymbol = pkgNode.symbol;
currentPkgID = pkgSymbol.pkgID;
currentPkgInfo = packageInfo;
currentPkgInfo.nameCPIndex = addUTF8CPEntry(currentPkgInfo, currentPkgID.bvmAlias());
currentPkgInfo.versionCPIndex = addUTF8CPEntry(currentPkgInfo, currentPkgID.version.value);
// Insert the package reference to the constant pool of the current package
currentPackageRefCPIndex = addPackageRefCPEntry(currentPkgInfo, currentPkgID);
// This attribute keep track of line numbers
int lineNoAttrNameIndex = addUTF8CPEntry(currentPkgInfo, AttributeInfo.Kind.LINE_NUMBER_TABLE_ATTRIBUTE.value());
lineNoAttrInfo = new LineNumberTableAttributeInfo(lineNoAttrNameIndex);
// This attribute keep package-level variable information
int pkgVarAttrNameIndex = addUTF8CPEntry(currentPkgInfo, AttributeInfo.Kind.LOCAL_VARIABLES_ATTRIBUTE.value());
currentPkgInfo.addAttributeInfo(AttributeInfo.Kind.LOCAL_VARIABLES_ATTRIBUTE, new LocalVariableAttributeInfo(pkgVarAttrNameIndex));
pkgNode.globalVars.forEach(this::createPackageVarInfo);
pkgNode.structs.forEach(this::createStructInfoEntry);
pkgNode.enums.forEach(this::createEnumInfoEntry);
pkgNode.connectors.forEach(this::createConnectorInfoEntry);
pkgNode.functions.forEach(this::createFunctionInfoEntry);
pkgNode.services.forEach(this::createServiceInfoEntry);
pkgNode.functions.forEach(this::createFunctionInfoEntry);
pkgNode.transformers.forEach(this::createTransformerInfoEntry);
// Visit package builtin function
visitBuiltinFunctions(pkgNode.initFunction);
visitBuiltinFunctions(pkgNode.startFunction);
visitBuiltinFunctions(pkgNode.stopFunction);
pkgNode.topLevelNodes.stream().filter(pkgLevelNode -> pkgLevelNode.getKind() != NodeKind.VARIABLE && pkgLevelNode.getKind() != NodeKind.XMLNS).forEach(pkgLevelNode -> genNode((BLangNode) pkgLevelNode, this.env));
currentPkgInfo.addAttributeInfo(AttributeInfo.Kind.LINE_NUMBER_TABLE_ATTRIBUTE, lineNoAttrInfo);
currentPackageRefCPIndex = -1;
currentPkgID = null;
pkgNode.completedPhases.add(CompilerPhase.CODE_GEN);
}
Aggregations