List of usage examples for javax.xml.xpath XPathConstants STRING
QName STRING
To view the source code for javax.xml.xpath XPathConstants STRING.
Click Source Link
The XPath 1.0 string data type.
Maps to Java String .
From source file:org.opencastproject.mediapackage.elementbuilder.AbstractAttachmentBuilderPlugin.java
/** * This implementation of <code>accept</code> tests for the correct node type (attachment). * /*from w w w . jav a 2 s.c o m*/ * @see org.opencastproject.mediapackage.elementbuilder.MediaPackageElementBuilderPlugin#accept(org.w3c.dom.Node) */ public boolean accept(Node elementNode) { try { // Test for attachment String nodeName = elementNode.getNodeName(); if (nodeName.contains(":")) { nodeName = nodeName.substring(nodeName.indexOf(":") + 1); } if (!MediaPackageElement.Type.Attachment.toString().equalsIgnoreCase(nodeName)) return false; // Check flavor if (this.flavor != null) { String nodeFlavor = (String) xpath.evaluate("@type", elementNode, XPathConstants.STRING); if (!flavor.eq(nodeFlavor)) return false; } // Check mime type if (mimeTypes != null && mimeTypes.size() > 0) { String nodeMimeType = (String) xpath.evaluate("mimetype", elementNode, XPathConstants.STRING); MimeType mimeType = MimeTypes.parseMimeType(nodeMimeType); if (!mimeTypes.contains(mimeType)) return false; } return true; } catch (XPathExpressionException e) { logger.warn("Error while reading attachment flavor from manifest: " + e.getMessage()); return false; } }
From source file:org.opencastproject.mediapackage.elementbuilder.AbstractAttachmentBuilderPlugin.java
/** * @see org.opencastproject.mediapackage.elementbuilder.MediaPackageElementBuilderPlugin#elementFromManifest(org.w3c.dom.Node, * org.opencastproject.mediapackage.MediaPackageSerializer) */// w w w.jav a 2 s.c om public MediaPackageElement elementFromManifest(Node elementNode, MediaPackageSerializer serializer) throws UnsupportedElementException { String id = null; String attachmentFlavor = null; String reference = null; URI uri = null; long size = -1; Checksum checksum = null; MimeType mimeType = null; try { // id id = (String) xpath.evaluate("@id", elementNode, XPathConstants.STRING); // flavor attachmentFlavor = (String) xpath.evaluate("@type", elementNode, XPathConstants.STRING); // reference reference = (String) xpath.evaluate("@ref", elementNode, XPathConstants.STRING); // url uri = serializer.resolvePath(xpath.evaluate("url/text()", elementNode).trim()); // size String attachmentSize = xpath.evaluate("size/text()", elementNode).trim(); if (!"".equals(attachmentSize)) size = Long.parseLong(attachmentSize); // checksum String checksumValue = (String) xpath.evaluate("checksum/text()", elementNode, XPathConstants.STRING); String checksumType = (String) xpath.evaluate("checksum/@type", elementNode, XPathConstants.STRING); if (StringUtils.isNotEmpty(checksumValue) && checksumType != null) checksum = Checksum.create(checksumType.trim(), checksumValue.trim()); // mimetype String mimeTypeValue = (String) xpath.evaluate("mimetype/text()", elementNode, XPathConstants.STRING); if (StringUtils.isNotEmpty(mimeTypeValue)) mimeType = MimeTypes.parseMimeType(mimeTypeValue); // create the attachment AttachmentImpl attachment = (AttachmentImpl) AttachmentImpl.fromURI(uri); if (StringUtils.isNotEmpty(id)) attachment.setIdentifier(id); // Add url attachment.setURI(uri); // Add reference if (StringUtils.isNotEmpty(reference)) attachment.referTo(MediaPackageReferenceImpl.fromString(reference)); // Add type/flavor information if (StringUtils.isNotEmpty(attachmentFlavor)) { try { MediaPackageElementFlavor flavor = MediaPackageElementFlavor.parseFlavor(attachmentFlavor); attachment.setFlavor(flavor); } catch (IllegalArgumentException e) { logger.warn("Unable to read attachment flavor: " + e.getMessage()); } } // Set the size if (size > 0) attachment.setSize(size); // Set checksum if (checksum != null) attachment.setChecksum(checksum); // Set mimetype if (mimeType != null) attachment.setMimeType(mimeType); // Set the description String description = xpath.evaluate("description/text()", elementNode); if (StringUtils.isNotEmpty(description)) attachment.setElementDescription(description.trim()); // Set tags NodeList tagNodes = (NodeList) xpath.evaluate("tags/tag", elementNode, XPathConstants.NODESET); for (int i = 0; i < tagNodes.getLength(); i++) { attachment.addTag(tagNodes.item(i).getTextContent()); } return specializeAttachment(attachment); } catch (XPathExpressionException e) { throw new UnsupportedElementException( "Error while reading attachment from manifest: " + e.getMessage()); } catch (NoSuchAlgorithmException e) { throw new UnsupportedElementException("Unsupported digest algorithm: " + e.getMessage()); } catch (URISyntaxException e) { throw new UnsupportedElementException( "Error while reading attachment file " + uri + ": " + e.getMessage()); } }
From source file:org.opencastproject.mediapackage.elementbuilder.CatalogBuilderPlugin.java
/** * {@inheritDoc}//from www . ja v a 2 s . co m * * @see org.opencastproject.mediapackage.elementbuilder.MediaPackageElementBuilderPlugin#elementFromManifest(org.w3c.dom.Node, * org.opencastproject.mediapackage.MediaPackageSerializer) */ @Override public MediaPackageElement elementFromManifest(Node elementNode, MediaPackageSerializer serializer) throws UnsupportedElementException { String id = null; String flavor = null; URI url = null; long size = -1; Checksum checksum = null; MimeType mimeType = null; String reference = null; try { // id id = (String) xpath.evaluate("@id", elementNode, XPathConstants.STRING); // url url = serializer.resolvePath(xpath.evaluate("url/text()", elementNode).trim()); // flavor flavor = (String) xpath.evaluate("@type", elementNode, XPathConstants.STRING); // reference reference = (String) xpath.evaluate("@ref", elementNode, XPathConstants.STRING); // size String documentSize = xpath.evaluate("size/text()", elementNode).trim(); if (!"".equals(documentSize)) size = Long.parseLong(documentSize); // checksum String checksumValue = (String) xpath.evaluate("checksum/text()", elementNode, XPathConstants.STRING); String checksumType = (String) xpath.evaluate("checksum/@type", elementNode, XPathConstants.STRING); if (StringUtils.isNotEmpty(checksumValue) && checksumType != null) checksum = Checksum.create(checksumType.trim(), checksumValue.trim()); // mimetype String mimeTypeValue = (String) xpath.evaluate("mimetype/text()", elementNode, XPathConstants.STRING); if (StringUtils.isNotEmpty(mimeTypeValue)) mimeType = MimeTypes.parseMimeType(mimeTypeValue); // create the catalog Catalog dc = CatalogImpl.fromURI(url); if (StringUtils.isNotEmpty(id)) dc.setIdentifier(id); // Add url dc.setURI(url); // Add flavor if (flavor != null) dc.setFlavor(MediaPackageElementFlavor.parseFlavor(flavor)); // Add reference if (StringUtils.isNotEmpty(reference)) dc.referTo(MediaPackageReferenceImpl.fromString(reference)); // Set size if (size > 0) dc.setSize(size); // Set checksum if (checksum != null) dc.setChecksum(checksum); // Set Mimetype if (mimeType != null) dc.setMimeType(mimeType); // Tags NodeList tagNodes = (NodeList) xpath.evaluate("tags/tag", elementNode, XPathConstants.NODESET); for (int i = 0; i < tagNodes.getLength(); i++) { dc.addTag(tagNodes.item(i).getTextContent()); } return dc; } catch (XPathExpressionException e) { throw new UnsupportedElementException( "Error while reading catalog information from manifest: " + e.getMessage()); } catch (NoSuchAlgorithmException e) { throw new UnsupportedElementException("Unsupported digest algorithm: " + e.getMessage()); } catch (URISyntaxException e) { throw new UnsupportedElementException( "Error while reading dublin core catalog " + url + ": " + e.getMessage()); } }
From source file:org.opencastproject.mediapackage.elementbuilder.PublicationBuilderPlugin.java
@Override public MediaPackageElement elementFromManifest(Node elementNode, MediaPackageSerializer serializer) throws UnsupportedElementException { String id = null;//from w w w . ja va2 s . c om MimeType mimeType = null; MediaPackageElementFlavor flavor = null; String reference = null; String channel = null; URI url = null; long size = -1; Checksum checksum = null; try { // id id = (String) xpath.evaluate("@id", elementNode, XPathConstants.STRING); if (StringUtils.isEmpty(id)) { throw new UnsupportedElementException("Unvalid or missing id argument!"); } // url url = serializer.resolvePath(xpath.evaluate("url/text()", elementNode).trim()); // channel channel = (String) xpath.evaluate("@channel", elementNode).trim(); if (StringUtils.isEmpty(channel)) { throw new UnsupportedElementException("Unvalid or missing channel argument!"); } // reference reference = (String) xpath.evaluate("@ref", elementNode, XPathConstants.STRING); // size String trackSize = xpath.evaluate("size/text()", elementNode).trim(); if (!"".equals(trackSize)) size = Long.parseLong(trackSize); // flavor String flavorValue = (String) xpath.evaluate("@type", elementNode, XPathConstants.STRING); if (StringUtils.isNotEmpty(flavorValue)) flavor = MediaPackageElementFlavor.parseFlavor(flavorValue); // checksum String checksumValue = (String) xpath.evaluate("checksum/text()", elementNode, XPathConstants.STRING); String checksumType = (String) xpath.evaluate("checksum/@type", elementNode, XPathConstants.STRING); if (StringUtils.isNotEmpty(checksumValue) && checksumType != null) checksum = Checksum.create(checksumType.trim(), checksumValue.trim()); // mimetype String mimeTypeValue = (String) xpath.evaluate("mimetype/text()", elementNode, XPathConstants.STRING); if (StringUtils.isNotEmpty(mimeTypeValue)) { mimeType = MimeTypes.parseMimeType(mimeTypeValue); } else { throw new UnsupportedElementException("Unvalid or missing mimetype argument!"); } // Build the publication element PublicationImpl publication = new PublicationImpl(id, channel, url, mimeType); if (StringUtils.isNotBlank(id)) publication.setIdentifier(id); // Add url publication.setURI(url); // Add reference if (StringUtils.isNotEmpty(reference)) publication.referTo(MediaPackageReferenceImpl.fromString(reference)); // Set size if (size > 0) publication.setSize(size); // Set checksum if (checksum != null) publication.setChecksum(checksum); // Set mimetpye if (mimeType != null) publication.setMimeType(mimeType); if (flavor != null) publication.setFlavor(flavor); // description String description = (String) xpath.evaluate("description/text()", elementNode, XPathConstants.STRING); if (StringUtils.isNotBlank(description)) publication.setElementDescription(description.trim()); // tags NodeList tagNodes = (NodeList) xpath.evaluate("tags/tag", elementNode, XPathConstants.NODESET); for (int i = 0; i < tagNodes.getLength(); i++) { publication.addTag(tagNodes.item(i).getTextContent()); } return publication; } catch (XPathExpressionException e) { throw new UnsupportedElementException( "Error while reading track information from manifest: " + e.getMessage()); } catch (NoSuchAlgorithmException e) { throw new UnsupportedElementException("Unsupported digest algorithm: " + e.getMessage()); } catch (URISyntaxException e) { throw new UnsupportedElementException( "Error while reading presenter track " + url + ": " + e.getMessage()); } }
From source file:org.opencastproject.mediapackage.elementbuilder.TrackBuilderPlugin.java
/** * @see org.opencastproject.mediapackage.elementbuilder.MediaPackageElementBuilderPlugin#elementFromManifest(org.w3c.dom.Node, * org.opencastproject.mediapackage.MediaPackageSerializer) *///w ww . j a va 2 s . c om public MediaPackageElement elementFromManifest(Node elementNode, MediaPackageSerializer serializer) throws UnsupportedElementException { String id = null; MimeType mimeType = null; MediaPackageElementFlavor flavor = null; String reference = null; URI url = null; long size = -1; Checksum checksum = null; try { // id id = (String) xpath.evaluate("@id", elementNode, XPathConstants.STRING); // url url = serializer.resolvePath(xpath.evaluate("url/text()", elementNode).trim()); // reference reference = (String) xpath.evaluate("@ref", elementNode, XPathConstants.STRING); // size String trackSize = xpath.evaluate("size/text()", elementNode).trim(); if (!"".equals(trackSize)) size = Long.parseLong(trackSize); // flavor String flavorValue = (String) xpath.evaluate("@type", elementNode, XPathConstants.STRING); if (StringUtils.isNotEmpty(flavorValue)) flavor = MediaPackageElementFlavor.parseFlavor(flavorValue); // checksum String checksumValue = (String) xpath.evaluate("checksum/text()", elementNode, XPathConstants.STRING); String checksumType = (String) xpath.evaluate("checksum/@type", elementNode, XPathConstants.STRING); if (StringUtils.isNotEmpty(checksumValue) && checksumType != null) checksum = Checksum.create(checksumType.trim(), checksumValue.trim()); // mimetype String mimeTypeValue = (String) xpath.evaluate("mimetype/text()", elementNode, XPathConstants.STRING); if (StringUtils.isNotEmpty(mimeTypeValue)) mimeType = MimeTypes.parseMimeType(mimeTypeValue); // // Build the track TrackImpl track = TrackImpl.fromURI(url); if (StringUtils.isNotBlank(id)) track.setIdentifier(id); // Add url track.setURI(url); // Add reference if (StringUtils.isNotEmpty(reference)) track.referTo(MediaPackageReferenceImpl.fromString(reference)); // Set size if (size > 0) track.setSize(size); // Set checksum if (checksum != null) track.setChecksum(checksum); // Set mimetpye if (mimeType != null) track.setMimeType(mimeType); if (flavor != null) track.setFlavor(flavor); // description String description = (String) xpath.evaluate("description/text()", elementNode, XPathConstants.STRING); if (StringUtils.isNotBlank(description)) track.setElementDescription(description.trim()); // tags NodeList tagNodes = (NodeList) xpath.evaluate("tags/tag", elementNode, XPathConstants.NODESET); for (int i = 0; i < tagNodes.getLength(); i++) { track.addTag(tagNodes.item(i).getTextContent()); } // duration try { String strDuration = (String) xpath.evaluate("duration/text()", elementNode, XPathConstants.STRING); if (StringUtils.isNotEmpty(strDuration)) { long duration = Long.parseLong(strDuration.trim()); track.setDuration(duration); } } catch (NumberFormatException e) { throw new UnsupportedElementException("Duration of track " + url + " is malformatted"); } // audio settings Node audioSettingsNode = (Node) xpath.evaluate("audio", elementNode, XPathConstants.NODE); if (audioSettingsNode != null && audioSettingsNode.hasChildNodes()) { try { AudioStreamImpl as = AudioStreamImpl.fromManifest(createStreamID(track), audioSettingsNode, xpath); track.addStream(as); } catch (IllegalStateException e) { throw new UnsupportedElementException( "Illegal state encountered while reading audio settings from " + url + ": " + e.getMessage()); } catch (XPathException e) { throw new UnsupportedElementException( "Error while parsing audio settings from " + url + ": " + e.getMessage()); } } // video settings Node videoSettingsNode = (Node) xpath.evaluate("video", elementNode, XPathConstants.NODE); if (videoSettingsNode != null && videoSettingsNode.hasChildNodes()) { try { VideoStreamImpl vs = VideoStreamImpl.fromManifest(createStreamID(track), videoSettingsNode, xpath); track.addStream(vs); } catch (IllegalStateException e) { throw new UnsupportedElementException( "Illegal state encountered while reading video settings from " + url + ": " + e.getMessage()); } catch (XPathException e) { throw new UnsupportedElementException( "Error while parsing video settings from " + url + ": " + e.getMessage()); } } return track; } catch (XPathExpressionException e) { throw new UnsupportedElementException( "Error while reading track information from manifest: " + e.getMessage()); } catch (NoSuchAlgorithmException e) { throw new UnsupportedElementException("Unsupported digest algorithm: " + e.getMessage()); } catch (URISyntaxException e) { throw new UnsupportedElementException( "Error while reading presenter track " + url + ": " + e.getMessage()); } }
From source file:org.opencastproject.mediapackage.track.AudioStreamImpl.java
/** * Create an audio stream from the XML manifest. * /*from ww w. j av a 2s . c o m*/ * @param streamIdHint * stream ID that has to be used if the manifest does not provide one. This is the case when reading an old * manifest. */ public static AudioStreamImpl fromManifest(String streamIdHint, Node node, XPath xpath) throws IllegalStateException, XPathException { // Create stream String sid = (String) xpath.evaluate("@id", node, XPathConstants.STRING); if (StringUtils.isEmpty(sid)) sid = streamIdHint; AudioStreamImpl as = new AudioStreamImpl(sid); // bit depth try { String bd = (String) xpath.evaluate("bitdepth/text()", node, XPathConstants.STRING); if (!StringUtils.isBlank(bd)) as.bitdepth = new Integer(bd.trim()); } catch (NumberFormatException e) { throw new IllegalStateException("Bit depth was malformatted: " + e.getMessage()); } // channels try { String strChannels = (String) xpath.evaluate("channels/text()", node, XPathConstants.STRING); if (!StringUtils.isBlank(strChannels)) as.channels = new Integer(strChannels.trim()); } catch (NumberFormatException e) { throw new IllegalStateException("Number of channels was malformatted: " + e.getMessage()); } // sampling rate try { String sr = (String) xpath.evaluate("framerate/text()", node, XPathConstants.STRING); if (!StringUtils.isBlank(sr)) as.samplingrate = new Integer(sr.trim()); } catch (NumberFormatException e) { throw new IllegalStateException("Frame rate was malformatted: " + e.getMessage()); } // Bit rate try { String br = (String) xpath.evaluate("bitrate/text()", node, XPathConstants.STRING); if (!StringUtils.isBlank(br)) as.bitrate = new Float(br.trim()); } catch (NumberFormatException e) { throw new IllegalStateException("Bit rate was malformatted: " + e.getMessage()); } // device String captureDevice = (String) xpath.evaluate("device/@type", node, XPathConstants.STRING); if (!StringUtils.isBlank(captureDevice)) as.device.type = captureDevice; String captureDeviceVersion = (String) xpath.evaluate("device/@version", node, XPathConstants.STRING); if (!StringUtils.isBlank(captureDeviceVersion)) as.device.version = captureDeviceVersion; String captureDeviceVendor = (String) xpath.evaluate("device/@vendor", node, XPathConstants.STRING); if (!StringUtils.isBlank(captureDeviceVendor)) as.device.vendor = captureDeviceVendor; // encoder String format = (String) xpath.evaluate("encoder/@type", node, XPathConstants.STRING); if (!StringUtils.isBlank(format)) as.encoder.type = format; String formatVersion = (String) xpath.evaluate("encoder/@version", node, XPathConstants.STRING); if (!StringUtils.isBlank(formatVersion)) as.encoder.version = formatVersion; String encoderLibraryVendor = (String) xpath.evaluate("encoder/@vendor", node, XPathConstants.STRING); if (!StringUtils.isBlank(encoderLibraryVendor)) as.encoder.vendor = encoderLibraryVendor; return as; }
From source file:org.opencastproject.mediapackage.track.VideoStreamImpl.java
/** * Create a video stream from the XML manifest. * // w ww. jav a 2 s . c om * @param streamIdHint * stream ID that has to be used if the manifest does not provide one. This is the case when reading an old * manifest. */ public static VideoStreamImpl fromManifest(String streamIdHint, Node node, XPath xpath) throws IllegalStateException, XPathException { // Create stream String sid = (String) xpath.evaluate("@id", node, XPathConstants.STRING); if (StringUtils.isEmpty(sid)) sid = streamIdHint; VideoStreamImpl vs = new VideoStreamImpl(sid); // bit rate try { String strBitrate = (String) xpath.evaluate("bitrate/text()", node, XPathConstants.STRING); if (StringUtils.isNotEmpty(strBitrate)) vs.bitRate = new Float(strBitrate.trim()); } catch (NumberFormatException e) { throw new IllegalStateException("Bit rate was malformatted: " + e.getMessage()); } // frame rate try { String strFrameRate = (String) xpath.evaluate("framerate/text()", node, XPathConstants.STRING); if (StringUtils.isNotEmpty(strFrameRate)) vs.frameRate = new Float(strFrameRate.trim()); } catch (NumberFormatException e) { throw new IllegalStateException("Frame rate was malformatted: " + e.getMessage()); } // resolution String res = (String) xpath.evaluate("resolution/text()", node, XPathConstants.STRING); if (StringUtils.isNotEmpty(res)) { vs.resolution = res; } // interlacing String scanType = (String) xpath.evaluate("scantype/@type", node, XPathConstants.STRING); if (StringUtils.isNotEmpty(scanType)) { if (vs.scanType == null) vs.scanType = new Scan(); vs.scanType.type = ScanType.fromString(scanType); } String scanOrder = (String) xpath.evaluate("interlacing/@order", node, XPathConstants.STRING); if (StringUtils.isNotEmpty(scanOrder)) { if (vs.scanType == null) vs.scanType = new Scan(); vs.scanType.order = ScanOrder.fromString(scanOrder); } // device String deviceType = (String) xpath.evaluate("device/@type", node, XPathConstants.STRING); if (StringUtils.isNotEmpty(deviceType)) { if (vs.device == null) vs.device = new Device(); vs.device.type = deviceType; } String deviceVersion = (String) xpath.evaluate("device/@version", node, XPathConstants.STRING); if (StringUtils.isNotEmpty(deviceVersion)) { if (vs.device == null) vs.device = new Device(); vs.device.version = deviceVersion; } String deviceVendor = (String) xpath.evaluate("device/@vendor", node, XPathConstants.STRING); if (StringUtils.isNotEmpty(deviceVendor)) { if (vs.device == null) vs.device = new Device(); vs.device.vendor = deviceVendor; } // encoder String encoderType = (String) xpath.evaluate("encoder/@type", node, XPathConstants.STRING); if (StringUtils.isNotEmpty(encoderType)) { if (vs.encoder == null) vs.encoder = new Encoder(); vs.encoder.type = encoderType; } String encoderVersion = (String) xpath.evaluate("encoder/@version", node, XPathConstants.STRING); if (StringUtils.isNotEmpty(encoderVersion)) { if (vs.encoder == null) vs.encoder = new Encoder(); vs.encoder.version = encoderVersion; } String encoderVendor = (String) xpath.evaluate("encoder/@vendor", node, XPathConstants.STRING); if (StringUtils.isNotEmpty(encoderVendor)) { if (vs.encoder == null) vs.encoder = new Encoder(); vs.encoder.vendor = encoderVendor; } return vs; }
From source file:org.opencastproject.oaipmh.harvester.OaiPmhResponse.java
/** * Evaluate the xpath expression against the contained document. The expression must return a string (text). *///from w w w.jav a 2 s . c o m protected String xpathString(String expr) { try { return ((String) xpath.evaluate(expr, doc, XPathConstants.STRING)).trim(); } catch (XPathExpressionException e) { throw new RuntimeException("malformed xpath expression " + expr, e); } }
From source file:org.openehealth.ipf.commons.ihe.ws.cxf.audit.AbstractAuditInterceptor.java
/** * Extracts ITI-40 XUA user name from the SAML2 assertion contained * in the given CXF message, and stores it in the ATNA audit dataset. * * @param message/*www .ja v a 2 s . c om*/ * source CXF message. * @param auditDataset * target ATNA audit dataset. * @throws XPathExpressionException * actually cannot occur. */ protected static void extractXuaUserNameFromSaml2Assertion(SoapMessage message, WsAuditDataset auditDataset) throws XPathExpressionException { // check whether someone has already parsed the SAML2 assertion // and provided the XUA user name for us via WS message context if (message.getContextualProperty(XUA_USERNAME_CONTEXT_KEY) != null) { auditDataset.setUserName(message.getContextualProperty(XUA_USERNAME_CONTEXT_KEY).toString()); return; } // extract information from SAML2 assertion XPathExpression[] expressions = XUA_XPATH_EXPRESSIONS.get(); Node envelopeNode = message.getContent(Node.class); Node nameNode = (Node) expressions[0].evaluate(envelopeNode, XPathConstants.NODE); if (nameNode == null) { return; } String issuer = (String) expressions[1].evaluate(envelopeNode, XPathConstants.STRING); String userName = nameNode.getTextContent(); if (issuer.isEmpty() || userName.isEmpty()) { return; } // set ATNA XUA userName element StringBuilder sb = new StringBuilder().append(((Element) nameNode).getAttribute("SPProvidedID")).append('<') .append(userName).append('@').append(issuer).append('>'); auditDataset.setUserName(sb.toString()); }
From source file:org.openengsb.openengsbplugin.MojoPreparation.java
@BeforeClass public static void preparePlugin() throws Exception { if (!prepared) { LOG.debug("preparing openengsb-maven-plugin.."); File f = new File("pom.xml"); Document doc = Tools.parseXMLFromString(FileUtils.readFileToString(f)); groupId = Tools.evaluateXPath("/pom:project/pom:groupId/text()", doc, nsContext, XPathConstants.STRING, String.class).trim(); artifactId = Tools.evaluateXPath("/pom:project/pom:artifactId/text()", doc, nsContext, XPathConstants.STRING, String.class).trim(); version = Tools.evaluateXPath("/pom:project/pom:version/text()", doc, nsContext, XPathConstants.STRING, String.class).trim(); if (System.getProperty("os.name").startsWith("Windows")) { mvnCommand = "mvn.bat"; }/*from www .j ava2 s .co m*/ Tools.executeProcess(Arrays.asList(new String[] { mvnCommand, "install", "-Dmaven.test.skip=true" }), userDir); prepared = true; } }