232 |
232 |
/*
|
233 |
233 |
* API Resources
|
234 |
234 |
*/
|
235 |
|
private static final String RESOURCE_OBJECTS = "object";
|
236 |
|
private static final String RESOURCE_FORMATS = "formats";
|
237 |
|
private static final String RESOURCE_META = "meta";
|
238 |
|
private static final String RESOURCE_SESSION = "session";
|
239 |
|
private static final String RESOURCE_IDENTIFIER = "identifier";
|
240 |
|
private static final String RESOURCE_LOG = "log";
|
241 |
|
private static final String RESOURCE_CHECKSUM = "checksum";
|
242 |
|
private static final String RESOURCE_MONITOR = "monitor";
|
243 |
|
private static final String RESOURCE_BASE_URL = "d1";
|
244 |
|
private static final String RESOURCE_REPLICATE = "replicate";
|
|
235 |
protected static final String RESOURCE_OBJECTS = "object";
|
|
236 |
protected static final String RESOURCE_FORMATS = "formats";
|
|
237 |
protected static final String RESOURCE_META = "meta";
|
|
238 |
protected static final String RESOURCE_SESSION = "session";
|
|
239 |
protected static final String RESOURCE_IDENTIFIER = "identifier";
|
|
240 |
protected static final String RESOURCE_LOG = "log";
|
|
241 |
protected static final String RESOURCE_CHECKSUM = "checksum";
|
|
242 |
protected static final String RESOURCE_MONITOR = "monitor";
|
|
243 |
protected static final String RESOURCE_BASE_URL = "d1";
|
|
244 |
protected static final String RESOURCE_REPLICATE = "replicate";
|
245 |
245 |
|
246 |
246 |
/*
|
247 |
247 |
* API Functions used as URL parameters
|
248 |
248 |
*/
|
249 |
|
private static final String FUNCTION_KEYWORD = "op";
|
250 |
|
private static final String FUNCTION_NAME_LOGIN = "login";
|
251 |
|
private static final String FUNCTION_NAME_LOGOUT = "logout";
|
252 |
|
private static final String FUNCTION_NAME_SET_ACCESS = "setaccess";
|
253 |
|
private static final String FUNCTION_NAME_ISREGISTERED = "isregistered";
|
254 |
|
private static final String FUNCTION_NAME_GETALLDOCS = "getalldocids";
|
255 |
|
private static final String FUNCTION_NAME_GETNEXTREV = "getnextrevision";
|
256 |
|
private static final String FUNCTION_NAME_GETNEXTOBJ = "getnextobject";
|
257 |
|
private static final String FUNCTION_NAME_INSERT = "insert";
|
258 |
|
private static final String FUNCTION_NAME_UPDATE = "update";
|
259 |
|
private static final String FUNCTION_NAME_GENERATE_MISSING_SYSTEM_METADATA = "generatemissingsystemmetadata";
|
|
249 |
protected static final String FUNCTION_KEYWORD = "op";
|
|
250 |
protected static final String FUNCTION_NAME_LOGIN = "login";
|
|
251 |
protected static final String FUNCTION_NAME_LOGOUT = "logout";
|
|
252 |
protected static final String FUNCTION_NAME_SET_ACCESS = "setaccess";
|
|
253 |
protected static final String FUNCTION_NAME_ISREGISTERED = "isregistered";
|
|
254 |
protected static final String FUNCTION_NAME_GETALLDOCS = "getalldocids";
|
|
255 |
protected static final String FUNCTION_NAME_GETNEXTREV = "getnextrevision";
|
|
256 |
protected static final String FUNCTION_NAME_GETNEXTOBJ = "getnextobject";
|
|
257 |
protected static final String FUNCTION_NAME_INSERT = "insert";
|
|
258 |
protected static final String FUNCTION_NAME_UPDATE = "update";
|
|
259 |
protected static final String FUNCTION_NAME_GENERATE_MISSING_SYSTEM_METADATA = "generatemissingsystemmetadata";
|
260 |
260 |
|
261 |
|
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
|
261 |
protected static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
262 |
262 |
|
263 |
|
private ServletContext servletContext;
|
264 |
|
private Logger logMetacat;
|
265 |
|
private MetacatHandler handler;
|
266 |
|
private HttpServletRequest request;
|
267 |
|
private HttpServletResponse response;
|
268 |
|
private String username;
|
269 |
|
private String password;
|
270 |
|
private String sessionId;
|
271 |
|
private String[] groupNames;
|
|
263 |
protected ServletContext servletContext;
|
|
264 |
protected Logger logMetacat;
|
|
265 |
protected MetacatHandler handler;
|
|
266 |
protected HttpServletRequest request;
|
|
267 |
protected HttpServletResponse response;
|
|
268 |
protected String username;
|
|
269 |
protected String password;
|
|
270 |
protected String sessionId;
|
|
271 |
protected String[] groupNames;
|
272 |
272 |
|
273 |
|
private Hashtable<String, String[]> params;
|
|
273 |
protected Hashtable<String, String[]> params;
|
274 |
274 |
|
275 |
275 |
// D1 certificate-based authentication
|
276 |
|
private Session session;
|
|
276 |
protected Session session;
|
277 |
277 |
|
278 |
278 |
/**Initializes new instance by setting servlet context,request and response*/
|
279 |
279 |
public ResourceHandler(ServletContext servletContext,
|
... | ... | |
1013 |
1013 |
/**
|
1014 |
1014 |
* copies request parameters to a hashtable which is given as argument to native metacathandler functions
|
1015 |
1015 |
*/
|
1016 |
|
private void initParams() {
|
|
1016 |
protected void initParams() {
|
1017 |
1017 |
|
1018 |
1018 |
String name = null;
|
1019 |
1019 |
String[] value = null;
|
... | ... | |
1392 |
1392 |
* @return
|
1393 |
1393 |
* @throws ParseException
|
1394 |
1394 |
*/
|
1395 |
|
private Date parseDateAndConvertToGMT(String date) throws ParseException
|
|
1395 |
protected Date parseDateAndConvertToGMT(String date) throws ParseException
|
1396 |
1396 |
{
|
1397 |
1397 |
try
|
1398 |
1398 |
{ //the format we want
|
... | ... | |
1450 |
1450 |
* @param out the stream to serialize it to
|
1451 |
1451 |
* @throws JiBXException
|
1452 |
1452 |
*/
|
1453 |
|
private void serializeServiceType(Class type, Object object, OutputStream out)
|
|
1453 |
protected void serializeServiceType(Class type, Object object, OutputStream out)
|
1454 |
1454 |
throws JiBXException
|
1455 |
1455 |
{
|
1456 |
1456 |
ServiceTypeUtil.serializeServiceType(type, object, out);
|
... | ... | |
1536 |
1536 |
out.close();
|
1537 |
1537 |
}
|
1538 |
1538 |
|
1539 |
|
private String streamToString(InputStream is)
|
1540 |
|
throws IOException
|
1541 |
|
{
|
1542 |
|
return IOUtil.toString(is);
|
1543 |
|
}
|
1544 |
|
|
1545 |
|
private InputStream stringToStream(String s)
|
1546 |
|
throws IOException
|
1547 |
|
{
|
1548 |
|
ByteArrayInputStream bais = new ByteArrayInputStream(s.getBytes(MetaCatServlet.DEFAULT_ENCODING));
|
1549 |
|
return bais;
|
1550 |
|
}
|
1551 |
|
|
1552 |
1539 |
/**
|
1553 |
1540 |
* locate the boundary marker for an MMP
|
1554 |
1541 |
* @param is
|
... | ... | |
1649 |
1636 |
* is the existing pid. If insert, the pid is the new one
|
1650 |
1637 |
* @throws IOException
|
1651 |
1638 |
*/
|
1652 |
|
private void putObject(String pid, String action) {
|
|
1639 |
protected void putObject(String pid, String action) {
|
1653 |
1640 |
System.out.println("ResourceHandler: putObject with pid " + pid);
|
1654 |
1641 |
logMetacat.debug("Entering putObject: " + pid + "/" + action);
|
1655 |
1642 |
OutputStream out = null;
|
... | ... | |
1922 |
1909 |
* set the access perms on a document
|
1923 |
1910 |
* @throws Exception
|
1924 |
1911 |
*/
|
1925 |
|
private void setaccess() throws Exception
|
|
1912 |
protected void setaccess() throws Exception
|
1926 |
1913 |
{
|
1927 |
1914 |
try
|
1928 |
1915 |
{
|
... | ... | |
1972 |
1959 |
* @param message Message to be displayed
|
1973 |
1960 |
* @param response Servlet response that xml message will be printed
|
1974 |
1961 |
* */
|
1975 |
|
private void printError(String message, HttpServletResponse response) {
|
|
1962 |
protected void printError(String message, HttpServletResponse response) {
|
1976 |
1963 |
try {
|
1977 |
1964 |
logMetacat.error("ResourceHandler: Printing error to servlet response: " + message);
|
1978 |
1965 |
PrintWriter out = response.getWriter();
|
... | ... | |
1992 |
1979 |
* @param e
|
1993 |
1980 |
* @param out
|
1994 |
1981 |
*/
|
1995 |
|
private void serializeException(BaseException e, OutputStream out) {
|
|
1982 |
protected void serializeException(BaseException e, OutputStream out) {
|
1996 |
1983 |
// TODO: Use content negotiation to determine which return format to use
|
1997 |
1984 |
response.setContentType("text/xml");
|
1998 |
1985 |
response.setStatus(e.getCode());
|
... | ... | |
2127 |
2114 |
* Register System Metadata without data or metadata object
|
2128 |
2115 |
* @param pid identifier for System Metadata entry
|
2129 |
2116 |
*/
|
2130 |
|
private void registerSystemMetadata(String pid) {
|
|
2117 |
protected void registerSystemMetadata(String pid) {
|
2131 |
2118 |
logMetacat.debug("Entering registerSystemMetadata: " + pid);
|
2132 |
2119 |
OutputStream out = null;
|
2133 |
2120 |
try {
|
make RestServlet and ResourceHandler extendible for D1 CN and MN handlers