org.apache.ws.commons.schema.XmlSchemaAppInfo Java Examples
The following examples show how to use
org.apache.ws.commons.schema.XmlSchemaAppInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WSDLParameter.java From cxf with Apache License 2.0 | 6 votes |
private boolean isObjectReference(SchemaCollection schemaList, QName name) { for (XmlSchema schema : schemaList.getXmlSchemas()) { XmlSchemaElement element = schema.getElementByName(name); if (element != null) { XmlSchemaAnnotation annotation = element.getAnnotation(); if (annotation != null) { List<XmlSchemaAnnotationItem> annotationColl = annotation.getItems(); for (XmlSchemaAnnotationItem item : annotationColl) { if (item instanceof XmlSchemaAppInfo) { return true; } } } } } return false; }
Example #2
Source File: DidSchemaParser.java From secure-data-service with Apache License 2.0 | 6 votes |
/** * Parse an annotation for keyfields and add to a map */ private Map<String, String> parseAnnotationForKeyField(XmlSchemaAnnotation annotation) { Map<String, String> keyField = new HashMap<String, String>(); XmlSchemaAppInfo appInfo = getAppInfo(annotation); if (appInfo != null) { NodeList nodes = appInfo.getMarkup(); for (int nodeIdx = 0; nodeIdx < nodes.getLength(); nodeIdx++) { Node node = nodes.item(nodeIdx); if (node instanceof Element) { String key = node.getLocalName().trim(); String value = node.getFirstChild().getNodeValue().trim(); if (key.equals(REF_TYPE) || key.equals(KEY_FIELD_NAME)) { keyField.put(key, value); } } } } return keyField; }
Example #3
Source File: DidSchemaParser.java From secure-data-service with Apache License 2.0 | 6 votes |
/** * Parse an annotation for recordType annotation */ private String parseAnnotationForRecordType(XmlSchemaAnnotation annotation) { String recordType = null; XmlSchemaAppInfo appInfo = getAppInfo(annotation); if (appInfo != null) { NodeList nodes = appInfo.getMarkup(); for (int nodeIdx = 0; nodeIdx < nodes.getLength(); nodeIdx++) { Node node = nodes.item(nodeIdx); if (node instanceof Element) { String key = node.getLocalName().trim(); String value = node.getFirstChild().getNodeValue().trim(); if (key.equals(RECORD_TYPE)) { recordType = value; break; } } } } return recordType; }
Example #4
Source File: DidSchemaParser.java From secure-data-service with Apache License 2.0 | 6 votes |
/** * Parse an annotation for naturalKeys annotation */ private String parseAnnotationForNaturalKeys(XmlSchemaAnnotation annotation) { String naturalKeys = null; XmlSchemaAppInfo appInfo = getAppInfo(annotation); if (appInfo != null) { NodeList nodes = appInfo.getMarkup(); for (int nodeIdx = 0; nodeIdx < nodes.getLength(); nodeIdx++) { Node node = nodes.item(nodeIdx); if (node instanceof Element) { String key = node.getLocalName().trim(); String value = node.getFirstChild().getNodeValue().trim(); if (key.equals("naturalKeys")) { naturalKeys = value; break; } } } } return naturalKeys; }
Example #5
Source File: Xsd2UmlConvert.java From secure-data-service with Apache License 2.0 | 5 votes |
/** * The xs:annotation is parsed into {@link TaggedValue} with one entry per * xs:documentation or xs:appinfo. */ private static final List<TaggedValue> annotations(final XmlSchemaAnnotated schemaType, final Xsd2UmlConfig config) { if (schemaType == null) { return EMPTY_TAGGED_VALUES; } final XmlSchemaAnnotation annotation = schemaType.getAnnotation(); if (annotation == null) { return EMPTY_TAGGED_VALUES; } else { final List<TaggedValue> taggedValues = new LinkedList<TaggedValue>(); final XmlSchemaObjectCollection children = annotation.getItems(); for (int childIdx = 0; childIdx < children.getCount(); ++childIdx) { final XmlSchemaObject child = children.getItem(childIdx); if (child instanceof XmlSchemaDocumentation) { final XmlSchemaDocumentation documentation = (XmlSchemaDocumentation) child; taggedValues.add(documentation(documentation, config)); } else if (child instanceof XmlSchemaAppInfo) { final XmlSchemaAppInfo appInfo = (XmlSchemaAppInfo) child; taggedValues.addAll(config.getPlugin().tagsFromAppInfo(appInfo, config)); } else { throw new AssertionError(child); } } return taggedValues; } }
Example #6
Source File: XsdToNeutralSchemaRepo.java From secure-data-service with Apache License 2.0 | 5 votes |
private void parseAppInfo(NeutralSchema neutralSchema, XmlSchemaType schemaType) { XmlSchemaObjectCollection annotations = schemaType.getAnnotation().getItems(); for (int annotationIdx = 0; annotationIdx < annotations.getCount(); ++annotationIdx) { XmlSchemaObject annotation = annotations.getItem(annotationIdx); if (annotation instanceof XmlSchemaAppInfo) { XmlSchemaAppInfo info = (XmlSchemaAppInfo) annotation; neutralSchema.addAnnotation(new AppInfo(info.getMarkup())); } } }
Example #7
Source File: DidSchemaParser.java From secure-data-service with Apache License 2.0 | 5 votes |
/** * Parse an annotation for DidRefSource data */ private DidRefSource parseAnnotationForRef(XmlSchemaAnnotation annotation) { DidRefSource refSource = null; boolean applyKeyFields = false; String refType = null; XmlSchemaAppInfo appInfo = getAppInfo(annotation); if (appInfo != null) { // get applyKeyFields and refType from appInfo NodeList nodes = appInfo.getMarkup(); for (int nodeIdx = 0; nodeIdx < nodes.getLength(); nodeIdx++) { Node node = nodes.item(nodeIdx); if (node instanceof Element) { String key = node.getLocalName().trim(); String value = node.getFirstChild().getNodeValue().trim(); if (key.equals(APPLY_KEY_FIELDS)) { if (value.equals("true")) { applyKeyFields = true; } } else if (key.equals(REF_TYPE)) { refType = value; } } } if (applyKeyFields && refType != null) { refSource = new DidRefSource(); refSource.setEntityType(refType); } } return refSource; }
Example #8
Source File: CobolAnnotations.java From legstar-core2 with GNU Affero General Public License v3.0 | 5 votes |
/** * XSD elements are annotated with COBOL markup that we extract here. * * @param xsdElement the XSD element * @return the COBOL markup */ private static Element getCobolXsdAnnotations(XmlSchemaElement xsdElement) { XmlSchemaAnnotation annotation = xsdElement.getAnnotation(); if (annotation == null || annotation.getItems().size() == 0) { throw new IllegalArgumentException("Xsd element of type " + xsdElement.getSchemaType().getQName() + " at line " + xsdElement.getLineNumber() + " does not have COBOL annotations"); } XmlSchemaAppInfo appinfo = (XmlSchemaAppInfo) annotation.getItems() .get(0); if (appinfo.getMarkup() == null) { throw new IllegalArgumentException("Xsd element of type " + xsdElement.getSchemaType().getQName() + " does not have any markup in its annotations"); } Node node = null; boolean found = false; for (int i = 0; i < appinfo.getMarkup().getLength(); i++) { node = appinfo.getMarkup().item(i); if (node instanceof Element && node.getLocalName().equals(CobolMarkup.ELEMENT) && node.getNamespaceURI().equals(CobolMarkup.NS)) { found = true; break; } } if (!found) { throw new IllegalArgumentException("Xsd element of type " + xsdElement.getSchemaType().getQName() + " at line " + xsdElement.getLineNumber() + " does not have any COBOL annotations"); } return (Element) node; }
Example #9
Source File: ObjectReferenceVisitor.java From cxf with Apache License 2.0 | 4 votes |
private void isDuplicateReference(QName referenceName, QName bindingName, Scope refScope, XmlSchemaType wsaType, AST node) { XmlSchema refSchema = null; if (!mapper.isDefaultMapping()) { String tns = mapper.map(refScope.getParent()); String refSchemaFileName = getWsdlVisitor().getOutputDir() + System.getProperty("file.separator") + refScope.getParent().toString("_") + ".xsd"; refSchema = manager.getXmlSchema(tns); if (refSchema == null) { refSchema = manager.createXmlSchema(tns, wsdlVisitor.getSchemas()); } addWSAddressingImport(refSchema); manager.addXmlSchemaImport(schema, refSchema, refSchemaFileName); } else { refSchema = schema; } // Check to see if we have already defined an element for this reference type. If // we have, then there is no need to add it to the schema again. if (!isReferenceSchemaTypeDefined(referenceName, refSchema)) { // We need to add a new element definition to the schema section of our WSDL. // For custom endpoint types, this should contain an annotation which points // to the binding which will be used for this endpoint type. XmlSchemaElement refElement = new XmlSchemaElement(schema, true); refElement.setName(referenceName.getLocalPart()); refElement.setSchemaType(wsaType); refElement.setSchemaTypeName(wsaType.getQName()); // Create an annotation which contains the CORBA binding for the element XmlSchemaAnnotation annotation = new XmlSchemaAnnotation(); XmlSchemaAppInfo appInfo = new XmlSchemaAppInfo(); try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.newDocument(); Element el = doc.createElement("appinfo"); el.setTextContent("corba:binding=" + bindingName.getLocalPart()); // TODO: This is correct but the appinfo markup is never added to the // schema. Investigate. appInfo.setMarkup(el.getChildNodes()); } catch (ParserConfigurationException ex) { throw new RuntimeException("[ObjectReferenceVisitor: error creating endpoint schema]"); } annotation.getItems().add(appInfo); refElement.setAnnotation(annotation); } }
Example #10
Source File: Xsd2UmlPluginForEdFi.java From secure-data-service with Apache License 2.0 | 4 votes |
@Override public List<TaggedValue> tagsFromAppInfo(final XmlSchemaAppInfo appInfo, final Xsd2UmlPluginHost host) { throw new UnsupportedOperationException(); }
Example #11
Source File: XsdAnnotationEmitter.java From legstar-core2 with GNU Affero General Public License v3.0 | 4 votes |
/** * Create an XML Schema annotation with markup corresponding to the original * COBOL data item attributes. * * @param xsdDataItem COBOL data item decorated with XSD attributes * @return an XML schema annotation */ public XmlSchemaAnnotation createLegStarAnnotation( final XsdDataItem xsdDataItem) { Document doc = _docBuilder.newDocument(); Element el = doc.createElementNS(getCOXBNamespace(), getCOXBElements()); Element elc = doc.createElementNS(getCOXBNamespace(), getCOXBElement()); elc.setAttribute(CobolMarkup.LEVEL_NUMBER, Integer.toString(xsdDataItem.getLevelNumber())); elc.setAttribute(CobolMarkup.COBOL_NAME, xsdDataItem.getCobolName()); elc.setAttribute(CobolMarkup.TYPE, xsdDataItem.getCobolType() .toString()); if (xsdDataItem.getCobolType() != CobolTypes.GROUP_ITEM) { if (xsdDataItem.getPicture() != null) { elc.setAttribute(CobolMarkup.PICTURE, xsdDataItem.getPicture()); } if (xsdDataItem.getUsage() != null) { elc.setAttribute(CobolMarkup.USAGE, xsdDataItem.getUsageForCobol()); } if (xsdDataItem.isJustifiedRight()) { elc.setAttribute(CobolMarkup.IS_JUSTIFIED_RIGHT, "true"); } if (xsdDataItem.getTotalDigits() > 0) { elc.setAttribute(CobolMarkup.IS_SIGNED, (xsdDataItem.isSigned()) ? "true" : "false"); elc.setAttribute(CobolMarkup.TOTAL_DIGITS, Integer.toString(xsdDataItem.getTotalDigits())); if (xsdDataItem.getFractionDigits() > 0) { elc.setAttribute(CobolMarkup.FRACTION_DIGITS, Integer.toString(xsdDataItem.getFractionDigits())); } if (xsdDataItem.isSignLeading()) { elc.setAttribute(CobolMarkup.IS_SIGN_LEADING, "true"); } if (xsdDataItem.isSignSeparate()) { elc.setAttribute(CobolMarkup.IS_SIGN_SEPARATE, "true"); } } } /* * Annotations transfer the COBOL occurs semantic (as opposed to the XSD * semantic). No depending on => fixed size array */ if (xsdDataItem.getCobolMaxOccurs() > 0) { elc.setAttribute(CobolMarkup.MAX_OCCURS, Integer.toString(xsdDataItem.getCobolMaxOccurs())); if (xsdDataItem.getDependingOn() == null) { elc.setAttribute(CobolMarkup.MIN_OCCURS, Integer.toString(xsdDataItem.getCobolMaxOccurs())); } else { elc.setAttribute(CobolMarkup.DEPENDING_ON, xsdDataItem.getDependingOn()); elc.setAttribute(CobolMarkup.MIN_OCCURS, Integer.toString(xsdDataItem.getCobolMinOccurs())); } } if (xsdDataItem.isODOObject()) { elc.setAttribute(CobolMarkup.IS_ODO_OBJECT, "true"); } if (xsdDataItem.getRedefines() != null) { elc.setAttribute(CobolMarkup.REDEFINES, xsdDataItem.getRedefines()); } if (xsdDataItem.isRedefined()) { elc.setAttribute(CobolMarkup.IS_REDEFINED, "true"); elc.setAttribute(CobolMarkup.UNMARSHAL_CHOICE_STRATEGY, ""); } if (xsdDataItem.getValue() != null && xsdDataItem.getValue().length() > 0) { elc.setAttribute(CobolMarkup.VALUE, ValueUtil.resolveFigurative( xsdDataItem.getValue(), xsdDataItem.getMaxStorageLength(), getConfig().quoteIsQuote())); } if (xsdDataItem.getSrceLine() > 0) { elc.setAttribute(CobolMarkup.SRCE_LINE, Integer.toString(xsdDataItem.getSrceLine())); } el.appendChild(elc); XmlSchemaAppInfo appInfo = new XmlSchemaAppInfo(); appInfo.setMarkup(el.getChildNodes()); /* Create annotation */ XmlSchemaAnnotation annotation = new XmlSchemaAnnotation(); annotation.getItems().add(appInfo); return annotation; }
Example #12
Source File: Xsd2UmlPluginHostAdapter.java From secure-data-service with Apache License 2.0 | 4 votes |
@Override public List<TaggedValue> tagsFromAppInfo(final XmlSchemaAppInfo appInfo, final Xsd2UmlPluginHost host) { return Collections.emptyList(); }
Example #13
Source File: Xsd2UmlPluginGeneric.java From secure-data-service with Apache License 2.0 | 4 votes |
@Override public List<TaggedValue> tagsFromAppInfo(final XmlSchemaAppInfo appInfo, final Xsd2UmlPluginHost host) { throw new UnsupportedOperationException(); }
Example #14
Source File: Xsd2UmlPluginGenericTest.java From secure-data-service with Apache License 2.0 | 4 votes |
/** * Method: tagsFromAppInfo(final XmlSchemaAppInfo appInfo, final Xsd2UmlPluginHost host) */ @Test(expected = UnsupportedOperationException.class) public void testTagsFromAppInfo() throws Exception { XmlSchemaAppInfo appInfo = Mockito.mock(XmlSchemaAppInfo.class); generic.tagsFromAppInfo(appInfo, host); }
Example #15
Source File: Xsd2UmlPluginDefaultTest.java From secure-data-service with Apache License 2.0 | 4 votes |
public List<TaggedValue> tagsFromAppInfo(XmlSchemaAppInfo appInfo, Xsd2UmlPluginHost host) { return Collections.emptyList(); }
Example #16
Source File: Xsd2UmlPluginForSLITest.java From secure-data-service with Apache License 2.0 | 4 votes |
/** * * Method: tagsFromAppInfo(final XmlSchemaAppInfo appInfo, final Xsd2UmlPluginHost host) * */ @Test public void testTagsFromAppInfo() throws Exception { XmlSchemaAppInfo xmlSchemaAppInfo = Mockito.mock(XmlSchemaAppInfo.class); Xsd2UmlPluginHost host = Mockito.mock(Xsd2UmlPluginHost.class); NodeList nodeList = Mockito.mock(NodeList.class); Element node = Mockito.mock(Element.class); Mockito.when(host.ensureTagDefinitionId(Mockito.anyString())).thenReturn(Identifier.random()); Mockito.when(xmlSchemaAppInfo.getMarkup()).thenReturn(nodeList); Mockito.when(nodeList.item(Matchers.anyInt())).thenReturn(node); Mockito.when(nodeList.getLength()).thenReturn(1); Mockito.when(node.getNodeType()).thenReturn(Node.ELEMENT_NODE); Mockito.when(node.getNamespaceURI()).thenReturn(SliMongoConstants.NAMESPACE_SLI); Mockito.when(node.getLocalName()).thenReturn("CollectionType"); Mockito.when(node.getChildNodes()).thenReturn(nodeList); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("naturalKey"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("applyNaturalKeys"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("PersonallyIdentifiableInfo"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("ReferenceType"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("ReadEnforcement"); Mockito.when(node.getTextContent()).thenReturn("READ_RESTRICTED"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("SecuritySphere"); Mockito.when(node.getTextContent()).thenReturn("Public"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("RelaxedBlacklist"); Mockito.when(node.getTextContent()).thenReturn("true"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("RestrictedForLogging"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("WriteEnforcement"); Mockito.when(node.getTextContent()).thenReturn("WRITE_RESTRICTED"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("schemaVersion"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); }
Example #17
Source File: Xsd2UmlPluginHostAdapterTest.java From secure-data-service with Apache License 2.0 | 2 votes |
/** * * Method: tagsFromAppInfo(final XmlSchemaAppInfo appInfo, final Xsd2UmlPluginHost host) * */ @Test public void testTagsFromAppInfo() throws Exception { Assert.assertEquals(Collections.emptyList(), adapter.tagsFromAppInfo(new XmlSchemaAppInfo(), host)); }
Example #18
Source File: Xsd2UmlHostedPlugin.java From secure-data-service with Apache License 2.0 | votes |
List<TaggedValue> tagsFromAppInfo(XmlSchemaAppInfo appInfo, Xsd2UmlPluginHost host);