Revision 6023
Added by Chris Jones over 13 years ago
src/edu/ucsb/nceas/metacat/service/ObjectFormatService.java | ||
---|---|---|
1 |
/** |
|
2 |
* '$RCSfile$' |
|
3 |
* Purpose: A Class that implements session utility methods |
|
4 |
* Copyright: 2011 Regents of the University of California and the |
|
5 |
* National Center for Ecological Analysis and Synthesis |
|
6 |
* Authors: Christopher Jones |
|
7 |
* |
|
8 |
* '$Author: $' |
|
9 |
* '$Date: $' |
|
10 |
* '$Revision: $' |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or modify |
|
13 |
* it under the terms of the GNU General Public License as published by |
|
14 |
* the Free Software Foundation; either version 2 of the License, or |
|
15 |
* (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
25 |
*/ |
|
26 |
|
|
27 |
package edu.ucsb.nceas.metacat.service; |
|
28 |
|
|
29 |
import org.apache.commons.io.IOUtils; |
|
30 |
import org.apache.log4j.Logger; |
|
31 |
|
|
32 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
|
33 |
import edu.ucsb.nceas.metacat.shared.BaseService; |
|
34 |
import edu.ucsb.nceas.metacat.shared.ServiceException; |
|
35 |
|
|
36 |
/** |
|
37 |
* The ObjectFormatService manages the list of object formats registered |
|
38 |
* within Metacat. This includes schema types, mime types, and other |
|
39 |
* information related to a particular format. The service provides |
|
40 |
* functionality for the DataONE MemberNode and CoordinatingNode components, |
|
41 |
* with CoordinatingNodes providing the authoritative list of object formats. |
|
42 |
*/ |
|
43 |
public class ObjectFormatService extends BaseService { |
|
44 |
|
|
45 |
|
|
46 |
/* The instance of the logging class */ |
|
47 |
private static Logger logMetacat = Logger.getLogger(ObjectFormatService.class); |
|
48 |
|
|
49 |
/* The singleton instance of the object format service */ |
|
50 |
private ObjectFormatService objectFormatService = null; |
|
51 |
|
|
52 |
/* The scope of the object formats docid used as the metacat identifier */ |
|
53 |
private static final String OBJECT_FORMATS_SCOPE = "OBJECT_FORMAT_LIST.1"; |
|
54 |
|
|
55 |
/* The revision of the object formats document */ |
|
56 |
private int rev; |
|
57 |
|
|
58 |
/* |
|
59 |
* Constructor: Creates an instance of the object format service. Since |
|
60 |
* this uses a singleton pattern, use getInstance() to gain the instance. |
|
61 |
*/ |
|
62 |
private ObjectFormatService() { |
|
63 |
|
|
64 |
super(); |
|
65 |
this._serviceName="ObjectFormatService"; |
|
66 |
|
|
67 |
try { |
|
68 |
doRefresh(); |
|
69 |
|
|
70 |
} catch (ServiceException se) { |
|
71 |
logMetacat.debug("There was a problem creating the ObjectFormatService. " + |
|
72 |
"The error message was: " + se.getMessage()); |
|
73 |
|
|
74 |
} |
|
75 |
|
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* Get the instance of the ObjectFormatService that has been instantiated, |
|
80 |
* or instantiate one if it has not been already. |
|
81 |
* |
|
82 |
* @return objectFormatService - The instance of the object format service |
|
83 |
*/ |
|
84 |
public ObjectFormatService getInstance(){ |
|
85 |
|
|
86 |
if ( this.objectFormatService == null ) { |
|
87 |
|
|
88 |
this.objectFormatService = new ObjectFormatService(); |
|
89 |
|
|
90 |
} |
|
91 |
return this.objectFormatService; |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* Refreshes the object format service by manually updating the object |
|
96 |
* format document. |
|
97 |
*/ |
|
98 |
public void doRefresh() throws ServiceException { |
|
99 |
|
|
100 |
// stub only |
|
101 |
logMetacat.debug("ObjectFormatService.doRefresh() called. " + |
|
102 |
"Refreshing the object format service."); |
|
103 |
|
|
104 |
return; |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* Indicate whether or not this service is refreshable. In this case it is, |
|
109 |
* where the ObjectFormatService can manually get the latest object format |
|
110 |
* document from Metacat. |
|
111 |
* |
|
112 |
* @return refreshable - the boolean refreshable status |
|
113 |
*/ |
|
114 |
public boolean refreshable() { |
|
115 |
return true; |
|
116 |
|
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* Stop the ObjectFormatService. When stopped, the service will no longer |
|
121 |
* respond to requests. Not implemented yet. |
|
122 |
*/ |
|
123 |
public void stop() throws ServiceException { |
|
124 |
|
|
125 |
// stub only |
|
126 |
return; |
|
127 |
} |
|
128 |
|
|
129 |
} |
Also available in: Unified diff
This is the start of the ObjectFormatService, which manages the list of object formats registered within Metacat. This includes schema types, mime types, and other information related to a particular format. The service provides functionality for the DataONE MemberNode and CoordinatingNode components, with CoordinatingNodes providing the authoritative list of object formats. See https://redmine.dataone.org/issues/1378.
ObjectFormatService provides the following fields:
logMetacat - The instance of the logging class
objectFormatService - The singleton instance of the object format service
OBJECT_FORMATS_SCOPE - The scope of the object formats docid used as the metacat identifier.
rev - The revision of the object formats document
Provides the following singleton method:
getInstance() - Get the instance of the ObjectFormatService that has been instantiated, or instantiate one if it has not been already.
And the following stubbed methods that override methods in BaseService:
doRefresh() - Refreshes the object format service by manually updating the object format document.
refreshable() - Indicate whether or not this service is refreshable.
stop() - Stop the ObjectFormatService.