Example usage for javax.xml.namespace QName valueOf

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

Introduction

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

Prototype

public static QName valueOf(String qNameAsString) 

Source Link

Document

<p><code>QName</code> derived from parsing the formatted <code>String</code>.</p> <p>If the <code>String</code> is <code>null</code> or does not conform to #toString() QName.toString() formatting, an <code>IllegalArgumentException</code> is thrown.</p> <p><em>The <code>String</code> <strong>MUST</strong> be in the form returned by #toString() QName.toString() .</em></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.eclipse.winery.repository.rest.resources.API.APIResource.java

@GET
@Path("getallartifacttemplatesofcontaineddeploymentartifacts")
@Produces(MediaType.APPLICATION_JSON)//  w  ww .j  av a 2  s.  c  o m
public Response getAllArtifactTemplatesOfContainedDeploymentArtifacts(
        @QueryParam("servicetemplate") String serviceTemplateQNameString,
        @QueryParam("nodetemplateid") String nodeTemplateId) {
    if (StringUtils.isEmpty(serviceTemplateQNameString)) {
        return Response.status(Status.BAD_REQUEST).entity("servicetemplate has be given as query parameter")
                .build();
    }

    QName serviceTemplateQName = QName.valueOf(serviceTemplateQNameString);

    ServiceTemplateId serviceTemplateId = new ServiceTemplateId(serviceTemplateQName);
    if (!RepositoryFactory.getRepository().exists(serviceTemplateId)) {
        return Response.status(Status.BAD_REQUEST).entity("service template does not exist").build();
    }
    ServiceTemplateResource serviceTemplateResource = new ServiceTemplateResource(serviceTemplateId);

    Collection<QName> artifactTemplates = new ArrayList<>();
    List<TNodeTemplate> allNestedNodeTemplates = BackendUtils
            .getAllNestedNodeTemplates(serviceTemplateResource.getServiceTemplate());
    for (TNodeTemplate nodeTemplate : allNestedNodeTemplates) {
        if (StringUtils.isEmpty(nodeTemplateId) || nodeTemplate.getId().equals(nodeTemplateId)) {
            Collection<QName> ats = BackendUtils
                    .getArtifactTemplatesOfReferencedDeploymentArtifacts(nodeTemplate);
            artifactTemplates.addAll(ats);
        }
    }

    // convert QName list to select2 data
    Select2DataWithOptGroups res = new Select2DataWithOptGroups();
    for (QName qName : artifactTemplates) {
        res.add(qName.getNamespaceURI(), qName.toString(), qName.getLocalPart());
    }
    return Response.ok().entity(res.asSortedSet()).build();
}

From source file:org.eclipse.winery.repository.rest.resources.API.APIResource.java

/**
 * Implementation similar to//ww w  . ja v a  2 s.c  o  m
 * getAllArtifactTemplatesOfContainedDeploymentArtifacts. Only difference is
 * "getArtifactTemplatesOfReferencedImplementationArtifacts" instead of
 * "getArtifactTemplatesOfReferencedDeploymentArtifacts".
 */
@GET
@Path("getallartifacttemplatesofcontainedimplementationartifacts")
@Produces(MediaType.APPLICATION_JSON)
public Response getAllArtifactTemplatesOfContainedImplementationArtifacts(
        @QueryParam("servicetemplate") String serviceTemplateQNameString,
        @QueryParam("nodetemplateid") String nodeTemplateId) {
    if (StringUtils.isEmpty(serviceTemplateQNameString)) {
        return Response.status(Status.BAD_REQUEST).entity("servicetemplate has be given as query parameter")
                .build();
    }
    QName serviceTemplateQName = QName.valueOf(serviceTemplateQNameString);

    ServiceTemplateId serviceTemplateId = new ServiceTemplateId(serviceTemplateQName);
    if (!RepositoryFactory.getRepository().exists(serviceTemplateId)) {
        return Response.status(Status.BAD_REQUEST).entity("service template does not exist").build();
    }
    ServiceTemplateResource serviceTemplateResource = new ServiceTemplateResource(serviceTemplateId);

    Collection<QName> artifactTemplates = new ArrayList<>();
    List<TNodeTemplate> allNestedNodeTemplates = BackendUtils
            .getAllNestedNodeTemplates(serviceTemplateResource.getServiceTemplate());
    for (TNodeTemplate nodeTemplate : allNestedNodeTemplates) {
        if (StringUtils.isEmpty(nodeTemplateId) || nodeTemplate.getId().equals(nodeTemplateId)) {
            Collection<QName> ats = BackendUtils
                    .getArtifactTemplatesOfReferencedImplementationArtifacts(nodeTemplate);
            artifactTemplates.addAll(ats);
        }
    }

    // convert QName list to select2 data
    Select2DataWithOptGroups res = new Select2DataWithOptGroups();
    for (QName qName : artifactTemplates) {
        res.add(qName.getNamespaceURI(), qName.toString(), qName.getLocalPart());
    }
    return Response.ok().entity(res.asSortedSet()).build();
}

From source file:org.eclipse.winery.repository.rest.resources.artifacts.GenericArtifactsResource.java

/**
 * @return TImplementationArtifact | TDeploymentArtifact (XML) | URL of generated IA zip (in case of autoGenerateIA)
 */// w  w  w  .j ava  2 s  .  c o  m
@POST
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Creates a new implementation/deployment artifact. If an implementation artifact with the same name already exists, it is <em>overridden</em>.")
@SuppressWarnings("unchecked")
public Response generateArtifact(GenerateArtifactApiData apiData, @Context UriInfo uriInfo) {
    // we assume that the parent ComponentInstance container exists

    final IRepository repository = RepositoryFactory.getRepository();

    if (StringUtils.isEmpty(apiData.artifactName)) {
        return Response.status(Status.BAD_REQUEST).entity("Empty artifactName").build();
    }
    if (StringUtils.isEmpty(apiData.artifactType)) {
        if (StringUtils.isEmpty(apiData.artifactTemplateName)
                || StringUtils.isEmpty(apiData.artifactTemplateNamespace)) {
            if (StringUtils.isEmpty(apiData.artifactTemplate)) {
                return Response.status(Status.BAD_REQUEST)
                        .entity("No artifact type given and no template given. Cannot guess artifact type")
                        .build();
            }
        }
    }

    if (!StringUtils.isEmpty(apiData.autoGenerateIA)) {
        if (StringUtils.isEmpty(apiData.javaPackage)) {
            return Response.status(Status.BAD_REQUEST)
                    .entity("no java package name supplied for IA auto generation.").build();
        }
        if (StringUtils.isEmpty(apiData.interfaceName)) {
            return Response.status(Status.BAD_REQUEST)
                    .entity("no interface name supplied for IA auto generation.").build();
        }
    }

    // convert second calling form to first calling form
    if (!StringUtils.isEmpty(apiData.artifactTemplate)) {
        QName qname = QName.valueOf(apiData.artifactTemplate);
        apiData.artifactTemplateName = qname.getLocalPart();
        apiData.artifactTemplateNamespace = qname.getNamespaceURI();
    }

    Document doc = null;

    // check artifact specific content for validity
    // if invalid, abort and do not create anything
    if (!StringUtils.isEmpty(apiData.artifactSpecificContent)) {
        try {
            DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
            InputSource is = new InputSource();
            StringReader sr = new StringReader(apiData.artifactSpecificContent);
            is.setCharacterStream(sr);
            doc = db.parse(is);
        } catch (Exception e) {
            // FIXME: currently we allow a single element only. However, the content should be internally wrapped by an (arbitrary) XML element as the content will be nested in the artifact element, too
            GenericArtifactsResource.LOGGER.debug("Invalid content", e);
            return Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build();
        }
    }

    // determine artifactTemplate and artifactType

    ArtifactTypeId artifactTypeId;
    ArtifactTemplateId artifactTemplateId = null;
    ArtifactTemplateResource artifactTemplateResource = null;

    boolean doAutoCreateArtifactTemplate = !(StringUtils.isEmpty(apiData.autoCreateArtifactTemplate)
            || apiData.autoCreateArtifactTemplate.equalsIgnoreCase("no")
            || apiData.autoCreateArtifactTemplate.equalsIgnoreCase("false"));
    if (!doAutoCreateArtifactTemplate) {
        // no auto creation
        if (!StringUtils.isEmpty(apiData.artifactTemplateName)
                && !StringUtils.isEmpty(apiData.artifactTemplateNamespace)) {
            QName artifactTemplateQName = new QName(apiData.artifactTemplateNamespace,
                    apiData.artifactTemplateName);
            artifactTemplateId = BackendUtils.getDefinitionsChildId(ArtifactTemplateId.class,
                    artifactTemplateQName);
        }
        if (StringUtils.isEmpty(apiData.artifactType)) {
            // derive the type from the artifact template
            if (artifactTemplateId == null) {
                return Response.status(Status.NOT_ACCEPTABLE).entity(
                        "No artifactTemplate and no artifactType provided. Deriving the artifactType is not possible.")
                        .build();
            }
            @NonNull
            final QName type = repository.getElement(artifactTemplateId).getType();
            artifactTypeId = BackendUtils.getDefinitionsChildId(ArtifactTypeId.class, type);
        } else {
            // artifactTypeStr is directly given, use that
            artifactTypeId = BackendUtils.getDefinitionsChildId(ArtifactTypeId.class, apiData.artifactType);
        }
    } else {
        // do the artifact template auto creation magic

        if (StringUtils.isEmpty(apiData.artifactType)) {
            return Response.status(Status.BAD_REQUEST)
                    .entity("Artifact template auto creation requested, but no artifact type supplied.")
                    .build();
        }

        artifactTypeId = BackendUtils.getDefinitionsChildId(ArtifactTypeId.class, apiData.artifactType);
        // ensure that given type exists
        if (!repository.exists(artifactTypeId)) {
            LOGGER.debug("Artifact type {} is created", apiData.artifactType);
            final TArtifactType element = repository.getElement(artifactTypeId);
            try {
                repository.setElement(artifactTypeId, element);
            } catch (IOException e) {
                throw new WebApplicationException(e);
            }
        }

        if (StringUtils.isEmpty(apiData.artifactTemplateName)
                || StringUtils.isEmpty(apiData.artifactTemplateNamespace)) {
            // no explicit name provided
            // we use the artifactNameStr as prefix for the
            // artifact template name

            // we create a new artifact template in the namespace of the parent
            // element
            Namespace namespace = this.resWithNamespace.getNamespace();

            artifactTemplateId = new ArtifactTemplateId(namespace,
                    new XmlId(apiData.artifactName + "artifactTemplate", false));
        } else {
            QName artifactTemplateQName = new QName(apiData.artifactTemplateNamespace,
                    apiData.artifactTemplateName);
            artifactTemplateId = new ArtifactTemplateId(artifactTemplateQName);
        }

        // even if artifactTemplate does not exist, it is loaded
        final TArtifactTemplate artifactTemplate = repository.getElement(artifactTemplateId);
        artifactTemplate.setType(artifactTypeId.getQName());
        try {
            repository.setElement(artifactTemplateId, artifactTemplate);
        } catch (IOException e) {
            throw new WebApplicationException(e);
        }
    }

    // variable artifactTypeId is set
    // variable artifactTemplateId is not null if artifactTemplate has been generated

    // we have to generate the DA/IA resource now
    // Doing it here instead of doing it at the subclasses is dirty on the
    // one hand, but quicker to implement on the other hand

    // Create the artifact itself

    ArtifactT resultingArtifact;

    if (this instanceof ImplementationArtifactsResource) {
        ImplementationArtifact a = new ImplementationArtifact();
        // Winery internal id is the name of the artifact:
        // store the name
        a.setName(apiData.artifactName);
        a.setInterfaceName(apiData.interfaceName);
        a.setOperationName(apiData.operationName);
        assert (artifactTypeId != null);
        a.setArtifactType(artifactTypeId.getQName());
        if (artifactTemplateId != null) {
            a.setArtifactRef(artifactTemplateId.getQName());
        }
        if (doc != null) {
            // the content has been checked for validity at the beginning of the method.
            // If this point in the code is reached, the XML has been parsed into doc
            // just copy over the dom node. Hopefully, that works...
            a.getAny().add(doc.getDocumentElement());
        }

        this.list.add((ArtifactT) a);
        resultingArtifact = (ArtifactT) a;
    } else {
        // for comments see other branch

        TDeploymentArtifact a = new TDeploymentArtifact();
        a.setName(apiData.artifactName);
        assert (artifactTypeId != null);
        a.setArtifactType(artifactTypeId.getQName());
        if (artifactTemplateId != null) {
            a.setArtifactRef(artifactTemplateId.getQName());
        }
        if (doc != null) {
            a.getAny().add(doc.getDocumentElement());
        }

        this.list.add((ArtifactT) a);
        resultingArtifact = (ArtifactT) a;
    }

    // TODO: Check for error, and in case one found return it
    RestUtils.persist(super.res);

    if (StringUtils.isEmpty(apiData.autoGenerateIA)) {
        // No IA generation
        return Response.created(RestUtils.createURI(Util.URLencode(apiData.artifactName)))
                .entity(resultingArtifact).build();
    } else {
        // after everything was created, we fire up the artifact generation
        return this.generateImplementationArtifact(apiData.interfaceName, apiData.javaPackage, uriInfo,
                artifactTemplateId);
    }
}

From source file:org.eclipse.winery.repository.rest.resources.entitytypes.nodetypes.reqandcapdefs.RequirementOrCapabilityDefinitionsResource.java

@POST
// As there is no supertype of TCapabilityType and TRequirementType containing the common attributes, we have to rely on unchecked casts
@SuppressWarnings("unchecked")
@Consumes(MediaType.APPLICATION_JSON)//w w  w.jav a2s. c  o m
public Response onPost(CapabilityDefinitionPostData postData) {
    if (StringUtils.isEmpty(postData.name)) {
        return Response.status(Status.BAD_REQUEST).entity("Name has to be provided").build();
    }
    if (StringUtils.isEmpty(postData.type)) {
        return Response.status(Status.BAD_REQUEST).entity("Type has to be provided").build();
    }

    int lbound = 1;
    if (!StringUtils.isEmpty(postData.lowerBound)) {
        try {
            lbound = Integer.parseInt(postData.lowerBound);
        } catch (NumberFormatException e) {
            return Response.status(Status.BAD_REQUEST).entity("Bad format of lowerbound: " + e.getMessage())
                    .build();
        }
    }

    String ubound = "1";
    if (!StringUtils.isEmpty(postData.upperBound)) {
        ubound = postData.upperBound;
    }

    // we also support replacement of existing requirements
    // therefore, we loop through the existing requirements
    int idx = -1;
    boolean found = false;
    for (ReqDefOrCapDef d : this.list) {
        idx++;
        if (this.getId(d).equals(postData.name)) {
            found = true;
            break;
        }
    }

    QName typeQName = QName.valueOf(postData.type);
    // Create object and put type in it
    ReqDefOrCapDef def;
    if (this instanceof CapabilityDefinitionsResource) {
        def = (ReqDefOrCapDef) new TCapabilityDefinition();
        ((TCapabilityDefinition) def).setCapabilityType(typeQName);
    } else {
        assert (this instanceof RequirementDefinitionsResource);
        def = (ReqDefOrCapDef) new TRequirementDefinition();
        ((TRequirementDefinition) def).setRequirementType(typeQName);
    }

    // copy all other data into object
    AbstractReqOrCapDefResource.invokeSetter(def, "setName", postData.name);
    AbstractReqOrCapDefResource.invokeSetter(def, "setLowerBound", lbound);
    AbstractReqOrCapDefResource.invokeSetter(def, "setUpperBound", ubound);

    if (found) {
        // replace element
        this.list.set(idx, def);
    } else {
        // add new element
        this.list.add(def);
    }

    return RestUtils.persist(this.res);
}

From source file:org.eclipse.winery.repository.rest.resources.entitytypes.requirementtypes.RequiredCapabilityTypeResource.java

@PUT
@Consumes(MediaType.TEXT_PLAIN)/*from  w  w w  . ja  va  2  s  . co m*/
public Response putRequiredCapabilityType(String type) {
    if (StringUtils.isEmpty(type)) {
        return Response.status(Status.BAD_REQUEST).entity("type must not be empty").build();
    }
    QName qname = QName.valueOf(type);
    CapabilityTypeId id = new CapabilityTypeId(qname);
    if (RepositoryFactory.getRepository().exists(id)) {
        // everything allright. Store new reference
        this.getRequirementType().setRequiredCapabilityType(qname);
        return RestUtils.persist(this.requirementTypeResource);
    } else {
        throw new NotFoundException("Given QName could not be resolved to an existing capability type");
    }
}

From source file:org.fireflow.model.io.service.ServiceParser.java

protected Expression createExpression(Element expressionElement) {
    if (expressionElement != null) {
        ExpressionImpl exp = new ExpressionImpl();
        exp.setLanguage(expressionElement.getAttribute(LANGUAGE));
        exp.setName(expressionElement.getAttribute(NAME));
        exp.setDisplayName(expressionElement.getAttribute(DISPLAY_NAME));
        String dataTypeStr = expressionElement.getAttribute(DATA_TYPE);
        QName qname = QName.valueOf(dataTypeStr);
        exp.setDataType(qname);/*from  w  ww .j  a  v  a 2  s  . c o m*/
        Element bodyElement = Util4Deserializer.child(expressionElement, BODY);

        if (bodyElement == null) {
            exp.setBody("");
        } else {
            exp.setBody(this.loadCDATA(bodyElement));
        }

        Element namespacePrefixUriMapElem = Util4Deserializer.child(expressionElement,
                NAMESPACE_PREFIX_URI_MAP);

        if (namespacePrefixUriMapElem != null) {
            List<Element> children = Util4Deserializer.children(namespacePrefixUriMapElem, ENTRY);
            if (children != null && children.size() > 0) {
                for (Element elem : children) {
                    String prefix = elem.getAttribute(NAME);
                    String uri = elem.getAttribute(VALUE);
                    exp.getNamespaceMap().put(prefix, uri);
                }
            }
        }
        return exp;
    } else {
        ExpressionImpl exp = new ExpressionImpl();
        exp.setLanguage(ScriptLanguages.UNIFIEDJEXL.name());
        exp.setDataType(
                new QName(NameSpaces.JAVA.getUri(), String.class.getName(), NameSpaces.JAVA.getPrefix()));
        exp.setName("WorkItemSubject");
        exp.setDisplayName("");// 
        exp.setBody("");
        return exp;
    }
}

From source file:org.fireflow.pdl.fpdl.io.FPDLDeserializer.java

protected Expression createExpression(Element expressionElement) {
    if (expressionElement != null) {
        ExpressionImpl exp = new ExpressionImpl();
        exp.setLanguage(expressionElement.getAttribute(LANGUAGE));
        exp.setName(expressionElement.getAttribute(NAME));
        exp.setDisplayName(expressionElement.getAttribute(DISPLAY_NAME));
        String dataTypeStr = expressionElement.getAttribute(DATA_TYPE);
        if (dataTypeStr != null && !dataTypeStr.trim().equals("")) {
            QName qname = QName.valueOf(dataTypeStr);
            exp.setDataType(qname);/* w w  w .jav a  2s. c  o  m*/
        }

        Element bodyElement = Util4Deserializer.child(expressionElement, BODY);

        String body = this.loadCDATA(bodyElement);
        exp.setBody(body);

        Element namespacePrefixUriMapElem = Util4Deserializer.child(expressionElement,
                this.NAMESPACE_PREFIX_URI_MAP);

        if (namespacePrefixUriMapElem != null) {
            List<Element> children = Util4Deserializer.children(namespacePrefixUriMapElem, ENTRY);
            if (children != null && children.size() > 0) {
                for (Element elem : children) {
                    String prefix = elem.getAttribute(NAME);
                    String uri = elem.getAttribute(VALUE);
                    exp.getNamespaceMap().put(prefix, uri);
                }
            }
        }

        return exp;
    } else {
        ExpressionImpl exp = new ExpressionImpl();
        exp.setLanguage(ScriptLanguages.UNIFIEDJEXL.name());
        exp.setDataType(
                new QName(NameSpaces.JAVA.getUri(), String.class.getName(), NameSpaces.JAVA.getPrefix()));
        exp.setName("WorkItemSubject");
        exp.setDisplayName("");// 
        exp.setBody("");
        return exp;
    }
}

From source file:org.fireflow.pdl.fpdl.io.FPDLDeserializer.java

/**
 * @param parent/*from  ww  w .j  ava 2 s .c o m*/
 * @param element
 * @return
 * @throws DeserializerException
 */
protected Property createProperty(WorkflowElement parent, Element element) throws DeserializerException {
    if (element == null) {
        return null;
    }
    String dataTypeStr = element.getAttribute(DATA_TYPE);
    QName dataType = QName.valueOf(dataTypeStr);
    if (dataType == null) {
        dataType = new QName(NameSpaces.JAVA.getUri(), "java.lang.String");
    }

    Property dataField = new PropertyImpl(parent, element.getAttribute(NAME));

    dataField.setDataType(dataType);

    dataField.setDisplayName(element.getAttribute(DISPLAY_NAME));
    dataField.setInitialValueAsString(element.getAttribute(INIT_VALUE));
    dataField.setDescription(loadCDATA(Util4Deserializer.child(element, DESCRIPTION)));

    return dataField;
}

From source file:org.globus.workspace.client_common.TempBaseClient.java

protected CommandLine parse(String[] args, Properties defaultOptions) throws Exception {
    CommandLineParser parser = new PosixParser();
    CommandLine line = parser.parse(options, args, defaultOptions);

    if (defaultOptions != null) {
        Iterator iter = defaultOptions.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next();
            Option opt = options.getOption((String) entry.getKey());
            if (opt != null) {
                String desc = opt.getDescription();
                desc += " (Default '" + entry.getValue() + "')";
                opt.setDescription(desc);
            }//from w  w w . j  av  a2  s . com
        }
    }

    if (line.hasOption("h")) {
        displayUsage();
        System.exit(0);
    }

    if (line.hasOption("e")) {
        if (line.hasOption("k")) {
            throw new ParseException("-e and -k arguments are exclusive");
        }
        if (line.hasOption("s")) {
            throw new ParseException("-e and -s arguments are exclusive");
        }

        FileInputStream in = null;
        try {
            in = new FileInputStream(line.getOptionValue("e"));
            this.endpoint = (EndpointReferenceType) ObjectDeserializer.deserialize(new InputSource(in),
                    EndpointReferenceType.class);
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (Exception e) {
                }
            }
        }
    } else if (line.hasOption("s")) {
        this.endpoint = new EndpointReferenceType();
        this.endpoint.setAddress(new Address(line.getOptionValue("s")));
    } else {
        throw new ParseException("-s or -e argument is required");
    }

    if (line.hasOption("k")) {
        String[] values = line.getOptionValues("k");
        if (values.length != 2) {
            throw new ParseException("-k requires two arguments");
        }
        QName keyName = QName.valueOf(values[0]);
        ReferencePropertiesType props = new ReferencePropertiesType();
        SimpleResourceKey key = new SimpleResourceKey(keyName, values[1]);
        props.add(key.toSOAPElement());
        this.endpoint.setProperties(props);
    }

    this.debugMode = line.hasOption("d");

    // Security mechanism
    if (line.hasOption("m")) {
        String value = line.getOptionValue("m");
        if (value != null) {
            if (value.equals("msg")) {
                this.mechanism = Constants.GSI_SEC_MSG;
            } else if (value.equals("conv")) {
                this.mechanism = Constants.GSI_SEC_CONV;
            } else {
                throw new ParseException("Unsupported security mechanism: " + value);
            }
        }
    }

    // Protection
    if (line.hasOption("p")) {
        String value = line.getOptionValue("p");
        if (value != null) {
            if (value.equals("sig")) {
                this.protection = Constants.SIGNATURE;
            } else if (value.equals("enc")) {
                this.protection = Constants.ENCRYPTION;
            } else {
                throw new ParseException("Unsupported protection mode: " + value);
            }
        }
    }

    // Delegation
    if (line.hasOption("g")) {
        String value = line.getOptionValue("g");
        if (value != null) {
            if (value.equals("limited")) {
                this.delegation = GSIConstants.GSI_MODE_LIMITED_DELEG;
            } else if (value.equals("full")) {
                this.delegation = GSIConstants.GSI_MODE_FULL_DELEG;
            } else {
                throw new ParseException("Unsupported delegation mode: " + value);
            }
        }
    }

    // Authz
    if (line.hasOption("z")) {
        String value = line.getOptionValue("z");
        if (value != null) {
            if (value.equals("self")) {
                this.authorization = SelfAuthorization.getInstance();
            } else if (value.equals("host")) {
                this.authorization = HostAuthorization.getInstance();
            } else if (value.equals("none")) {
                this.authorization = NoAuthorization.getInstance();
            } else if (authorization == null) {
                this.authorization = new IdentityAuthorization(value);
            }
        }
    }

    // Anonymous
    if (line.hasOption("a")) {
        this.anonymous = Boolean.TRUE;
    }

    // context lifetime
    if (line.hasOption("l")) {
        String value = line.getOptionValue("l");
        if (value != null)
            this.contextLifetime = new Integer(value);
    }

    // msg actor
    if (line.hasOption("x")) {
        String value = line.getOptionValue("x");
        this.msgActor = value;
    }

    // conv actor
    if (line.hasOption("y")) {
        String value = line.getOptionValue("y");
        this.convActor = value;
    }

    // Server's public key
    if (line.hasOption("c")) {
        String value = line.getOptionValue("c");
        this.publicKeyFilename = value;
    }

    if (line.hasOption("f")) {
        String value = line.getOptionValue("f");
        this.descriptorFile = value;
    }

    return line;
}

From source file:org.kalypso.commons.databinding.conversion.StringToQNameConverter.java

@Override
public QName convertTyped(final String fromObject) {
    if (StringUtils.isBlank(fromObject))
        return null;

    return QName.valueOf(fromObject);
}