Revision 6514
Added by ben leinfelder over 12 years ago
CNResourceHandler.java | ||
---|---|---|
34 | 34 |
import javax.servlet.ServletContext; |
35 | 35 |
import javax.servlet.http.HttpServletRequest; |
36 | 36 |
import javax.servlet.http.HttpServletResponse; |
37 |
import javax.xml.parsers.ParserConfigurationException; |
|
37 | 38 |
|
38 | 39 |
import org.apache.commons.fileupload.FileUploadException; |
39 | 40 |
import org.apache.commons.io.IOUtils; |
... | ... | |
65 | 66 |
import org.dataone.service.util.DateTimeMarshaller; |
66 | 67 |
import org.dataone.service.util.TypeMarshaller; |
67 | 68 |
import org.jibx.runtime.JiBXException; |
69 |
import org.xml.sax.SAXException; |
|
68 | 70 |
|
69 | 71 |
import edu.ucsb.nceas.metacat.dataone.CNodeService; |
70 | 72 |
|
... | ... | |
150 | 152 |
|
151 | 153 |
if (resource.startsWith(RESOURCE_ACCESS_RULES) && httpVerb == PUT) { |
152 | 154 |
logMetacat.debug("Setting access policy"); |
153 |
setAccess(); |
|
155 |
// after the command |
|
156 |
extra = parseTrailing(resource, RESOURCE_ACCESS_RULES); |
|
157 |
setAccess(extra); |
|
154 | 158 |
status = true; |
155 | 159 |
logMetacat.debug("done setting access"); |
156 | 160 |
|
... | ... | |
308 | 312 |
} |
309 | 313 |
} |
310 | 314 |
|
311 |
private String parseTrailing(String resource, String token) { |
|
312 |
// get the rest |
|
313 |
String extra = null; |
|
314 |
if (resource.indexOf(token) != -1) { |
|
315 |
// what comes after the token? |
|
316 |
extra = resource.substring(resource.indexOf(token) + token.length()); |
|
317 |
// remove the slash |
|
318 |
if (extra.startsWith("/")) { |
|
319 |
extra = extra.substring(1); |
|
320 |
} |
|
321 |
// is there anything left? |
|
322 |
if (extra.length() == 0) { |
|
323 |
extra = null; |
|
324 |
} |
|
325 |
} |
|
326 |
return extra; |
|
327 |
} |
|
328 | 315 |
|
329 | 316 |
/** |
330 | 317 |
* Get the checksum for the given guid |
... | ... | |
787 | 774 |
* @throws IllegalAccessException |
788 | 775 |
* @throws InstantiationException |
789 | 776 |
* @throws IOException |
777 |
* @throws SAXException |
|
778 |
* @throws ParserConfigurationException |
|
790 | 779 |
*/ |
791 |
protected void setAccess() throws JiBXException, InvalidToken, ServiceFailure, NotFound, NotAuthorized, NotImplemented, InvalidRequest, IOException, InstantiationException, IllegalAccessException {
|
|
780 |
protected void setAccess(String pid) throws JiBXException, InvalidToken, ServiceFailure, NotFound, NotAuthorized, NotImplemented, InvalidRequest, IOException, InstantiationException, IllegalAccessException, ParserConfigurationException, SAXException {
|
|
792 | 781 |
|
793 |
String guid = params.get("guid")[0]; |
|
794 | 782 |
Identifier id = new Identifier(); |
795 |
id.setValue(guid);
|
|
796 |
String accesspolicy = params.get("accesspolicy")[0]; |
|
797 |
AccessPolicy accessPolicy = TypeMarshaller.unmarshalTypeFromStream(AccessPolicy.class, new ByteArrayInputStream(accesspolicy.getBytes("UTF-8")));
|
|
783 |
id.setValue(pid);
|
|
784 |
|
|
785 |
AccessPolicy accessPolicy = collectAccessPolicy();
|
|
798 | 786 |
CNodeService.getInstance().setAccessPolicy(session, id, accessPolicy); |
799 | 787 |
|
800 | 788 |
} |
Also available in: Unified diff
correctly handle incoming "accessPolicy" parameters for the setAccess() method