Revision 6254
Added by Chris Jones over 13 years ago
src/edu/ucsb/nceas/metacat/dataone/MNodeService.java | ||
---|---|---|
96 | 96 |
*/ |
97 | 97 |
public static MNodeService getInstance() { |
98 | 98 |
if (instance == null) { |
99 |
String metacatUrl = ""; |
|
100 |
String server; |
|
101 |
String port; |
|
102 |
String context; |
|
103 |
String serviceName; |
|
104 |
|
|
105 |
try { |
|
106 |
server = PropertyService.getProperty("server.name"); |
|
107 |
port = PropertyService.getProperty("server.httpPort"); |
|
108 |
context = PropertyService.getProperty("application.context"); |
|
109 |
serviceName = PropertyService.getProperty("dataone.serviceName"); |
|
110 |
|
|
111 |
} catch (PropertyNotFoundException e) { |
|
112 |
throw new RuntimeException("Error getting the servlet url in MNodeService: " + |
|
113 |
e.getMessage()); |
|
114 |
|
|
115 |
} |
|
116 |
metacatUrl = "http://" + server + ":" + port + "/" + context + "/" + serviceName; |
|
117 | 99 |
|
118 |
instance = new MNodeService(metacatUrl);
|
|
100 |
instance = new MNodeService(); |
|
119 | 101 |
|
120 | 102 |
} |
121 | 103 |
|
... | ... | |
124 | 106 |
|
125 | 107 |
/** |
126 | 108 |
* Constructor, private for singleton access |
127 |
* |
|
128 |
* @param metacatUrl - the URL of the metacat service, including the context |
|
129 |
* and serviceName (/d1) |
|
130 | 109 |
*/ |
131 |
private MNodeService(String metacatUrl) {
|
|
132 |
super(metacatUrl);
|
|
110 |
private MNodeService() { |
|
111 |
super(); |
|
133 | 112 |
logMetacat = Logger.getLogger(MNodeService.class); |
134 | 113 |
|
135 | 114 |
} |
... | ... | |
201 | 180 |
try { |
202 | 181 |
// delete the document |
203 | 182 |
DocumentImpl.delete(localId, subject.getValue(), groups, null); |
204 |
|
|
183 |
EventLog.getInstance().log(metacatUrl, subject.getValue(), localId, "create"); |
|
184 |
|
|
205 | 185 |
} catch (McdbDocNotFoundException e) { |
206 | 186 |
throw new InvalidRequest("1322", "The provided identifier was invalid."); |
207 | 187 |
|
... | ... | |
260 | 240 |
UnsupportedType, InsufficientResources, NotFound, InvalidSystemMetadata, |
261 | 241 |
NotImplemented, InvalidRequest { |
262 | 242 |
|
263 |
return null; |
|
243 |
|
|
244 |
return pid; |
|
264 | 245 |
} |
265 | 246 |
|
266 | 247 |
/** |
src/edu/ucsb/nceas/metacat/dataone/CNodeService.java | ||
---|---|---|
91 | 91 |
*/ |
92 | 92 |
public static CNodeService getInstance() { |
93 | 93 |
if (instance == null) { |
94 |
String metacatUrl = ""; |
|
95 |
String server; |
|
96 |
String port; |
|
97 |
String context; |
|
98 |
String serviceName; |
|
99 |
|
|
100 |
try { |
|
101 |
server = PropertyService.getProperty("server.name"); |
|
102 |
port = PropertyService.getProperty("server.httpPort"); |
|
103 |
context = PropertyService.getProperty("application.context"); |
|
104 |
serviceName = PropertyService.getProperty("dataone.serviceName"); |
|
105 |
|
|
106 |
} catch (PropertyNotFoundException e) { |
|
107 |
throw new RuntimeException("Error getting the servlet url in MNodeService: " + |
|
108 |
e.getMessage()); |
|
109 |
|
|
110 |
} |
|
111 |
metacatUrl = "http://" + server + ":" + port + "/" + context + "/" + serviceName; |
|
112 | 94 |
|
113 |
instance = new CNodeService(metacatUrl);
|
|
95 |
instance = new CNodeService(); |
|
114 | 96 |
|
115 | 97 |
} |
116 | 98 |
|
... | ... | |
119 | 101 |
|
120 | 102 |
/** |
121 | 103 |
* Constructor, private for singleton access |
122 |
* |
|
123 |
* @param metacatUrl - the URL of the metacat service, including the context |
|
124 |
* and serviceName (/d1) |
|
125 | 104 |
*/ |
126 |
private CNodeService(String metacatUrl) {
|
|
127 |
super(metacatUrl);
|
|
105 |
private CNodeService() { |
|
106 |
super(); |
|
128 | 107 |
logMetacat = Logger.getLogger(CNodeService.class); |
129 | 108 |
|
130 | 109 |
} |
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java | ||
---|---|---|
83 | 83 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
84 | 84 |
import edu.ucsb.nceas.metacat.replication.ForceReplicationHandler; |
85 | 85 |
import edu.ucsb.nceas.metacat.util.SessionData; |
86 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
|
86 | 87 |
import edu.ucsb.nceas.utilities.ParseLSIDException; |
87 | 88 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
88 | 89 |
|
... | ... | |
91 | 92 |
private static Logger logMetacat = Logger.getLogger(D1NodeService.class); |
92 | 93 |
|
93 | 94 |
/* the metacat URL as a string (including ending /d1 service)*/ |
94 |
private String metacatUrl;
|
|
95 |
protected String metacatUrl;
|
|
95 | 96 |
|
96 | 97 |
/* reference to the metacat handler */ |
97 | 98 |
private MetacatHandler handler; |
... | ... | |
104 | 105 |
* |
105 | 106 |
* @param metacatUrl - the URL of the metacat service, including the ending /d1 |
106 | 107 |
*/ |
107 |
public D1NodeService(String metacatUrl) { |
|
108 |
this.metacatUrl = metacatUrl; |
|
108 |
public D1NodeService() { |
|
109 |
this.metacatUrl = ""; |
|
110 |
|
|
111 |
try { |
|
112 |
this.metacatUrl = SystemUtil.getContextURL() + |
|
113 |
PropertyService.getProperty("dataone.serviceName"); |
|
114 |
} catch (PropertyNotFoundException e) { |
|
115 |
throw new RuntimeException("Error getting the servlet url in D1NodeService: " + |
|
116 |
e.getMessage()); |
|
117 |
|
|
118 |
} |
|
109 | 119 |
|
110 | 120 |
} |
111 | 121 |
|
Also available in: Unified diff
At Ben's suggestion, add metacatUrl to D1NodeService and make it available to subclasses. Set the metacatUrl in the constructor using SystemUtil rather than all roll your own PropertyService calls. More concise. Also, log the delete event in MNodeService.delete().