Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to use this code to recreate similar application in .Net environment, but I am little unclear of the logic. Hence I would like to seek some assistance, in explaining, what is going on in the code below:

There is a contentCreator class, which creates a issue & I am little unsure, what its doing here return api.create(publication.findLink("issue"), Utils.renderXml(document));:
Java
//ContentCreator

	public static ApiObject createIssue(NotessaApi api, ApiObject publication, Issue issue) throws IOException {
		Document document = Utils.createEmptyDocument();
		Node node = Utils.createNode(document, "issue");
		
		Utils.addXml(document, node, "title", issue.getTitle());
		Utils.addXml(document, node, "approval_status", issue.getApprovalStatus());
		Utils.addXml(document, node, "display_title", issue.getDisplayTitle());
		Utils.addXml(document, node, "display_date", issue.getDisplayDate());
		List<Property> properties = issue.getProperties();
		if(!properties.isEmpty()) {
			Node container = Utils.createNode(document, node, "properties");
			for(Property property : properties) {
				Element element = Utils.createNode(document, container, "property");
				element.setAttribute("name", property.getName());
				Utils.addXml(document, element, "value", property.getValue());
			}
		}
		
		return api.create(publication.findLink("issue"), Utils.renderXml(document));
	}


Is it creating the issue xml and forwarding it to the findlink url from the API Object class.

API Object class creates the following two methods:
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
	
public URL findLink(String rel) {
		String result = xpath("//link[contains(@rel,'" + rel + "')]/@href");
		try {
			return new URL(result);
		} catch(MalformedURLException e) {
			throw new RuntimeException(e);
		} 
	}

	public URL getSelfLink() throws MalformedURLException {
		String uri = xpath("//@uri");
		return new URL(uri); 
	}


Any further advice, would be most appreciated. Many thanks.
Posted
Updated 22-Sep-14 0:47am
v2

1 solution

The return statement makes a call out to api.create(publication.findLink("issue"), Utils.renderXml(document)); and returns whatever is returned by that method.
 
Share this answer
 
Comments
miss786 22-Sep-14 9:30am    
thank you for your reply back. I would like to clarify, if the create Issue method is returning the xml into the findURL link? Is this correct?
Richard MacCutchan 22-Sep-14 12:19pm    
Sorry, no idea. You will have to look at the code or documentation to find out.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900