Revision 7695
Added by ben leinfelder over 11 years ago
src/perl/register-dataset.cgi | ||
---|---|---|
215 | 215 |
|
216 | 216 |
debug("Initialized -- stage set: $FORM::stage"); |
217 | 217 |
|
218 |
# handle pids, set the mapped docid in the FORM params |
|
219 |
# see: https://projects.ecoinformatics.org/ecoinfo/issues/5932 |
|
220 |
if ($FORM::pid !~ "" ) { |
|
221 |
my $pid = $FORM::pid; |
|
222 |
my $metacat = Metacat->new($metacatUrl); |
|
223 |
my $docid = $metacat->getDocid($pid); |
|
224 |
$FORM::docid = $docid; |
|
225 |
} |
|
226 |
|
|
218 | 227 |
# Process the form based on stage parameter. |
219 | 228 |
if ( $FORM::stage =~ "loginform" ) { |
220 | 229 |
print "Content-type: text/html\n\n"; |
src/perl/Metacat/Metacat.pm | ||
---|---|---|
437 | 437 |
} |
438 | 438 |
|
439 | 439 |
############################################################# |
440 |
# subroutine to get the docid for a given PID |
|
441 |
# If success, return docid, else return -1 |
|
442 |
############################################################# |
|
443 |
sub getDocid { |
|
444 |
my $self = shift; |
|
445 |
my $pid = shift; |
|
446 |
|
|
447 |
my $returnval = 0; |
|
448 |
|
|
449 |
my %postData = ( action => 'getdocid', |
|
450 |
pid => $pid |
|
451 |
); |
|
452 |
|
|
453 |
my $response = $self->sendData(%postData); |
|
454 |
if (($response) && $response->content =~ /<docid>(.*)<\/docid>/s) { |
|
455 |
$returnval = "$1"; |
|
456 |
} elsif (($response)) { |
|
457 |
$returnval = -1; |
|
458 |
#print "Error response from sendData!\n"; |
|
459 |
#print $response->content, "\n"; |
|
460 |
} else { |
|
461 |
$returnval = -1; |
|
462 |
#print "Invalid response from sendData!\n"; |
|
463 |
} |
|
464 |
|
|
465 |
return $returnval; |
|
466 |
} |
|
467 |
|
|
468 |
############################################################# |
|
440 | 469 |
# subroutine to get the message returned from the last executed |
441 | 470 |
# metacat action. These are generally XML formatted messages. |
442 | 471 |
############################################################# |
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
941 | 941 |
PrintWriter out = response.getWriter(); |
942 | 942 |
handler.handleGetDTDSchemaAction(out, params, response); |
943 | 943 |
out.close(); |
944 |
} else if (action.equals("getdocid")) { |
|
945 |
handler.handleGetDocid(params, response); |
|
944 | 946 |
} else if (action.equals("getlastdocid")) { |
945 | 947 |
PrintWriter out = response.getWriter(); |
946 | 948 |
handler.handleGetMaxDocidAction(out, params, response); |
src/edu/ucsb/nceas/metacat/MetacatHandler.java | ||
---|---|---|
2136 | 2136 |
} |
2137 | 2137 |
|
2138 | 2138 |
/** |
2139 |
* Look up the pid (guid)-to-docid mapping. |
|
2140 |
* Returns XML on the response, e.g.: |
|
2141 |
* <docid>sample.1.1</docid> |
|
2142 |
* |
|
2143 |
* @param params |
|
2144 |
* @param response |
|
2145 |
* @throws IOException |
|
2146 |
*/ |
|
2147 |
protected void handleGetDocid(Hashtable<String, String[]> params, HttpServletResponse response) throws IOException { |
|
2148 |
response.setContentType("text/xml"); |
|
2149 |
ServletOutputStream out = response.getOutputStream(); |
|
2150 |
try { |
|
2151 |
// Get pid from parameters |
|
2152 |
String pid = null; |
|
2153 |
if (params.containsKey("pid")) { |
|
2154 |
pid = params.get("pid")[0]; |
|
2155 |
} |
|
2156 |
String docid = IdentifierManager.getInstance().getLocalId(pid); |
|
2157 |
out.println(PROLOG); |
|
2158 |
out.println("<docid>"); |
|
2159 |
out.println(docid); |
|
2160 |
out.println("</docid>"); |
|
2161 |
|
|
2162 |
} catch (Exception e) { |
|
2163 |
// Handle exception |
|
2164 |
out.println(PROLOG); |
|
2165 |
out.println(ERROR); |
|
2166 |
out.println(e.getMessage()); |
|
2167 |
out.println(ERRORCLOSE); |
|
2168 |
} finally { |
|
2169 |
out.close(); |
|
2170 |
} |
|
2171 |
|
|
2172 |
} |
|
2173 |
|
|
2174 |
/** |
|
2139 | 2175 |
* Handle "getrevsionanddoctype" action Given a docid, return it's current |
2140 | 2176 |
* revision and doctype from data base The output is String look like |
2141 | 2177 |
* "rev;doctype" |
Also available in: Unified diff
Allow use of PID instead of docid in the Perl registry. At least for reading/editing and deleting existing content. Does not create content using a pid. https://projects.ecoinformatics.org/ecoinfo/issues/5932