edu.ucsb.nceas.metacat
Class MetacatReplication

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--edu.ucsb.nceas.metacat.MetacatReplication
All Implemented Interfaces:
java.lang.Runnable, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class MetacatReplication
extends javax.servlet.http.HttpServlet
implements java.lang.Runnable

See Also:
Serialized Form

Constructor Summary
MetacatReplication()
           
 
Method Summary
 void destroy()
           
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
static java.lang.String getCatalogXML()
          Returns the xml_catalog table encoded in xml
static int getHomeServerCodeForDocId(java.lang.String accNum)
          Returns a home server location given a accnum
static java.util.Hashtable getHomeServerInfoForDocId(java.lang.String docId)
          Method to get a host server information for given docid
static int getServerCodeForServerName(java.lang.String server)
          Returns a server code given a server name
static java.lang.String getServerNameForServerCode(int serverCode)
          Returns the name of a server given a serverCode
static java.lang.String getURLContent(java.net.URL u)
          This method returns the content of a url
 void init(javax.servlet.ServletConfig config)
          Initialize the servlet by creating appropriate database connections
static void replErrorLog(java.lang.String message)
          Method for writing replication messages to a log file specified in metacat.properties
static void replLog(java.lang.String message)
          Method for writing replication messages to a log file specified in metacat.properties
static boolean replToServer(java.lang.String server)
          Returns true if the replicate field for server in xml_replication is 1.
 void run()
          this method handles the timeout for a file lock.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetacatReplication

public MetacatReplication()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initialize the servlet by creating appropriate database connections

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
javax.servlet.ServletException

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException,
                  java.io.IOException
Overrides:
doGet in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws javax.servlet.ServletException,
                   java.io.IOException
Overrides:
doPost in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException

getCatalogXML

public static java.lang.String getCatalogXML()
Returns the xml_catalog table encoded in xml


run

public void run()
this method handles the timeout for a file lock. when a lock is granted it is granted for 30 seconds. When this thread runs out it deletes the docid from the queue, thus eliminating the lock.

Specified by:
run in interface java.lang.Runnable

getServerNameForServerCode

public static java.lang.String getServerNameForServerCode(int serverCode)
Returns the name of a server given a serverCode

Parameters:
serverCode - the serverid of the server
Returns:
the servername or null if the specified serverCode does not exist.

getServerCodeForServerName

public static int getServerCodeForServerName(java.lang.String server)
                                      throws java.lang.Exception
Returns a server code given a server name

Parameters:
server - the name of the server
Returns:
integer > 0 representing the code of the server, 0 if the server does not exist.
java.lang.Exception

getHomeServerInfoForDocId

public static java.util.Hashtable getHomeServerInfoForDocId(java.lang.String docId)
Method to get a host server information for given docid


getHomeServerCodeForDocId

public static int getHomeServerCodeForDocId(java.lang.String accNum)
                                     throws java.lang.Exception
Returns a home server location given a accnum

Parameters:
accNum - , given accNum for a document
java.lang.Exception

getURLContent

public static java.lang.String getURLContent(java.net.URL u)
                                      throws java.io.IOException
This method returns the content of a url

Parameters:
u - the url to return the content from
Returns:
a string representing the content of the url
Throws:
java.io.IOException

replLog

public static void replLog(java.lang.String message)
Method for writing replication messages to a log file specified in metacat.properties


replErrorLog

public static void replErrorLog(java.lang.String message)
Method for writing replication messages to a log file specified in metacat.properties


replToServer

public static boolean replToServer(java.lang.String server)
Returns true if the replicate field for server in xml_replication is 1. Returns false otherwise



Copyright © 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.