List of usage examples for javax.xml.namespace QName valueOf
public static QName valueOf(String qNameAsString)
From source file:org.kalypso.gml.processes.internal.gml.GmlPropertyTester.java
private static QName parseQName(final Object expectedValue) { final String excpectedStr = expectedValue.toString().replaceAll("\"", ""); // strip " //$NON-NLS-1$ //$NON-NLS-2$ return QName.valueOf(excpectedStr); }
From source file:org.kalypso.ogc.gml.map.properties.ThemeTester.java
private boolean testQName(final IKalypsoTheme theme, final Object expectedValue) { if (theme == null || expectedValue == null) return false; if (!(theme instanceof IKalypsoFeatureTheme)) return false; final IFeatureType featureType = ((IKalypsoFeatureTheme) theme).getFeatureType(); if (featureType == null) return false; final QName expectedQName = QName.valueOf(expectedValue.toString()); return GMLSchemaUtilities.substitutes(featureType, expectedQName); }
From source file:org.kalypso.ui.catalogs.FeatureTypePropertiesCatalog.java
private Set<QName> parseHiddenChildren(final String hiddenChildrenValue) { final Set<QName> hiddenChildren = new HashSet<>(); if (StringUtils.isBlank(hiddenChildrenValue)) return hiddenChildren; final String[] split = StringUtils.split(hiddenChildrenValue, ','); for (final String element : split) { try {/*from w w w.ja v a2 s.co m*/ final QName qname = QName.valueOf(element); hiddenChildren.add(qname); } catch (final IllegalArgumentException e) { e.printStackTrace(); } } return hiddenChildren; }
From source file:org.kalypsodeegree.xml.XMLTools.java
/** * @param name/*from w ww . ja v a 2 s .c o m*/ * @param namespace * @param node */ public static QName getQNameValue(final Element element) { if (element == null) return null; final String value = getValue(element); if (StringUtils.isBlank(value)) return null; // hack to build a qName from string presentation (QName.toString()) // this is needed as the XML-SchemaType is still xs:string and not xs:QName // according to Markus U. Mller (OGC SLD-Editor) this will change in the next version in SLD Standard final int pos = value.indexOf('}'); if (value.startsWith("{") && pos > 0) return QName.valueOf(value); QName prefixedName = parsePrefixedQName(value); String prefix = prefixedName.getPrefix(); final String namespaceURI = element.lookupNamespaceURI(prefix); return new QName(namespaceURI, prefixedName.getLocalPart(), prefix); }
From source file:org.kuali.kpme.core.role.proxy.service.KpmeRoleProxyDerivedRoleTypeServiceImpl.java
/** * Gets the derived role service for {@code role}. * //from w w w . jav a2 s .com * @param role the role * * @return the derived role service name for {@code role}. */ protected RoleTypeService getRoleTypeService(Role role) { RoleTypeService roleTypeService = null; if (role != null) { String serviceName = getDerivedRoleServiceName(role.getKimTypeId()); if (serviceName != null) { try { KimTypeService service = (KimTypeService) GlobalResourceLoader .getService(QName.valueOf(serviceName)); if (service != null && service instanceof RoleTypeService) { return (RoleTypeService) service; } } catch (Exception ex) { LOG.error("Unable to find role type service with name: " + serviceName, ex); } } } return roleTypeService; }
From source file:org.kuali.kpme.core.service.permission.HrPermissionServiceBase.java
protected PermissionTypeService getPermissionTypeService(Template permissionTemplate) { if (permissionTemplate == null) { throw new IllegalArgumentException("permissionTemplate may not be null"); }/*from w ww . j a v a 2 s . c o m*/ KimType kimType = getKimTypeInfoService().getKimType(permissionTemplate.getKimTypeId()); String serviceName = kimType.getServiceName(); // if no service specified, return a default implementation if (StringUtils.isBlank(serviceName)) { // return an instance of default service TODO: direct instantiation! return new PermissionTypeServiceBase(); } 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.core.impl.cache.DistributedCacheManagerDecorator.java
private void sendFlushCacheMessages(Collection<CacheTarget> cacheTargets) { try {/*from ww w. j a va2 s.c o m*/ if (!cacheTargets.isEmpty()) { logFlushCache(cacheTargets); // need to ensure that the list passed is serializable in order for the KSB messaging to work cacheTargets = new ArrayList<CacheTarget>(cacheTargets); CacheAdminService cacheAdminService = KsbApiServiceLocator.getMessageHelper() .getServiceAsynchronously(QName.valueOf(serviceName)); cacheAdminService.flush(cacheTargets); } } catch (Throwable t) { LOG.error("failed to execute distributed flush for serviceName " + serviceName, t); } }
From source file:org.kuali.rice.core.impl.resourceloader.BaseWrappingResourceLoader.java
@Override public void start() throws Exception { String servicesToCacheFromConfig = ConfigContext.getCurrentContextConfig() .getProperty(RiceConstants.SERVICES_TO_CACHE); if (!StringUtils.isEmpty(servicesToCacheFromConfig)) { String[] services = servicesToCacheFromConfig.split(","); for (String serviceName : services) { serviceName = serviceName.trim(); try { servicesToCache.add(QName.valueOf(serviceName)); LOG.info("Adding service " + serviceName + " to service cache."); } catch (IllegalArgumentException e) { LOG.error("Failed to parse serviceName into QName from property " + RiceConstants.SERVICES_TO_CACHE + ". Service name given was: " + serviceName); }/*from ww w. java 2 s. com*/ } } super.start(); }
From source file:org.kuali.rice.kew.api.extension.ExtensionUtils.java
/** * Loads the extension object for the given extension definition, using the default applicationId if the given * extension definition has a null applicationId. * * @param extensionDefinition the definition of the extension to load * @param defaultApplicationId the application id to use when attempting to loading the extension if the * application id on the given definition is null * @param <T> the type of the extension object which is to be loaded * * @return the loaded extension, or null if no extension was loaded for the given definition */// w w w .j av a 2 s . co m public static <T> T loadExtension(ExtensionDefinitionContract extensionDefinition, String defaultApplicationId) { T extensionService = null; // first check if the class name is a valid and available java class String resourceDescriptor = extensionDefinition.getResourceDescriptor(); ObjectDefinition extensionObjectDefinition = getExtensionObjectDefinition(extensionDefinition, defaultApplicationId); extensionService = GlobalResourceLoader.<T>getObject(extensionObjectDefinition); if (extensionService == null) { // if we can't find a class, try a service extensionService = GlobalResourceLoader.<T>getService(QName.valueOf(resourceDescriptor)); } return extensionService; }
From source file:org.kuali.rice.kew.dto.DTOConverter.java
private static Element createDocumentContentSection(Document document, Element existingAttributeElement, List<WorkflowAttributeDefinition> definitions, String content, String elementName, String documentTypeName) throws SAXException, IOException, ParserConfigurationException { Element contentSectionElement = existingAttributeElement; // if they've updated the content, we're going to re-build the content section element from scratch if (content != null) { if (!org.apache.commons.lang.StringUtils.isEmpty(content)) { contentSectionElement = document.createElement(elementName); // if they didn't merely clear the content, let's build the content section element by combining the children // of the incoming XML content Element incomingAttributeElement = XmlHelper.readXml(content).getDocumentElement(); NodeList children = incomingAttributeElement.getChildNodes(); for (int index = 0; index < children.getLength(); index++) { contentSectionElement.appendChild(document.importNode(children.item(index), true)); }//from w w w.j a v a2 s. co m } else { contentSectionElement = null; } } // if they have new definitions we're going to append those to the existing content section if (definitions != null && !definitions.isEmpty()) { String errorMessage = ""; boolean inError = false; if (contentSectionElement == null) { contentSectionElement = document.createElement(elementName); } for (WorkflowAttributeDefinition definitionVO : definitions) { AttributeDefinition definition = convertWorkflowAttributeDefinition(definitionVO); ExtensionDefinition extensionDefinition = definition.getExtensionDefinition(); Object attribute = null; attribute = GlobalResourceLoader.getObject(definition.getObjectDefinition()); if (attribute == null) { attribute = GlobalResourceLoader .getService(QName.valueOf(definition.getExtensionDefinition().getResourceDescriptor())); } if (attribute instanceof XmlConfiguredAttribute) { ((XmlConfiguredAttribute) attribute) .setExtensionDefinition(definition.getExtensionDefinition()); } boolean propertiesAsMap = false; if (KewApiConstants.RULE_XML_ATTRIBUTE_TYPE.equals(extensionDefinition.getType())) { propertiesAsMap = true; } if (propertiesAsMap) { for (org.kuali.rice.kew.api.document.PropertyDefinition propertyDefinitionVO : definitionVO .getPropertyDefinitions()) { if (attribute instanceof GenericXMLRuleAttribute) { ((GenericXMLRuleAttribute) attribute).getParamMap().put(propertyDefinitionVO.getName(), propertyDefinitionVO.getValue()); } } } // validate inputs from client application if the attribute is capable if (attribute instanceof WorkflowAttributeXmlValidator) { List<? extends RemotableAttributeErrorContract> errors = ((WorkflowAttributeXmlValidator) attribute) .validateClientRoutingData(); if (!errors.isEmpty()) { inError = true; errorMessage += "Error validating attribute " + definitionVO.getAttributeName() + " "; errorMessage += Joiner.on("; ") .join(Iterables.transform(errors, Functions.toStringFunction())); } } // dont add to xml if attribute is in error if (!inError) { if (attribute instanceof WorkflowRuleAttribute) { String attributeDocContent = ((WorkflowRuleAttribute) attribute).getDocContent(); if (!StringUtils.isEmpty(attributeDocContent)) { XmlHelper.appendXml(contentSectionElement, attributeDocContent); } } else if (attribute instanceof SearchableAttribute) { SearchableAttribute searchableAttribute = (SearchableAttribute) attribute; String searchableAttributeContent = searchableAttribute .generateSearchContent(extensionDefinition, documentTypeName, definitionVO); if (!StringUtils.isBlank(searchableAttributeContent)) { XmlHelper.appendXml(contentSectionElement, searchableAttributeContent); } } } } if (inError) { throw new WorkflowRuntimeException(errorMessage); } } if (contentSectionElement != null) { // always be sure and import the element into the new document, if it originated from the existing doc content // and // appended to it, it will need to be imported contentSectionElement = (Element) document.importNode(contentSectionElement, true); } return contentSectionElement; }