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.kuali.rice.kew.engine.node.hierarchyrouting.HierarchyRoutingNode.java

/**
 * Loads hierarchy provider class via the GlobalResourceLoader
 * @param nodeInstance the current RouteNodeInstance
 * @param context the current RouteContext
 * @return the HierarchyProvider implementation, as specified by the HIERARCHY_PROVIDER config parameter
 *///from  w  w w.ja  v  a 2s .co m
protected HierarchyProvider getHierarchyProvider(RouteNodeInstance nodeInstance, RouteContext context) {
    Map<String, String> cfgMap = Utilities
            .getKeyValueCollectionAsMap(nodeInstance.getRouteNode().getConfigParams());
    String hierarchyProviderClass = cfgMap.get(HIERARCHY_PROVIDER);
    if (StringUtils.isEmpty(hierarchyProviderClass)) {
        throw new WorkflowRuntimeException(
                "hierarchyProvider configuration parameter not set for HierarchyRoutingNode: "
                        + nodeInstance.getName());
    }
    QName qn = QName.valueOf(hierarchyProviderClass);
    ObjectDefinition od;
    if (XMLConstants.NULL_NS_URI.equals(qn.getNamespaceURI())) {
        od = new ObjectDefinition(qn.getLocalPart());
    } else {
        od = new ObjectDefinition(qn.getLocalPart(), qn.getNamespaceURI());
    }
    HierarchyProvider hp = (HierarchyProvider) GlobalResourceLoader.getObject(od);
    hp.init(nodeInstance, context);
    return hp;
}

From source file:org.kuali.rice.kew.impl.peopleflow.PeopleFlowInquirableImpl.java

/**
 * Invokes the {@link org.kuali.rice.kew.api.repository.type.KewTypeRepositoryService} to retrieve the remotable
 * field definitions for the attributes associated with the selected type
 *
 * @param view - view instance//w  w  w . jav a2  s . c om
 * @param model - object containing the form data, from which the selected type will be pulled
 * @param container - container that holds the remotable fields
 * @return List<RemotableAttributeField> instances for the type attributes, or empty list if not attributes exist
 */
public List<RemotableAttributeField> retrieveTypeAttributes(View view, Object model, Container container) {
    List<RemotableAttributeField> remoteFields = new ArrayList<RemotableAttributeField>();

    PeopleFlowBo peopleFlow = (PeopleFlowBo) ((InquiryForm) model).getDataObject();

    // retrieve the type service and invoke to get the remotable field definitions
    if (peopleFlow != null && StringUtils.isNotBlank(peopleFlow.getTypeId())) {
        String typeId = peopleFlow.getTypeId();
        KewTypeDefinition typeDefinition = KewApiServiceLocator.getKewTypeRepositoryService()
                .getTypeById(typeId);
        PeopleFlowTypeService peopleFlowTypeService = GlobalResourceLoader
                .<PeopleFlowTypeService>getService(QName.valueOf(typeDefinition.getServiceName()));
        remoteFields = peopleFlowTypeService.getAttributeFields(typeId);
    }

    return remoteFields;
}

From source file:org.kuali.rice.kew.impl.peopleflow.PeopleFlowMaintainableImpl.java

/**
 * Invokes the {@link org.kuali.rice.kew.api.repository.type.KewTypeRepositoryService} to retrieve the remotable
 * field definitions for the attributes associated with the selected type
 *
 * @param view - view instance/*from w ww. jav  a 2s  .  c om*/
 * @param model - object containing the form data, from which the selected type will be pulled
 * @param container - container that holds the remotable fields
 * @return List<RemotableAttributeField> instances for the type attributes, or empty list if not attributes exist
 */
public List<RemotableAttributeField> retrieveTypeAttributes(View view, Object model, Container container) {
    List<RemotableAttributeField> remoteFields = new ArrayList<RemotableAttributeField>();

    PeopleFlowBo peopleFlow = (PeopleFlowBo) ((MaintenanceDocumentForm) model).getDocument()
            .getNewMaintainableObject().getDataObject();

    // retrieve the type service and invoke to get the remotable field definitions
    String typeId = peopleFlow.getTypeId();
    if (StringUtils.isNotBlank(typeId)) {
        KewTypeDefinition typeDefinition = KewApiServiceLocator.getKewTypeRepositoryService()
                .getTypeById(typeId);
        PeopleFlowTypeService peopleFlowTypeService = GlobalResourceLoader
                .<PeopleFlowTypeService>getService(QName.valueOf(typeDefinition.getServiceName()));
        remoteFields = peopleFlowTypeService.getAttributeFields(typeId);
    }

    return remoteFields;
}

From source file:org.kuali.rice.kim.api.type.KimTypeUtils.java

/**
 * Resolves the given kim type service name represented as a String to the appropriate QName.
 * If the value given is empty or null, then it will resolve to a qname representing the
 * {@link KimConstants#DEFAULT_KIM_TYPE_SERVICE}.
 *
 * @param kimTypeServiceName the name to resolve
 * @return a qname representing a resolved type service
 *///from  w  w w  . ja  va2s.  co m
public static QName resolveKimTypeServiceName(String kimTypeServiceName) {
    if (StringUtils.isBlank(kimTypeServiceName)) {
        return QName.valueOf(KimConstants.DEFAULT_KIM_TYPE_SERVICE);
    }
    return QName.valueOf(kimTypeServiceName);
}

From source file:org.kuali.rice.kim.document.rule.GenericPermissionMaintenanceDocumentRule.java

protected PermissionTypeService getPermissionTypeService(String serviceName) {
    if (StringUtils.isBlank(serviceName)) {
        return null;
    }//  w w  w.j  ava 2s .  co m
    try {
        Object service = GlobalResourceLoader.getService(QName.valueOf(serviceName));
        // if we have a service name, it must exist
        if (service == null) {
            LOG.warn("null returned for permission type service for service name: " + serviceName);
        } else {
            // whatever we retrieved must be of the correct type
            if (!(service instanceof PermissionTypeService)) {
                LOG.warn("Service " + serviceName + " was not a KimPermissionTypeService.  Was: "
                        + service.getClass().getName());
                service = null;
            }
        }
        return (PermissionTypeService) service;
    } catch (Exception ex) {
        LOG.error("Error retrieving service: " + serviceName + " from the KimImplServiceLocator.", ex);
    }
    return null;
}

From source file:org.kuali.rice.kim.document.rule.IdentityManagementRoleDocumentRule.java

protected RoleTypeService getRoleTypeService(KimType typeInfo) {
    String serviceName = typeInfo.getServiceName();
    if (serviceName != null) {
        try {//from  www  .j  a  va2  s . c  o  m
            KimTypeService service = (KimTypeService) GlobalResourceLoader
                    .getService(QName.valueOf(serviceName));
            if (service != null && service instanceof RoleTypeService) {
                return (RoleTypeService) service;
            }
            return (RoleTypeService) KimImplServiceLocator.getService("kimNoMembersRoleTypeService");
        } catch (Exception ex) {
            return (RoleTypeService) KimImplServiceLocator.getService("kimNoMembersRoleTypeService");
        }
    }
    return null;
}

From source file:org.kuali.rice.kim.document.rule.IdentityManagementRoleDocumentRule.java

protected VersionedService<RoleTypeService> getVersionedRoleTypeService(KimType typeInfo) {
    String serviceName = typeInfo.getServiceName();
    if (serviceName != null) {
        String version = "2.0.0"; // default version since the base services have been available since then
        RoleTypeService roleTypeService = null;

        try {//from  w w  w . j  a va2 s  .c  o m

            ServiceBus serviceBus = KsbApiServiceLocator.getServiceBus();
            Endpoint endpoint = serviceBus.getEndpoint(QName.valueOf(serviceName));
            if (endpoint != null) {
                version = endpoint.getServiceConfiguration().getServiceVersion();
            }
            KimTypeService service = (KimTypeService) GlobalResourceLoader
                    .getService(QName.valueOf(serviceName));
            if (service != null && service instanceof RoleTypeService) {
                roleTypeService = (RoleTypeService) service;
            } else {
                roleTypeService = (RoleTypeService) KimImplServiceLocator
                        .getService("kimNoMembersRoleTypeService");
            }
        } catch (Exception ex) {
            roleTypeService = (RoleTypeService) KimImplServiceLocator.getService("kimNoMembersRoleTypeService");
        }

        return new VersionedService<RoleTypeService>(version, roleTypeService);
    }

    return null;
}

From source file:org.kuali.rice.kim.impl.permission.PermissionServiceImpl.java

protected PermissionTypeService getPermissionTypeService(Template permissionTemplate) {
    if (permissionTemplate == null) {
        throw new IllegalArgumentException("permissionTemplate may not be null");
    }//from ww  w.j  a  v  a2s.  c  o  m
    KimType kimType = kimTypeInfoService.getKimType(permissionTemplate.getKimTypeId());
    String serviceName = kimType.getServiceName();
    // if no service specified, return a default implementation
    if (StringUtils.isBlank(serviceName)) {
        return defaultPermissionTypeService;
    }
    try {
        Object service = GlobalResourceLoader.getService(QName.valueOf(serviceName));
        // if we have a service name, it must exist
        if (service == null) {
            throw new RuntimeException(
                    "null returned for permission type service for service name: " + serviceName);
        }
        // whatever we retrieved must be of the correct type
        if (!(service instanceof PermissionTypeService)) {
            throw new RuntimeException("Service " + serviceName + " was not a PermissionTypeService.  Was: "
                    + service.getClass().getName());
        }
        return (PermissionTypeService) service;
    } catch (Exception ex) {
        // sometimes service locators throw exceptions rather than returning null, handle that
        throw new RuntimeException(
                "Error retrieving service: " + serviceName + " from the KimImplServiceLocator.", ex);
    }
}

From source file:org.kuali.rice.kim.impl.responsibility.ResponsibilityServiceImpl.java

private Map<String, ResponsibilityTypeService> getResponsibilityTypeServicesByTemplateId(
        Collection<Responsibility> responsibilities) {
    Map<String, ResponsibilityTypeService> responsibilityTypeServices = new HashMap<String, ResponsibilityTypeService>(
            responsibilities.size());//from  w  ww  .  j  av  a2s .c  o m
    for (Responsibility responsibility : responsibilities) {
        final Template t = responsibility.getTemplate();
        final KimType type = kimTypeInfoService.getKimType(t.getKimTypeId());

        final String serviceName = type.getServiceName();
        if (serviceName != null) {
            ResponsibilityTypeService responsibiltyTypeService = GlobalResourceLoader
                    .getService(QName.valueOf(serviceName));
            if (responsibiltyTypeService != null) {
                responsibilityTypeServices.put(responsibility.getTemplate().getId(), responsibiltyTypeService);
            } else {
                responsibilityTypeServices.put(responsibility.getTemplate().getId(),
                        defaultResponsibilityTypeService);
            }
        }
    }
    return Collections.unmodifiableMap(responsibilityTypeServices);
}

From source file:org.kuali.rice.kim.impl.role.RoleServiceBase.java

/**
 * Retrieves the role type service for the given service name.
 *
 * @param serviceName the name of the service to retrieve
 * @return the Role Type Service//  ww w.ja v  a 2s .co  m
 */
protected RoleTypeService getRoleTypeServiceByName(String serviceName) {
    try {
        KimTypeService service = (KimTypeService) GlobalResourceLoader.getService(QName.valueOf(serviceName));
        if (service != null && service instanceof RoleTypeService) {
            return (RoleTypeService) service;
        }
        LOG.warn("Unable to find role type service by name: " + serviceName
                + ". Defaulting to: kimNoMembersRoleTypeService ");
        return (RoleTypeService) KimImplServiceLocator.getService("kimNoMembersRoleTypeService");
    } catch (Exception ex) {
        LOG.warn("Unable to find role type service by name: " + serviceName, ex);
        return (RoleTypeService) KimImplServiceLocator.getService("kimNoMembersRoleTypeService");
    }
}