|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.dlese.dpc.ndr.NdrUtils
public class NdrUtils
Collection of static methods for setting up NDR proxy and performing operations on the NDR.
NOTE: many NDR proxy functions require a ndrPrivateKey. Edit this file to set the "ndrPrivateKeyFile" attribute to a key file accessible to your filesystem to enable these functions.
Field Summary | |
---|---|
static SimpleDateFormat |
ndrDateFormat
Formats and parses dates according to utcDateFormatString. |
static String |
ndrDateFormatString
"yyyy-MM-dd'T'HH:mm:ss'Z'" |
static SimpleDateFormat |
simpleDateFormat
NOT YET DOCUMENTED |
static String |
simpleDateFormatString
NOT YET DOCUMENTED |
Constructor Summary | |
---|---|
NdrUtils()
|
Method Summary | |
---|---|
static void |
activateObject(String handle)
Set state to "Active" for NDR Object corresponding to handle. |
static void |
deactivateObject(String handle)
Set state to "Inactive" for NDR Object corresponding to handle. |
static void |
deleteCollection(String collection)
Removes the metadataProvider and all Metadata Objects associated with given key from the NDR. |
static void |
deleteNDRCollection(String mdpHandle)
Removes the metadataProvider, all Metadata Objects, and the aggregator associated with the given mdpHandle from the NDR. |
static InfoXML |
deleteNDRObject(String handle)
Marks the object corresponding to the provided handle as "deleted" in the NDR. |
static InfoXML |
deleteNDRObject(String handle,
boolean cascade)
Marks the object corresponding to the provided handle, as well as all subordinate objects (when cascade is true), as "deleted" in the NDR. |
static List |
findDeletedMetadataObjects(String mdpHandle)
Returns deleted metadata objects for specified metadataProvider. |
static List |
findFinalValidResources(String mdpHandle)
Retrieve list of metadata objects provided by specified metadataProvider whose metadata is valid and whose status is Final. |
static String |
findResource(String url)
Return the handle of the resource for the given url if one is found, null otherwise. |
static String |
findResourceOld(String url)
Finds the handle of the resource associated with provided url. |
static String |
formattedDate(Date date)
Converts a Date object to String of form "yyyy-MM-dd". |
static List |
getAggregatorHandles()
Gets the aggregatorHandles attribute of the NdrUtils class |
static List |
getAggregatorHandles(String agentHandle)
Gets the aggregatorHandles attribute of the NdrUtils class |
static Document |
getCollectionRecord(String collection)
Retrieves the CollectionRecord stored in the NDR for the given collection key. |
static List |
getEmtpyMDPHandles()
Gets List of handles for MetadataProviders having no items. |
static String |
getInfoLink(String mdHandle)
Gets the "link" value that goes into the nsdl_dc_info stream for metadata records |
static List |
getMDPHandles()
Gets all MetadataProvider handles associated with the DleseAgent |
static List |
getMDPHandles(String agentHandle)
Gets the handles for all MetadataProvider objects associated with the aggent associated with specified agentHandle (which defaults to the dleseAgent). |
static MetadataProviderReader |
getMetadataProvider(String collection)
Gets the metadataProvider stored in the NDR associated with given collection key. |
static Document |
getNDRObjectDoc(String handle)
Performs a "get" request on the NDR with the provided object handle and returns the result as a dom4j.Document. |
static Document |
getNDRObjectDoc(URL handleUrl)
Retrieves the provided "handleUrl" (a complete URL including ndrApi and a handle to a specific object) as a dom4j.Document. |
static String |
getNonEmpyStringOrNull(String s)
Returns null if the string is null or empty, or the original string otherwise. |
static List |
getRecentMDPHandles(Date thresholdDate)
Gets handles of MetadataProvider Objects in the NDR that have been modified since specified threshold date. |
static List |
getStaleMDPHandles(Date thresholdDate)
Gets List of MDP handles that have not been modified since provided threshold Date. |
static void |
initProp()
Sets TransformerFactory to a XSL 1.0 version so the localizers don't complain. |
static boolean |
isNDRCollectionMDP1(String mdpHandle)
Returns true if the provided handle is for a MetadataProvider that is part of a NDR Collection Definition (as opposed to a MDP that is used to group metadata for an NCS collection that is not seen by the NDR). |
static boolean |
isNDRCollectionMetadataProvider(String mdpHandle)
Returns true if the provided handle is for a MetadataProvider that is part of a NDR Collection Definition (as opposed to a MDP that is used to group metadata for an NCS collection that is not seen by the NDR). |
static void |
main(String[] args)
The main program for the NdrUtils class |
static String |
normalizeUrl(String urlStr)
Stand in for the official NDR normalizing routine. |
static Date |
parseDateString(String dateStr,
SimpleDateFormat dateFormat)
Formats given date string using given dateFormat. |
static Date |
parseNdrDateString(String dateStr)
Converts String of form used by NDR ("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") into a Date object. |
static Date |
parseSimpleDateString(String dateStr)
Converts date string of form "yyyy-MM-dd" to Date object. |
static void |
pp(Node node)
Pretty-prints a dom4j.Node. |
static void |
pp(String xml)
NOT YET DOCUMENTED |
static void |
prtln(String s,
String prefix)
NOT YET DOCUMENTED |
static void |
setDebug(boolean bool)
Sets the debug attribute of the NdrUtils class |
static void |
setObjectState(NdrObjectReader reader,
NDRConstants.ObjectState state)
Sets the objectState attribute of the NdrUtils class |
static void |
setObjectState(String handle,
NDRConstants.ObjectState state)
Sets the state of the NDR Object corresponding to provided handle. |
static void |
setup(File propsFile)
Sets configuration parameters from provided properties file to communicate with an NDR instance |
static void |
setup(String ndrServer)
Configures system to communicate with specified ndrServer (on read-only basis) |
static void |
setup(String ndrServer,
String ncsAgentHandle,
String keyPath)
Intialize NDR Constants to enable interaction with NDR. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static String ndrDateFormatString
public static SimpleDateFormat ndrDateFormat
public static String simpleDateFormatString
public static SimpleDateFormat simpleDateFormat
Constructor Detail |
---|
public NdrUtils()
Method Detail |
---|
public static String normalizeUrl(String urlStr)
urlStr
- NOT YET DOCUMENTED
public static void setup(String ndrServer)
ndrServer
- the ndr server api url (e.g., "http://ndrtest.nsdl.org/api")public static void setup(File propsFile)
Properties:
propsFile
- the properties filepublic static void setup(String ndrServer, String ncsAgentHandle, String keyPath)
ndrServer
- NOT YET DOCUMENTEDncsAgentHandle
- NOT YET DOCUMENTEDkeyPath
- NOT YET DOCUMENTEDpublic static final String getNonEmpyStringOrNull(String s)
s
- NOT YET DOCUMENTED
public static boolean isNDRCollectionMDP1(String mdpHandle) throws Exception
NOTE: This is not a general solution, but instead depends upon an NCS relationship. See isNDRCollectionMetadataProvider for a general solution.
mdpHandle
- NOT YET DOCUMENTED
Exception
- NOT YET DOCUMENTEDpublic static boolean isNDRCollectionMetadataProvider(String mdpHandle)
Algorithm:
mdpHandle
- NOT YET DOCUMENTED
public static List findFinalValidResources(String mdpHandle) throws Exception
mdpHandle
- handle of metadataProvider owning desired metadata
Exception
- when ndrRequest results in error from NDRpublic static String findResourceOld(String url)
url
- resource url to find
public static void deactivateObject(String handle) throws Exception
handle
- handle of object to activate
Exception
- NOT YET DOCUMENTEDpublic static void activateObject(String handle) throws Exception
NOTE: will not activate an object with an NCS status that is not final.
handle
- handle of object to activate
Exception
- NOT YET DOCUMENTEDpublic static void setObjectState(String handle, NDRConstants.ObjectState state) throws Exception
handle
- handle for NDR Objectstate
- The new objectState value
Exception
- if NDR Object not found for handlepublic static void setObjectState(NdrObjectReader reader, NDRConstants.ObjectState state) throws Exception
reader
- NDR reader for object for which state will be setstate
- The new objectState value
Exception
public static String getInfoLink(String mdHandle) throws Exception
mdHandle
- NOT YET DOCUMENTED
Exception
- NOT YET DOCUMENTEDpublic static String findResource(String url)
url
- url for which object will be found
public static List findDeletedMetadataObjects(String mdpHandle)
mdpHandle
- handle for a metadataProvider object
public static MetadataProviderReader getMetadataProvider(String collection) throws Exception
collection
- collection key
Exception
- NOT YET DOCUMENTEDpublic static Document getCollectionRecord(String collection) throws Exception
collection
- collectionKey associated with a collection stored in
the NDR.
Exception
- NOT YET DOCUMENTEDpublic static Document getNDRObjectDoc(String handle) throws Exception
handle
- handle to an ndrObject
Exception
- if handle is not provided, or url does not resolve to
well-formed xml.public static Document getNDRObjectDoc(URL handleUrl) throws Exception
handleUrl
- NOT YET DOCUMENTED
Exception
- If url does not resolve to well-formed xml.public static List getMDPHandles() throws Exception
Exception
- NOT YET DOCUMENTEDpublic static List getMDPHandles(String agentHandle) throws Exception
Relies on "Find" request, which requires authentication and therefore uses NDRAPIProxy.
agentHandle
- agent for which we are retrieving mdpHandles
Exception
- NOT YET DOCUMENTEDpublic static List getAggregatorHandles() throws Exception
Exception
- NOT YET DOCUMENTEDpublic static List getAggregatorHandles(String agentHandle) throws Exception
agentHandle
- NOT YET DOCUMENTED
Exception
- NOT YET DOCUMENTEDpublic static void initProp() throws Exception
Exception
- NOT YET DOCUMENTEDpublic static void main(String[] args) throws Exception
args
- The command line arguments
Exception
- NOT YET DOCUMENTEDpublic static List getEmtpyMDPHandles() throws Exception
Exception
- NOT YET DOCUMENTEDpublic static List getRecentMDPHandles(Date thresholdDate)
thresholdDate
- NOT YET DOCUMENTED
public static List getStaleMDPHandles(Date thresholdDate)
thresholdDate
- NOT YET DOCUMENTED
public static InfoXML deleteNDRObject(String handle) throws Exception
handle
- handle of Object to be deleted.
Exception
- if NDR object cannot be deletedpublic static InfoXML deleteNDRObject(String handle, boolean cascade) throws Exception
handle
- handle of Object to be deletedcascade
- flag to delete all dependent objects (not working in
NDR)
Exception
- if NDR object cannot be deletedpublic static void deleteCollection(String collection) throws Exception
collection
- collectionKey
Exception
- if NDR objects cannot be deletedpublic static void deleteNDRCollection(String mdpHandle) throws Exception
mdpHandle
- MetadataProvider object handle.
Exception
- if NDR objects cannot be deletedpublic static Date parseDateString(String dateStr, SimpleDateFormat dateFormat)
dateStr
- Date in string form to be converted to a Date ObjectdateFormat
- NOT YET DOCUMENTED
public static Date parseNdrDateString(String dateStr)
dateStr
-
public static Date parseSimpleDateString(String dateStr)
dateStr
- NOT YET DOCUMENTED
public static String formattedDate(Date date)
date
- NOT YET DOCUMENTED
public static void pp(Node node)
node
- NOT YET DOCUMENTEDpublic static void pp(String xml)
xml
- NOT YET DOCUMENTEDpublic static void setDebug(boolean bool)
bool
- The new debug valuepublic static void prtln(String s, String prefix)
s
- NOT YET DOCUMENTEDprefix
- NOT YET DOCUMENTED
|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |