Skip to content
Snippets Groups Projects
Commit 33b4bae1 authored by Sara Bertocco's avatar Sara Bertocco
Browse files

New working version after Victoria trip - new file

parent 602e4604
Branches
No related tags found
No related merge requests found
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package it.inaf.oats.vospacebackend.implementation;
import ca.nrc.cadc.net.TransientException;
import ca.nrc.cadc.vos.Node;
import ca.nrc.cadc.vos.NodeNotFoundException;
import ca.nrc.cadc.vos.VOSURI;
import ca.nrc.cadc.vos.server.NodeID;
import java.net.URISyntaxException;
import org.apache.log4j.Logger;
/**
*
* @author bertocco
*/
public class NodeUtils {
public DatabaseNodePersistenceImpl dbNodePers;
private static final Logger log = Logger.getLogger(NodeUtils.class);
public NodeUtils() {
dbNodePers = new DatabaseNodePersistenceImpl();
}
public Long getNodeIdLongfromVosuriStr(String vosuri) {
Node myNode = null;
NodeID nodeID;
myNode = getNodeFromVosuriStr(vosuri);
if (myNode != null) {
nodeID = (NodeID)myNode.appData;
return nodeID.getID();
} else {
return null;
}
}
/* Returns the node or null if something went wrong */
public Node getNodeFromVosuriStr(String vosuri) {
Node myNode = null;
try {
myNode = dbNodePers.get(new VOSURI(vosuri));
} catch (NodeNotFoundException e) {
log.debug("NodeNotFoundException getting node from persistence.");
log.debug(e.getMessage());
} catch (TransientException e) {
log.debug("TransientException getting node from persistence.");
log.debug(e.getMessage());
} catch (URISyntaxException e) {
log.debug("URISyntaxException getting node from persistence.");
log.debug(e.getMessage());
}
return myNode;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment