1
|
/**
|
2
|
* '$RCSfile$'
|
3
|
* Copyright: 2000 Regents of the University of California and the
|
4
|
* National Center for Ecological Analysis and Synthesis
|
5
|
*
|
6
|
* '$Author: $'
|
7
|
* '$Date: 2009-06-13 15:28:13 +0300 $'
|
8
|
*
|
9
|
* This program is free software; you can redistribute it and/or modify
|
10
|
* it under the terms of the GNU General Public License as published by
|
11
|
* the Free Software Foundation; either version 2 of the License, or
|
12
|
* (at your option) any later version.
|
13
|
*
|
14
|
* This program is distributed in the hope that it will be useful,
|
15
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
* GNU General Public License for more details.
|
18
|
*
|
19
|
* You should have received a copy of the GNU General Public License
|
20
|
* along with this program; if not, write to the Free Software
|
21
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
22
|
*/
|
23
|
|
24
|
package edu.ucsb.nceas.metacat.dataone;
|
25
|
|
26
|
import java.io.IOException;
|
27
|
import java.util.Date;
|
28
|
|
29
|
import javax.servlet.http.HttpServletRequest;
|
30
|
import javax.servlet.http.HttpServletResponse;
|
31
|
|
32
|
import org.dataone.service.mn.MemberNodeHealth;
|
33
|
import org.dataone.service.types.Identifier;
|
34
|
import org.dataone.service.types.ObjectFormat;
|
35
|
import org.dataone.service.types.ObjectInfo;
|
36
|
import org.omg.CORBA.portable.OutputStream;
|
37
|
|
38
|
/**
|
39
|
* @author berkley
|
40
|
* Class to implement the HealthService API for DataONE
|
41
|
*/
|
42
|
public class HealthService implements MemberNodeHealth
|
43
|
{
|
44
|
HttpServletRequest request;
|
45
|
HttpServletResponse response;
|
46
|
|
47
|
/**
|
48
|
* Constructor
|
49
|
* @param request
|
50
|
* @param response
|
51
|
*/
|
52
|
public HealthService(HttpServletRequest request, HttpServletResponse response)
|
53
|
{
|
54
|
this.request = request;
|
55
|
this.response = response;
|
56
|
}
|
57
|
|
58
|
/**
|
59
|
* Implements /monitory/ping from
|
60
|
* http://mule1.dataone.org/ArchitectureDocs-current/apis/REST_interface.html#get-monitor-object
|
61
|
*/
|
62
|
public void ping()
|
63
|
{
|
64
|
response.setStatus(200);
|
65
|
try
|
66
|
{
|
67
|
response.getOutputStream().write("OK".getBytes());
|
68
|
}
|
69
|
catch (IOException e)
|
70
|
{
|
71
|
System.out.println("ERROR getting ping response: " + e.getMessage());
|
72
|
e.printStackTrace();
|
73
|
response.setStatus(500);
|
74
|
}
|
75
|
}
|
76
|
|
77
|
/**
|
78
|
* implements /monitor/object from
|
79
|
* http://mule1.dataone.org/ArchitectureDocs-current/apis/REST_interface.html#get-monitor-object
|
80
|
*/
|
81
|
public void getObjectStatistics(boolean reportDaily,
|
82
|
Identifier guid, String url, ObjectFormat format, Date time)
|
83
|
{
|
84
|
response.setStatus(500);
|
85
|
try
|
86
|
{
|
87
|
response.getOutputStream().write("getObjectStatistics Not Implemented".getBytes());
|
88
|
response.getOutputStream().flush();
|
89
|
}
|
90
|
catch (IOException e)
|
91
|
{
|
92
|
System.out.println("Error in getObjectStatistics: " + e.getMessage());
|
93
|
e.printStackTrace();
|
94
|
}
|
95
|
|
96
|
}
|
97
|
|
98
|
/**
|
99
|
* implements /monitor/event from
|
100
|
* http://mule1.dataone.org/ArchitectureDocs-current/apis/REST_interface.html#get-monitor-object
|
101
|
*/
|
102
|
public void getOperationStatistics(boolean reportDaily, Identifier pid,
|
103
|
ObjectFormat format, Date createDate, Date eventTime, String ipAddress, String event)
|
104
|
{
|
105
|
response.setStatus(500);
|
106
|
try
|
107
|
{
|
108
|
response.getOutputStream().write("getOperationStatistics Not Implemented".getBytes());
|
109
|
response.getOutputStream().flush();
|
110
|
}
|
111
|
catch (IOException e)
|
112
|
{
|
113
|
System.out.println("Error in getOperationStatistics: " + e.getMessage());
|
114
|
e.printStackTrace();
|
115
|
}
|
116
|
}
|
117
|
|
118
|
/**
|
119
|
* Implements /monitor/status from
|
120
|
* http://mule1.dataone.org/ArchitectureDocs-current/apis/REST_interface.html#get-monitor-object
|
121
|
* This method is mostly unimplemented. Right now it just does what ping does.
|
122
|
* It should be updated in the future to return status information such as
|
123
|
* pending outages, software updates, etc. See Use Case 10 for more
|
124
|
* info.
|
125
|
*/
|
126
|
public void getStatus()
|
127
|
{
|
128
|
ping();
|
129
|
}
|
130
|
}
|