Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

issue when trying to get service provider for a project in one particular server

HI,

I am getting an issue when trying to get service provider for a project in one particular server whereas it works fine for another server.

Is there a difference for XPathConstants.NODE between

Node

and

{http://www.w3.org/1999/XSL/Transform}NODE

private static String getServiceProvider(String catalogURI, String paName,String server,String login,String password,HttpClient httpclient) throws InvalidCredentialsException, IOException, XPathExpressionException {
  HttpGet query = new HttpGet(catalogURI);
  query.addHeader("Accept", "application/xml");
  query.addHeader("OSLC-Core-Version", "2.0");
  System.out.println("paName 111111111111 "+paName);
  // Access to the Service Providers catalog
  HttpResponse response = HttpUtil.sendGetForSecureDocument(
            server, query, login, password, httpclient);
  if (response.getStatusLine().getStatusCode() != 200) {
   response.getEntity().consumeContent();
   throw new HttpResponseException(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase());
  }
  // Define the XPath evaluation environment
  XPathFactory factory = XPathFactory.newInstance();
  XPath xpath = factory.newXPath();
  String serviceProviderXPath = "//oslc:ServiceProvider[dcterms:title=\""+paName+"\"]/@rdf:about";
  xpath.setNamespaceContext(
    new NamespaceContextMap(new String[]
      {"oslc", "http://open-services.net/ns/core#",
      "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
      "dcterms", "http://purl.org/dc/terms/"}));

  // Retrieve the designated Service Provider
  InputSource source = new InputSource(response.getEntity().getContent());
  Node paNode = (Node)(xpath.evaluate(serviceProviderXPath, source, XPathConstants.NODE));
  if (paNode == null) {
   response.getEntity().consumeContent();
   throw new RuntimeException("Unknown Project Area: "+paName);
  }
  return paNode.getTextContent();
 }

0 votes


Be the first one to answer this question!

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Jul 19 '13, 7:41 a.m.

Question was seen: 4,194 times

Last updated: Jul 19 '13, 7:41 a.m.

Confirmation Cancel Confirm