Example usage for javax.xml.namespace QName toString

List of usage examples for javax.xml.namespace QName toString

Introduction

In this page you can find the example usage for javax.xml.namespace QName toString.

Prototype

public String toString() 

Source Link

Document

<p><code>String</code> representation of this <code>QName</code>.</p> <p>The commonly accepted way of representing a <code>QName</code> as a <code>String</code> was <a href="http://jclark.com/xml/xmlns.htm">defined</a> by James Clark.

Usage

From source file:org.wso2.carbon.humantask.core.scheduler.JobProcessorImpl.java

private void executeDeadline(long taskId, String name) throws HumanTaskException {
    //TODO what if two deadlines fired at the same time???
    //TODO do the needful for deadlines. i.e create notifications and re-assign
    log.info("ON DEADLINE: " + " : now: " + new Date());

    TaskDAO task = HumanTaskServiceComponent.getHumanTaskServer().getDaoConnectionFactory().getConnection()
            .getTask(taskId);// w ww  .  j av a 2  s  .c om

    // Setting the tenant id and tenant domain
    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(task.getTenantId());
    String tenantDomain = null;
    try {
        tenantDomain = HumanTaskServiceComponent.getRealmService().getTenantManager()
                .getDomain(task.getTenantId());
    } catch (UserStoreException e) {
        log.error(" Cannot find the tenant domain " + e.toString());
    }

    if (tenantDomain == null) {
        tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    }

    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain);

    TaskConfiguration taskConf = (TaskConfiguration) HumanTaskServiceComponent.getHumanTaskServer()
            .getTaskStoreManager().getHumanTaskStore(task.getTenantId())
            .getTaskConfiguration(QName.valueOf(task.getName()));
    TDeadline deadline = taskConf.getDeadline(name);
    EvaluationContext evalCtx = new ExpressionEvaluationContext(task, taskConf);

    List<TEscalation> validEscalations = new ArrayList<TEscalation>();
    boolean reassingnmentAdded = false;
    for (TEscalation escalation : deadline.getEscalationArray()) {
        if (!escalation.isSetCondition()) {
            //We only need the first Re-assignment and we ignore all other re-assignments
            if (escalation.isSetReassignment() && !reassingnmentAdded) {
                reassingnmentAdded = true;
            } else if (escalation.isSetReassignment()) {
                continue;
            }
            validEscalations.add(escalation);
            continue;
        }

        if (evaluateCondition(escalation.getCondition().newCursor().getTextValue(),
                escalation.getCondition().getExpressionLanguage() == null ? taskConf.getExpressionLanguage()
                        : escalation.getCondition().getExpressionLanguage(),
                evalCtx)) {
            if (escalation.isSetReassignment() && !reassingnmentAdded) {
                reassingnmentAdded = true;
            } else if (escalation.isSetReassignment()) {
                continue;
            }
            validEscalations.add(escalation);
        }
    }

    //We may do this in the above for loop as well
    for (TEscalation escalation : validEscalations) {
        if (log.isDebugEnabled()) {
            log.debug("Escalation: " + escalation.getName());
        }
        if (escalation.isSetLocalNotification() || escalation.isSetNotification()) {
            QName qName;
            if (escalation.isSetLocalNotification()) {
                qName = escalation.getLocalNotification().getReference();
            } else {
                qName = new QName(taskConf.getName().getNamespaceURI(), escalation.getNotification().getName());
            }

            HumanTaskBaseConfiguration notificationConfiguration = HumanTaskServiceComponent
                    .getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(task.getTenantId())
                    .getActiveTaskConfiguration(qName);
            if (notificationConfiguration == null) {
                log.error("Fatal Error, notification definition not found for name " + qName.toString());
                return;
            }

            TaskCreationContext taskContext = new TaskCreationContext();
            taskContext.setTaskConfiguration(notificationConfiguration);
            taskContext.setTenantId(task.getTenantId());
            taskContext.setPeopleQueryEvaluator(
                    HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getPeopleQueryEvaluator());

            Map<String, Element> tempBodyParts = new HashMap<String, Element>();
            Map<String, Element> tempHeaderParts = new HashMap<String, Element>();
            QName tempName = null;

            TToParts toParts = escalation.getToParts();
            if (toParts == null) {
                //get the input message of the task
                MessageDAO msg = task.getInputMessage();
                tempName = msg.getName();
                for (Map.Entry<String, Element> partEntry : msg.getBodyParts().entrySet()) {
                    tempBodyParts.put(partEntry.getKey(), partEntry.getValue());
                }
                for (Map.Entry<String, Element> partEntry : msg.getHeaderParts().entrySet()) {
                    tempHeaderParts.put(partEntry.getKey(), partEntry.getValue());
                }

                taskContext.setMessageBodyParts(tempBodyParts);
                taskContext.setMessageHeaderParts(tempHeaderParts);
                taskContext.setMessageName(tempName);
            } else {
                for (TToPart toPart : toParts.getToPartArray()) {
                    if (!notificationConfiguration.isValidPart(toPart.getName())) {
                        //This validation should be done at the deployment time
                        String errMsg = "The part: " + toPart.getName() + " is not available"
                                + " in the corresponding WSDL message";
                        log.error(errMsg);
                        throw new RuntimeException(errMsg);
                    }
                    String expLang = toPart.getExpressionLanguage() == null ? taskConf.getExpressionLanguage()
                            : toPart.getExpressionLanguage();
                    Node nodePart = HumanTaskServerHolder.getInstance().getHtServer().getTaskEngine()
                            .getExpressionLanguageRuntime(expLang)
                            .evaluateAsPart(toPart.newCursor().getTextValue(), toPart.getName(), evalCtx);
                    tempBodyParts.put(toPart.getName(), (Element) nodePart);
                }
            }

            taskContext.setMessageBodyParts(tempBodyParts);
            taskContext.setMessageHeaderParts(tempHeaderParts);
            taskContext.setMessageName(tempName);
            HumanTaskServerHolder.getInstance().getHtServer().getTaskEngine().getDaoConnectionFactory()
                    .getConnection().createTask(taskContext);
        } else { //if re-assignment
            if (escalation.getReassignment().getPotentialOwners().isSetFrom()) {
                escalation.getReassignment().getPotentialOwners().getFrom().getArgumentArray();

                String roleName = null;
                for (TArgument argument : escalation.getReassignment().getPotentialOwners().getFrom()
                        .getArgumentArray()) {
                    if ("role".equals(argument.getName())) {
                        roleName = argument.newCursor().getTextValue().trim();
                    }
                }

                if (roleName == null) {
                    String errMsg = "Value for argument name 'role' is expected.";
                    log.error(errMsg);
                    throw new Scheduler.JobProcessorException(errMsg);
                }

                if (!isExistingRole(roleName, task.getTenantId())) {
                    log.warn("Role name " + roleName + " does not exist for tenant id" + task.getTenantId());
                }

                List<OrganizationalEntityDAO> orgEntities = new ArrayList<OrganizationalEntityDAO>();
                OrganizationalEntityDAO orgEntity = HumanTaskServiceComponent.getHumanTaskServer()
                        .getDaoConnectionFactory().getConnection().createNewOrgEntityObject(roleName,
                                OrganizationalEntityDAO.OrganizationalEntityType.GROUP);
                orgEntities.add(orgEntity);
                task.replaceOrgEntitiesForLogicalPeopleGroup(
                        GenericHumanRoleDAO.GenericHumanRoleType.POTENTIAL_OWNERS, orgEntities);
            } else {
                String errMsg = "From element is expected inside the assignment";
                log.error(errMsg);
                throw new Scheduler.JobProcessorException(errMsg);
            }
        }
    }
}

From source file:org.wso2.carbon.mediation.initializer.utils.SynapseArtifactInitUtils.java

/**
 * Function to create synapse imports to enable installed connectors
 *
 * @param axisConfiguration axis configuration
 */// w  w  w  .j  a  v  a 2s.c om
public static void initializeConnectors(AxisConfiguration axisConfiguration) {
    String synapseLibPath = axisConfiguration.getRepository().getPath() + File.separator
            + ServiceBusConstants.SYNAPSE_LIB_CONFIGS;
    File synapseLibDir = new File(synapseLibPath);
    if (synapseLibDir.exists() && synapseLibDir.isDirectory()) {
        File[] connectorList = synapseLibDir.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return name.endsWith(".zip");
            }
        });

        if (connectorList == null) {
            // No connectors found
            return;
        }

        //Check import related to the connector is available
        String importConfigDirPath = axisConfiguration.getRepository().getPath()
                + ServiceBusConstants.SYNAPSE_IMPORTS_CONFIG_PATH;
        File importsDir = new File(importConfigDirPath);

        if (!importsDir.exists() && !importsDir.mkdirs()) {
            log.error("Import synapse config directory does not exists and unable to create: "
                    + importsDir.getAbsolutePath());
            // Retrying the same for other connectors is waste
            return;
        }

        for (File connectorZip : connectorList) {
            if (log.isDebugEnabled()) {
                log.debug("Generating import for connector deployed with package: " + connectorZip.getName());
            }
            String connectorExtractedPath = null;
            try {
                connectorExtractedPath = extractConnector(connectorZip.getAbsolutePath());
            } catch (IOException e) {
                log.error("Error while extracting Connector zip : " + connectorZip.getAbsolutePath(), e);
                continue;
            }
            String packageName = retrievePackageName(connectorExtractedPath);

            // Retrieve connector name
            String connectorName = connectorZip.getName().substring(0, connectorZip.getName().indexOf('-'));
            QName qualifiedName = new QName(packageName, connectorName);
            File importFile = new File(importsDir, qualifiedName.toString() + ".xml");

            if (!importFile.exists()) {
                // Import file enabling file connector not available in synapse imports directory
                if (log.isDebugEnabled()) {
                    log.debug("Generating import config to enable connector: " + qualifiedName);
                }
                generateImportConfig(qualifiedName, importFile);
            }
        }
    }
}

From source file:org.wso2.wsf.jython.messagereceiver.PythonScriptReceiver.java

/**
 * Creates an object that can be passed into a pythonscript function from an OMElement.
 *
 * @param omElement The OMElement that the parameter should be created for
 * @param type      The schemaType of the incoming message element
 * @return An Object that can be passed into a Py function
 * @throws AxisFault In case an exception occurs
 */// w  ww. jav  a 2 s. co m
private Object createParam(OMElement omElement, QName type) throws AxisFault {
    if (log.isDebugEnabled()) {
        log.debug("QName type of the parameter : " + type.toString());
    }

    if (Constants.XSD_ANYTYPE.equals(type)) {

    }
    String value = omElement.getText();
    if (value == null) {
        throw new AxisFault("The value of Element " + omElement.getLocalName() + " cannot be null");
    }
    if (Constants.XSD_BOOLEAN.equals(type)) {
        try {
            return ConverterUtil.convertToBoolean(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "boolean"));
        }
    }
    if (Constants.XSD_DOUBLE.equals(type)) {
        try {
            return ConverterUtil.convertToDouble(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "double"));
        }
    }
    if (Constants.XSD_FLOAT.equals(type)) {
        try {
            return ConverterUtil.convertToFloat(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "float"));
        }
    }
    if (Constants.XSD_INT.equals(type)) {
        try {
            return ConverterUtil.convertToInt(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "int"));
        }
    }
    if (Constants.XSD_INTEGER.equals(type)) {
        try {
            if (value.equals("") || value == null) {
                return Integer.MIN_VALUE;
            }
            if (value.startsWith("+")) {
                value = value.substring(1);
            }
            return new Integer(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "integer"));
        }
    }
    if (Constants.XSD_POSITIVEINTEGER.equals(type)) {
        try {
            return ConverterUtil.convertToPositiveInteger(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "positive integer"));
        }
    }
    if (Constants.XSD_NEGATIVEINTEGER.equals(type)) {
        try {
            return ConverterUtil.convertToNegativeInteger(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "negative integer"));
        }
    }
    if (Constants.XSD_NONPOSITIVEINTEGER.equals(type)) {
        try {
            return ConverterUtil.convertToNonPositiveInteger(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "non-positive integer"));
        }
    }
    if (Constants.XSD_NONNEGATIVEINTEGER.equals(type)) {
        try {
            return ConverterUtil.convertToNonNegativeInteger(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "non-negative integer"));
        }
    }
    if (Constants.XSD_LONG.equals(type)) {
        try {
            return ConverterUtil.convertToLong(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "long"));
        }
    }
    if (Constants.XSD_SHORT.equals(type)) {
        try {
            return ConverterUtil.convertToShort(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "short"));
        }
    }
    if (Constants.XSD_BYTE.equals(type)) {
        try {
            return ConverterUtil.convertToByte(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "byte"));
        }
    }
    if (Constants.XSD_UNSIGNEDINT.equals(type)) {
        try {
            return ConverterUtil.convertToUnsignedInt(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "unsigned int"));
        }
    }
    if (Constants.XSD_UNSIGNEDLONG.equals(type)) {
        try {
            return ConverterUtil.convertToUnsignedLong(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "unsigned long"));
        }
    }
    if (Constants.XSD_UNSIGNEDSHORT.equals(type)) {
        try {
            return ConverterUtil.convertToUnsignedShort(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "unsigned short"));
        }
    }
    if (Constants.XSD_UNSIGNEDBYTE.equals(type)) {
        try {
            return ConverterUtil.convertToUnsignedByte(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "unsigned byte"));
        }
    }
    if (Constants.XSD_DECIMAL.equals(type)) {
        try {
            return ConverterUtil.convertToDecimal(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "decimal"));
        }
    }
    if (Constants.XSD_DURATION.equals(type)) {
        try {
            Duration duration = ConverterUtil.convertToDuration(value);
            return duration.toString();
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "duration"));
        }
    }
    if (Constants.XSD_QNAME.equals(type)) {

    }
    if (Constants.XSD_HEXBIN.equals(type)) {
        try {
            return ConverterUtil.convertToString(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "hexBinary"));
        }
    }
    if (Constants.XSD_BASE64.equals(type)) {
        try {
            return ConverterUtil.convertToString(value);
        } catch (Exception e) {
            throw new AxisFault(getFaultString(value, "base64Binary"));
        }
    }
    return omElement.getText();
}

From source file:org.xchain.namespaces.hibernate.DebugSessionCommand.java

public boolean execute(JXPathContext context) throws Exception {
    try {/*from w w  w. j a va  2  s. c  o m*/
        Session session = null;
        Transaction transaction = null;

        String message = getMessage(context);
        log.debug(message);
        // get the session from the context.
        QName name = getName(context);
        session = HibernateLifecycle.getCurrentSession(name);

        log.debug("Getting session for {}", name.toString());

        // if we didn't find the session, then bail out.
        if (session == null) {
            throw new IllegalStateException("Session not found.");
        }

        // Dump Session data to log
        logSession(session);

        transaction = session.getTransaction();

        if (transaction != null) {
            log.debug("Transaction Active: {}", transaction.isActive());
        }
    } catch (Exception e) {
        log.error("Error inspecting Session: {}", e.getMessage(), e);
    }

    return false;
}

From source file:test.integ.be.e_contract.sts.CXFSTSClientTest.java

@Test
public void testCXFWSDL() throws Exception {
    Bus bus = BusFactory.getDefaultBus();
    // String wsdlLocation = CXFSTSClientTest.class
    // .getResource("/ws-trust-1.3.wsdl").toURI().toURL().toString();
    String wsdlLocation = "https://localhost/iam/sts?wsdl";
    QName serviceName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512", "SecurityTokenService");
    WSDLServiceFactory factory = new WSDLServiceFactory(bus, wsdlLocation, serviceName);
    SourceDataBinding dataBinding = new SourceDataBinding();
    factory.setDataBinding(dataBinding);
    Service service = factory.create();
    service.setDataBinding(dataBinding);
    QName endpointName = new QName("", "");
    LOGGER.debug("number of endpoints: {}", service.getEndpoints().size());
    for (QName endpointQName : service.getEndpoints().keySet()) {
        LOGGER.debug("endpoint name: {}", endpointQName.toString());
    }/*from   w ww. j  a v a 2  s  .c om*/
    EndpointInfo ei = service.getEndpointInfo(endpointName);
    Endpoint endpoint = new EndpointImpl(bus, service, ei);
}

From source file:test.integ.be.e_contract.sts.CXFSTSClientTest.java

@Test
public void testCXFExampleSecurityPolicy() throws Exception {
    Bus bus = BusFactory.getDefaultBus();
    String wsdlLocation = CXFSTSClientTest.class.getResource("/example-security-policy.wsdl").toURI().toURL()
            .toString();//from w ww  .  j av  a2 s  .  co  m
    QName serviceName = new QName("urn:be:e-contract:sts:example", "ExampleService");
    WSDLServiceFactory factory = new WSDLServiceFactory(bus, wsdlLocation, serviceName);
    SourceDataBinding dataBinding = new SourceDataBinding();
    factory.setDataBinding(dataBinding);
    Service service = factory.create();
    service.setDataBinding(dataBinding);
    QName endpointName = new QName("", "");
    LOGGER.debug("number of endpoints: {}", service.getEndpoints().size());
    for (QName endpointQName : service.getEndpoints().keySet()) {
        LOGGER.debug("endpoint name: {}", endpointQName.toString());
    }
    EndpointInfo ei = service.getEndpointInfo(endpointName);
    Endpoint endpoint = new EndpointImpl(bus, service, ei);
}

From source file:test.integ.be.e_contract.sts.CXFSTSClientTest.java

@Test
public void testCXFWSDLAGIV() throws Exception {
    Bus bus = BusFactory.getDefaultBus();
    // String wsdlLocation = CXFSTSClientTest.class
    // .getResource("/ws-trust-1.3.wsdl").toURI().toURL().toString();
    String wsdlLocation = "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc?wsdl";
    QName serviceName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512", "SecurityTokenService");
    WSDLServiceFactory factory = new WSDLServiceFactory(bus, wsdlLocation, serviceName);
    SourceDataBinding dataBinding = new SourceDataBinding();
    factory.setDataBinding(dataBinding);
    Service service = factory.create();
    service.setDataBinding(dataBinding);
    QName endpointName = new QName("", "");
    LOGGER.debug("number of endpoints: {}", service.getEndpoints().size());
    for (QName endpointQName : service.getEndpoints().keySet()) {
        LOGGER.debug("endpoint name: {}", endpointQName.toString());
    }//  w  w  w.j av  a 2  s  .  com
    EndpointInfo ei = service.getEndpointInfo(endpointName);
    Endpoint endpoint = new EndpointImpl(bus, service, ei);
}

From source file:xquery4j.XQueryEvaluator.java

public List evaluateExpression(String expr, org.w3c.dom.Node contextNode) {
    try {//from   ww  w.  j av  a  2 s. co m
        contextObjectTL.set(contextObject);
        {
            FunctionLibraryList fll = new FunctionLibraryList();
            fll.addFunctionLibrary(jel);
            config.setExtensionBinder("java", fll);
        }

        StaticQueryContext sqc = new StaticQueryContext(config);
        for (QName var : vars.keySet()) {
            sqc.declareGlobalVariable(StructuredQName.fromClarkName(var.toString()), SequenceType.SINGLE_ITEM,
                    convertJavaToSaxon(vars.get(var)), false);
        }
        DynamicQueryContext dqc = new DynamicQueryContext(config);
        XQueryExpression e = sqc.compileQuery(expr);

        if (contextNode != null) {
            if (!(contextNode instanceof Document || contextNode instanceof DocumentFragment)) {
                try {
                    contextNode = DOMUtils.parse(DOMUtils.domToString(contextNode));
                } catch (Exception e1) {
                    throw new RuntimeException("", e1);
                }
                //                    DocumentFragment frag = contextNode.getOwnerDocument().createDocumentFragment();
                //                    frag.appendChild(contextNode);
                //                    contextNode = frag;
            }
            dqc.setContextItem(new DocumentWrapper(contextNode, "", config));
        }

        List value = e.evaluate(dqc);
        List value2 = new ArrayList();
        for (Object o : value) {
            Object o2 = o;
            if (o2 instanceof NodeInfo) {
                try {
                    Node o3 = DOMUtils.parse(DOMUtils.domToString(NodeOverNodeInfo.wrap((NodeInfo) o2)))
                            .getDocumentElement();
                    o2 = o3;
                } catch (Exception e1) {
                    throw new RuntimeException("Error converting result", e1);
                }
            }
            value2.add(o2);
        }
        __log.debug("result for expression " + expr + " " + value2 + " value class "
                + (value2 == null ? null : value2.getClass()));
        return value2;
    } catch (XPathException e) {
        __log.error("", e);
        throw new RuntimeException(e);
    } finally {
        contextObjectTL.set(null);
    }
}