public OperationSelectorJMSUserProp read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { OperationSelectorJMSUserProp opSelector = new OperationSelectorJMSUserProp(); String propertyName = reader.getAttributeValue(null, OperationSelectorJMSUserProp.OPERATION_SELECTOR_JMS_USERPROP_ATTR); if (propertyName != null && propertyName.length() > 0) { opSelector.setPropertyName(propertyName); } else { throw new ContributionReadException(OperationSelectorJMSUserProp.OPERATION_SELECTOR_JMS_USERPROP_QNAME.toString() + ": " + OperationSelectorJMSUserProp.OPERATION_SELECTOR_JMS_USERPROP_ATTR + " is a required attribute."); } return opSelector; }
e.setLine(location.getLineNumber()); e.setColumn(location.getColumnNumber()); error(monitor, "ContributionReadException", reader, e); throw e; ContributionReadException ce = new ContributionReadException(e); error(monitor, "ContributionReadException", inputFactory, ce); throw ce;
public synchronized List<Definitions> getDefinitions() { if (!loaded) { loadDefinitionsDocuments(); URLArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); URLArtifactProcessor<Definitions> processor = processors.getProcessor(Definitions.class); ProcessorContext context = new ProcessorContext(monitorFactory.createMonitor()); for (URL url : documents) { Definitions def; try { def = processor.read(null, DEFINITIONS_URI, url, context); definitions.add(def); } catch (ContributionReadException e) { logger.log(Level.SEVERE, e.getMessage(), e); } } loaded = true; } return definitions; }
public synchronized List<Definitions> getDefinitions() { if (!loaded) { loadDefinitionsDocuments(); URLArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); URLArtifactProcessor<Definitions> processor = processors.getProcessor(Definitions.class); ProcessorContext context = new ProcessorContext(monitorFactory.createMonitor()); for (URL url : documents) { Definitions def; try { def = processor.read(null, DEFINITIONS_URI, url, context); definitions.add(def); } catch (ContributionReadException e) { logger.log(Level.SEVERE, e.getMessage(), e); } } loaded = true; } return definitions; }
public OperationSelectorJMSUserProp read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { OperationSelectorJMSUserProp opSelector = new OperationSelectorJMSUserProp(); String propertyName = reader.getAttributeValue(null, OperationSelectorJMSUserProp.OPERATION_SELECTOR_JMS_USERPROP_ATTR); if (propertyName != null && propertyName.length() > 0) { opSelector.setPropertyName(propertyName); } else { throw new ContributionReadException(OperationSelectorJMSUserProp.OPERATION_SELECTOR_JMS_USERPROP_QNAME.toString() + ": " + OperationSelectorJMSUserProp.OPERATION_SELECTOR_JMS_USERPROP_ATTR + " is a required attribute."); } return opSelector; }
e.setLine(location.getLineNumber()); e.setColumn(location.getColumnNumber()); error(monitor, "ContributionReadException", reader, e); throw e; ContributionReadException ce = new ContributionReadException(e); error(monitor, "ContributionReadException", inputFactory, ce); throw ce;
/** * Get the contribution location as a file * * @param contribution * @return * @throws ContributionReadException */ private File directory(Contribution contribution) throws ContributionReadException { File file; URI uri = null; try { uri = new URI(contribution.getLocation()); file = new File(uri); } catch (URISyntaxException e) { throw new ContributionReadException(e); } catch(IllegalArgumentException e) { // Hack for file:./a.txt or file:../a/c.wsdl return new File(uri.getPath()); } if (!file.exists() || !file.isDirectory()) { throw new ContributionReadException(contribution.getLocation()); } return file; }
/** * Get the contribution location as a file * * @param contribution * @return * @throws ContributionReadException */ private File directory(Contribution contribution) throws ContributionReadException { File file; URI uri = null; try { uri = new URI(contribution.getLocation()); file = new File(uri); } catch (URISyntaxException e) { throw new ContributionReadException(e); } catch(IllegalArgumentException e) { // Hack for file:./a.txt or file:../a/c.wsdl return new File(uri.getPath()); } if (!file.exists() || !file.isDirectory()) { throw new ContributionReadException(contribution.getLocation()); } return file; }
/** * Produces a location URL for a given artifact in the contribution * * @param contribution * @param artifact * @return * @throws ContributionReadException */ private static URL getArtifactURL(Contribution contribution, String artifact) throws ContributionReadException { try { URL url; if (contribution.toString().startsWith("jar:")) { url = new URL(new URL(contribution.getLocation()), artifact.toString()); } else { url = new URL("jar:" + contribution.getLocation() + "!/" + artifact); } return url; } catch (MalformedURLException e) { throw new ContributionReadException(e); } } }
public WireFormatJMSDefault read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { WireFormatJMSDefault wireFormat = new WireFormatJMSDefault(); String sendFormat = reader.getAttributeValue(null, WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_FORMAT_ATTR); if (sendFormat != null && sendFormat.length() > 0) { if (WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_TEXT_FORMAT_VAL.equalsIgnoreCase(sendFormat)) { wireFormat.setUseBytesMessage(false); }else if (WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_BYTES_FORMAT_VAL.equalsIgnoreCase(sendFormat)) { wireFormat.setUseBytesMessage(true); }else{ throw new ContributionReadException(WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_QNAME.toString() +" " +sendFormat + " is not a valid attribute value for " + WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_FORMAT_ATTR); } } return wireFormat; }
public WireFormatJMSObject read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { WireFormatJMSObject wireFormat = new WireFormatJMSObject(); String wrappedSingleInput = reader.getAttributeValue(null, WireFormatJMSObject.WIRE_FORMAT_JMS_OBJECT_WRAP_SINGLE_ATTR); if (wrappedSingleInput != null && wrappedSingleInput.length() > 0) { if ("true".equalsIgnoreCase(wrappedSingleInput)) { wireFormat.setWrappedSingleInput(true); } else if ("false".equalsIgnoreCase(wrappedSingleInput)) { wireFormat.setWrappedSingleInput(false); } else { throw new ContributionReadException(WireFormatJMSObject.WIRE_FORMAT_JMS_BYTES_QNAME.toString() + ": " + wrappedSingleInput + " is not a valid attribute value for " + WireFormatJMSObject.WIRE_FORMAT_JMS_OBJECT_WRAP_SINGLE_ATTR); } } return wireFormat; }
public WireFormatJMSObject read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { WireFormatJMSObject wireFormat = new WireFormatJMSObject(); String wrappedSingleInput = reader.getAttributeValue(null, WireFormatJMSObject.WIRE_FORMAT_JMS_OBJECT_WRAP_SINGLE_ATTR); if (wrappedSingleInput != null && wrappedSingleInput.length() > 0) { if ("true".equalsIgnoreCase(wrappedSingleInput)) { wireFormat.setWrappedSingleInput(true); } else if ("false".equalsIgnoreCase(wrappedSingleInput)) { wireFormat.setWrappedSingleInput(false); } else { throw new ContributionReadException(WireFormatJMSObject.WIRE_FORMAT_JMS_BYTES_QNAME.toString() + ": " + wrappedSingleInput + " is not a valid attribute value for " + WireFormatJMSObject.WIRE_FORMAT_JMS_OBJECT_WRAP_SINGLE_ATTR); } } return wireFormat; }
public WireFormatJMSDefault read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { WireFormatJMSDefault wireFormat = new WireFormatJMSDefault(); String sendFormat = reader.getAttributeValue(null, WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_FORMAT_ATTR); if (sendFormat != null && sendFormat.length() > 0) { if (WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_TEXT_FORMAT_VAL.equalsIgnoreCase(sendFormat)) { wireFormat.setUseBytesMessage(false); }else if (WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_BYTES_FORMAT_VAL.equalsIgnoreCase(sendFormat)) { wireFormat.setUseBytesMessage(true); }else{ throw new ContributionReadException(WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_QNAME.toString() +" " +sendFormat + " is not a valid attribute value for " + WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_FORMAT_ATTR); } } return wireFormat; }
/** * Produces a location URL for a given artifact in the contribution * * @param contribution * @param artifact * @return * @throws ContributionReadException */ private static URL getArtifactURL(Contribution contribution, String artifact) throws ContributionReadException { try { URL url; if (contribution.toString().startsWith("jar:")) { url = new URL(new URL(contribution.getLocation()), artifact.toString()); } else { url = new URL("jar:" + contribution.getLocation() + "!/" + artifact); } return url; } catch (MalformedURLException e) { throw new ContributionReadException(e); } } }
/** * Scan the contribution to retrieve all artifact uris * * @param contribution * @return * @throws ContributionReadException */ private List<String> scanContributionArtifacts(Contribution contribution) throws ContributionReadException { File directory = directory(contribution); List<String> artifacts = new ArrayList<String>(); // [rfeng] There are cases that the folder contains symbolic links that point to the same physical directory Set<File> visited = new HashSet<File>(); try { traverse(artifacts, directory, directory, visited); } catch (IOException e) { throw new ContributionReadException(e); } return artifacts; }
/** * Scan the contribution to retrieve all artifact uris * * @param contribution * @return * @throws ContributionReadException */ private List<String> scanContributionArtifacts(Contribution contribution) throws ContributionReadException { File directory = directory(contribution); List<String> artifacts = new ArrayList<String>(); // [rfeng] There are cases that the folder contains symbolic links that point to the same physical directory Set<File> visited = new HashSet<File>(); try { traverse(artifacts, directory, directory, visited); } catch (IOException e) { throw new ContributionReadException(e); } return artifacts; }
public ServiceDescriptions read(URL contributionURL, URI artifactURI, URL artifactURL, ProcessorContext context) throws ContributionReadException { InputStream is = null; try { URLConnection connection = artifactURL.openConnection(); connection.setUseCaches(false); is = connection.getInputStream(); } catch (IOException e) { ContributionReadException ce = new ContributionReadException(e); throw ce; } try { XMLStreamReader reader = inputFactory.createXMLStreamReader(is); ValidatingXMLInputFactory.setMonitor(reader, context.getMonitor()); Object result = extensionProcessor.read(reader, context); return (ServiceDescriptions)result; } catch (XMLStreamException e) { ContributionReadException ce = new ContributionReadException(e); throw ce; } finally { try { if (is != null) { is.close(); is = null; } } catch (IOException ioe) { //ignore } } }
public List<Artifact> scan(Contribution contribution) throws ContributionReadException { try { List<Artifact> artifacts = new ArrayList<Artifact>(); URL location = new URL(contribution.getLocation()); URL root = servletContext.getResource("/"); URI relative = root.toURI().relativize(location.toURI()); String path = relative.getPath(); if (!path.startsWith("/")) { path = "/" + path; } for (Object file : servletContext.getResourcePaths(path)) { Artifact artifact = contributionFactory.createArtifact(); String name = (String)file; // Remove leading / name = name.substring(1); artifact.setURI(name); URL artifactURL = new URL(location, name); artifact.setLocation(artifactURL.toString()); artifacts.add(artifact); } return artifacts; } catch (Exception e) { throw new ContributionReadException(e); } }
/** * Processes a partnerLink element from the BPEL process and creates a * BPELPartnerLink object * * @param reader */ private BPELPartnerLinkElement processPartnerLinkElement(XMLStreamReader reader, Monitor monitor) throws ContributionReadException { BPELPartnerLinkElement partnerLink = new BPELPartnerLinkElement( reader.getAttributeValue(null, "name"), getQNameValue(reader, reader.getAttributeValue(null, "partnerLinkType")), reader.getAttributeValue(null, "myRole"), reader.getAttributeValue(null, "partnerRole")); // See if there are any SCA extension attributes String scaService = reader.getAttributeValue(BPELProcessorConstants.SCA_BPEL_NS, "service"); String scaReference = reader.getAttributeValue(BPELProcessorConstants.SCA_BPEL_NS, "reference"); if ((scaService != null) && (scaReference != null)) { // It is incorrect to set both service & reference attributes error(monitor, "PartnerLinkHasBothAttr", partnerLink, reader.getAttributeValue(null, "name")); throw new ContributionReadException("BPEL PartnerLink " + reader.getAttributeValue(null, "name") + " has both sca:reference and sca:service attributes set"); } // end if // Set the SCA type and the related name, if present if (scaService != null) partnerLink.setAsService(scaService); else if (scaReference != null) partnerLink.setAsReference(scaReference); return partnerLink; } // end processPartnerLinkElement
/** * Processes a partnerLink element from the BPEL process and creates a * BPELPartnerLink object * * @param reader */ private BPELPartnerLinkElement processPartnerLinkElement(XMLStreamReader reader, Monitor monitor) throws ContributionReadException { BPELPartnerLinkElement partnerLink = new BPELPartnerLinkElement( reader.getAttributeValue(null, "name"), getQNameValue(reader, reader.getAttributeValue(null, "partnerLinkType")), reader.getAttributeValue(null, "myRole"), reader.getAttributeValue(null, "partnerRole")); // See if there are any SCA extension attributes String scaService = reader.getAttributeValue(BPELProcessorConstants.SCA_BPEL_NS, "service"); String scaReference = reader.getAttributeValue(BPELProcessorConstants.SCA_BPEL_NS, "reference"); if ((scaService != null) && (scaReference != null)) { // It is incorrect to set both service & reference attributes error(monitor, "PartnerLinkHasBothAttr", partnerLink, reader.getAttributeValue(null, "name")); throw new ContributionReadException("BPEL PartnerLink " + reader.getAttributeValue(null, "name") + " has both sca:reference and sca:service attributes set"); } // end if // Set the SCA type and the related name, if present if (scaService != null) partnerLink.setAsService(scaService); else if (scaReference != null) partnerLink.setAsReference(scaReference); return partnerLink; } // end processPartnerLinkElement