Revision 6367
Added by ben leinfelder over 13 years ago
src/edu/ucsb/nceas/metacat/restservice/MNResourceHandler.java | ||
---|---|---|
28 | 28 |
import java.io.IOException; |
29 | 29 |
import java.io.InputStream; |
30 | 30 |
import java.io.OutputStream; |
31 |
import java.io.UnsupportedEncodingException; |
|
32 | 31 |
import java.text.DateFormat; |
33 | 32 |
import java.text.ParseException; |
34 | 33 |
import java.text.SimpleDateFormat; |
... | ... | |
73 | 72 |
import org.dataone.service.types.v1.Permission; |
74 | 73 |
import org.dataone.service.types.v1.Subject; |
75 | 74 |
import org.dataone.service.types.v1.SystemMetadata; |
75 |
import org.dataone.service.util.TypeMarshaller; |
|
76 | 76 |
import org.jibx.runtime.JiBXException; |
77 | 77 |
|
78 | 78 |
import edu.ucsb.nceas.metacat.dataone.MNodeService; |
... | ... | |
307 | 307 |
* @throws ServiceFailure |
308 | 308 |
* @throws NotAuthorized |
309 | 309 |
* @throws InvalidRequest |
310 |
* @throws UnsupportedEncodingException |
|
311 | 310 |
* @throws JiBXException |
311 |
* @throws IllegalAccessException |
|
312 |
* @throws InstantiationException |
|
313 |
* @throws IOException |
|
312 | 314 |
*/ |
313 |
private void syncError() throws NotImplemented, ServiceFailure, NotAuthorized, InvalidRequest, UnsupportedEncodingException, JiBXException {
|
|
315 |
private void syncError() throws NotImplemented, ServiceFailure, NotAuthorized, InvalidRequest, JiBXException, IOException, InstantiationException, IllegalAccessException {
|
|
314 | 316 |
SynchronizationFailed syncFailed = null; |
315 | 317 |
if (params.containsKey("message")) { |
316 | 318 |
String message = params.get("message")[0]; |
317 |
syncFailed = (SynchronizationFailed) deserializeServiceType(SynchronizationFailed.class, new ByteArrayInputStream(message.getBytes("UTF-8")));
|
|
319 |
syncFailed = TypeMarshaller.unmarshalTypeFromStream(SynchronizationFailed.class, new ByteArrayInputStream(message.getBytes("UTF-8")));
|
|
318 | 320 |
} |
319 | 321 |
MNodeService.getInstance().synchronizationFailed(session, syncFailed); |
320 | 322 |
} |
... | ... | |
415 | 417 |
response.setStatus(200); |
416 | 418 |
response.setContentType("text/xml"); |
417 | 419 |
|
418 |
serializeServiceType(MonitorList.class, monitorList, out);
|
|
420 |
TypeMarshaller.marshalTypeToOutputStream(monitorList, out);
|
|
419 | 421 |
|
420 | 422 |
return true; |
421 | 423 |
|
... | ... | |
484 | 486 |
logMetacat.debug("got checksum " + c.getValue()); |
485 | 487 |
response.setStatus(200); |
486 | 488 |
logMetacat.debug("serializing response"); |
487 |
serializeServiceType(Checksum.class, c, response.getOutputStream());
|
|
489 |
TypeMarshaller.marshalTypeToOutputStream(c, response.getOutputStream());
|
|
488 | 490 |
logMetacat.debug("done serializing response."); |
489 | 491 |
|
490 | 492 |
} |
... | ... | |
500 | 502 |
* @throws InsufficientResources |
501 | 503 |
* @throws NotAuthorized |
502 | 504 |
* @throws NotImplemented |
505 |
* @throws IllegalAccessException |
|
506 |
* @throws InstantiationException |
|
503 | 507 |
*/ |
504 |
private void replicate() throws ServiceFailure, InvalidRequest, IOException, FileUploadException, JiBXException, NotImplemented, NotAuthorized, InsufficientResources, UnsupportedType { |
|
508 |
private void replicate() throws ServiceFailure, InvalidRequest, IOException, FileUploadException, JiBXException, NotImplemented, NotAuthorized, InsufficientResources, UnsupportedType, InstantiationException, IllegalAccessException {
|
|
505 | 509 |
|
506 | 510 |
logMetacat.debug("in POST replicate()"); |
507 | 511 |
|
... | ... | |
510 | 514 |
|
511 | 515 |
String sn = multipartparams.get("sourceNode").get(0); |
512 | 516 |
logMetacat.debug("sourceNode: " + sn); |
513 |
NodeReference sourceNode = (NodeReference) deserializeServiceType(NodeReference.class, new ByteArrayInputStream(sn.getBytes("UTF-8")));
|
|
517 |
NodeReference sourceNode = TypeMarshaller.unmarshalTypeFromStream(NodeReference.class, new ByteArrayInputStream(sn.getBytes("UTF-8")));
|
|
514 | 518 |
|
515 | 519 |
MNodeService.getInstance().replicate(session, sysmeta, sourceNode); |
516 | 520 |
|
... | ... | |
538 | 542 |
|
539 | 543 |
response.setContentType("text/xml"); |
540 | 544 |
response.setStatus(200); |
541 |
serializeServiceType(NodeList.class, nl, response.getOutputStream());
|
|
545 |
TypeMarshaller.marshalTypeToOutputStream(nl, response.getOutputStream());
|
|
542 | 546 |
|
543 | 547 |
} |
544 | 548 |
|
... | ... | |
565 | 569 |
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SZ"); |
566 | 570 |
response.addHeader("pid", pid); |
567 | 571 |
response.addHeader("checksum", dr.getDataONE_Checksum().getValue()); |
568 |
response.addHeader("checksum_algorithm", dr.getDataONE_Checksum().getAlgorithm().name());
|
|
572 |
response.addHeader("checksum_algorithm", dr.getDataONE_Checksum().getAlgorithm().xmlValue());
|
|
569 | 573 |
response.addHeader("content_length", dr.getContent_Length() + ""); |
570 | 574 |
response.addHeader("last_modified", dateFormat.format(dr.getLast_Modified())); |
571 | 575 |
response.addHeader("format", dr.getDataONE_ObjectFormat().toString()); |
... | ... | |
633 | 637 |
response.setStatus(200); |
634 | 638 |
response.setContentType("text/xml"); |
635 | 639 |
|
636 |
serializeServiceType(Log.class, log, out);
|
|
640 |
TypeMarshaller.marshalTypeToOutputStream(log, out);
|
|
637 | 641 |
|
638 | 642 |
} |
639 | 643 |
|
... | ... | |
771 | 775 |
response.setStatus(200); |
772 | 776 |
response.setContentType("text/xml"); |
773 | 777 |
// Serialize and write it to the output stream |
774 |
serializeServiceType(ObjectList.class, ol, out);
|
|
778 |
TypeMarshaller.marshalTypeToOutputStream(ol, out);
|
|
775 | 779 |
|
776 | 780 |
} |
777 | 781 |
|
... | ... | |
801 | 805 |
OutputStream out = response.getOutputStream(); |
802 | 806 |
|
803 | 807 |
// Serialize and write it to the output stream |
804 |
serializeServiceType(SystemMetadata.class, sysmeta, out);
|
|
808 |
TypeMarshaller.marshalTypeToOutputStream(sysmeta, out);
|
|
805 | 809 |
} |
806 | 810 |
|
807 | 811 |
|
... | ... | |
822 | 826 |
* @throws InvalidToken |
823 | 827 |
* @throws NotFound |
824 | 828 |
* @throws IOException |
829 |
* @throws IllegalAccessException |
|
830 |
* @throws InstantiationException |
|
825 | 831 |
*/ |
826 |
protected void putObject(String pid, String action) throws ServiceFailure, InvalidRequest, JiBXException, InvalidToken, NotAuthorized, IdentifierNotUnique, UnsupportedType, InsufficientResources, InvalidSystemMetadata, NotImplemented, NotFound, IOException { |
|
832 |
protected void putObject(String pid, String action) throws ServiceFailure, InvalidRequest, JiBXException, InvalidToken, NotAuthorized, IdentifierNotUnique, UnsupportedType, InsufficientResources, InvalidSystemMetadata, NotImplemented, NotFound, IOException, InstantiationException, IllegalAccessException {
|
|
827 | 833 |
logMetacat.debug("putObject with pid " + pid); |
828 | 834 |
logMetacat.debug("Entering putObject: " + pid + "/" + action); |
829 | 835 |
|
... | ... | |
844 | 850 |
if (action.equals(FUNCTION_NAME_INSERT)) { |
845 | 851 |
// handle inserts |
846 | 852 |
logMetacat.debug("Commence creation..."); |
847 |
SystemMetadata smd = (SystemMetadata) deserializeServiceType(SystemMetadata.class, sysmeta);
|
|
853 |
SystemMetadata smd = TypeMarshaller.unmarshalTypeFromStream(SystemMetadata.class, sysmeta);
|
|
848 | 854 |
|
849 | 855 |
Identifier id = new Identifier(); |
850 | 856 |
id.setValue(pid); |
851 | 857 |
logMetacat.debug("creating object with pid " + pid); |
852 | 858 |
Identifier rId = MNodeService.getInstance().create(session, id, object, smd); |
853 |
serializeServiceType(Identifier.class, rId, out);
|
|
859 |
TypeMarshaller.marshalTypeToOutputStream(rId, out);
|
|
854 | 860 |
|
855 | 861 |
} else if (action.equals(FUNCTION_NAME_UPDATE)) { |
856 | 862 |
// handle updates |
... | ... | |
870 | 876 |
logMetacat.debug("Commence update..."); |
871 | 877 |
|
872 | 878 |
// get the systemmetadata object |
873 |
SystemMetadata smd = (SystemMetadata) deserializeServiceType(SystemMetadata.class, sysmeta);
|
|
879 |
SystemMetadata smd = TypeMarshaller.unmarshalTypeFromStream(SystemMetadata.class, sysmeta);
|
|
874 | 880 |
|
875 | 881 |
Identifier rId = MNodeService.getInstance().update(session, newPid, object, obsoletedPid, smd); |
876 |
serializeServiceType(Identifier.class, rId, out);
|
|
882 |
TypeMarshaller.marshalTypeToOutputStream(rId, out);
|
|
877 | 883 |
} else { |
878 | 884 |
throw new InvalidRequest("1000", "Operation must be create or update."); |
879 | 885 |
} |
... | ... | |
905 | 911 |
|
906 | 912 |
logMetacat.debug("Calling delete"); |
907 | 913 |
MNodeService.getInstance().delete(session, id); |
908 |
serializeServiceType(Identifier.class, id, out);
|
|
914 |
TypeMarshaller.marshalTypeToOutputStream(id, out);
|
|
909 | 915 |
|
910 | 916 |
} |
911 | 917 |
|
912 | 918 |
/** |
913 | 919 |
* set the access perms on a document |
914 | 920 |
* @throws JiBXException |
915 |
* @throws UnsupportedEncodingException |
|
916 | 921 |
* @throws InvalidRequest |
917 | 922 |
* @throws NotImplemented |
918 | 923 |
* @throws NotAuthorized |
919 | 924 |
* @throws NotFound |
920 | 925 |
* @throws ServiceFailure |
921 | 926 |
* @throws InvalidToken |
927 |
* @throws IllegalAccessException |
|
928 |
* @throws InstantiationException |
|
929 |
* @throws IOException |
|
922 | 930 |
*/ |
923 |
protected void setAccess() throws UnsupportedEncodingException, JiBXException, InvalidToken, ServiceFailure, NotFound, NotAuthorized, NotImplemented, InvalidRequest
|
|
931 |
protected void setAccess() throws JiBXException, InvalidToken, ServiceFailure, NotFound, NotAuthorized, NotImplemented, InvalidRequest, IOException, InstantiationException, IllegalAccessException
|
|
924 | 932 |
{ |
925 | 933 |
|
926 | 934 |
String pid = params.get("pid")[0]; |
927 | 935 |
Identifier id = new Identifier(); |
928 | 936 |
id.setValue(pid); |
929 | 937 |
String accesspolicy = params.get("accesspolicy")[0]; |
930 |
AccessPolicy accessPolicy = (AccessPolicy) deserializeServiceType(AccessPolicy.class, new ByteArrayInputStream(accesspolicy.getBytes("UTF-8")));
|
|
938 |
AccessPolicy accessPolicy = TypeMarshaller.unmarshalTypeFromStream(AccessPolicy.class, new ByteArrayInputStream(accesspolicy.getBytes("UTF-8")));
|
|
931 | 939 |
MNodeService.getInstance().setAccessPolicy(session, id, accessPolicy); |
932 | 940 |
|
933 | 941 |
|
src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java | ||
---|---|---|
50 | 50 |
|
51 | 51 |
import org.apache.commons.io.IOUtils; |
52 | 52 |
import org.apache.log4j.Logger; |
53 |
import org.apache.maven.artifact.ant.shaded.IOUtil; |
|
54 | 53 |
import org.dataone.client.MNode; |
55 | 54 |
import org.dataone.client.ObjectFormatCache; |
56 | 55 |
import org.dataone.client.auth.CertificateManager; |
... | ... | |
87 | 86 |
import org.dataone.service.types.v1.Session; |
88 | 87 |
import org.dataone.service.types.v1.SystemMetadata; |
89 | 88 |
import org.dataone.service.types.v1.util.ChecksumUtil; |
90 |
import org.dataone.service.types.util.ServiceTypeUtil;
|
|
89 |
import org.dataone.service.util.TypeMarshaller;
|
|
91 | 90 |
import org.jibx.runtime.BindingDirectory; |
92 | 91 |
import org.jibx.runtime.IBindingFactory; |
93 | 92 |
import org.jibx.runtime.IUnmarshallingContext; |
... | ... | |
825 | 824 |
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SZ"); |
826 | 825 |
response.addHeader("guid", guid); |
827 | 826 |
response.addHeader("checksum", dr.getDataONE_Checksum().getValue()); |
828 |
response.addHeader("checksum_algorithm", dr.getDataONE_Checksum().getAlgorithm().name());
|
|
827 |
response.addHeader("checksum_algorithm", dr.getDataONE_Checksum().getAlgorithm().xmlValue());
|
|
829 | 828 |
response.addHeader("content_length", dr.getContent_Length() + ""); |
830 | 829 |
response.addHeader("last_modified", dateFormat.format(dr.getLast_Modified())); |
831 | 830 |
response.addHeader("format", dr.getDataONE_ObjectFormat().toString()); |
... | ... | |
1361 | 1360 |
* @param object the object to serialize |
1362 | 1361 |
* @param out the stream to serialize it to |
1363 | 1362 |
* @throws JiBXException |
1363 |
* @throws IOException |
|
1364 | 1364 |
*/ |
1365 | 1365 |
protected void serializeServiceType(Class type, Object object, OutputStream out) |
1366 |
throws JiBXException |
|
1366 |
throws JiBXException, IOException
|
|
1367 | 1367 |
{ |
1368 |
ServiceTypeUtil.serializeServiceType(type, object, out);
|
|
1368 |
TypeMarshaller.marshalTypeToOutputStream(object, out);
|
|
1369 | 1369 |
} |
1370 | 1370 |
|
1371 | 1371 |
/** |
... | ... | |
1373 | 1373 |
* @param type the class of the object to serialize (i.e. SystemMetadata.class) |
1374 | 1374 |
* @param is the stream to deserialize from |
1375 | 1375 |
* @throws JiBXException |
1376 |
* @throws IllegalAccessException |
|
1377 |
* @throws InstantiationException |
|
1378 |
* @throws IOException |
|
1376 | 1379 |
*/ |
1377 | 1380 |
protected Object deserializeServiceType(Class type, InputStream is) |
1378 |
throws JiBXException |
|
1381 |
throws JiBXException, IOException, InstantiationException, IllegalAccessException
|
|
1379 | 1382 |
{ |
1380 |
return ServiceTypeUtil.deserializeServiceType(type, is);
|
|
1383 |
return TypeMarshaller.unmarshalTypeFromStream(type, is);
|
|
1381 | 1384 |
} |
1382 | 1385 |
|
1383 | 1386 |
/** |
... | ... | |
1546 | 1549 |
* |
1547 | 1550 |
* @param guid - ID of data object to be inserted or updated. If action is update, the pid |
1548 | 1551 |
* is the existing pid. If insert, the pid is the new one |
1549 |
* @throws IOException |
|
1552 |
* @throws IOException
|
|
1550 | 1553 |
*/ |
1551 |
protected void putObject(String pid, String action) { |
|
1554 |
protected void putObject(String pid, String action) throws IOException {
|
|
1552 | 1555 |
System.out.println("ResourceHandler: putObject with pid " + pid); |
1553 | 1556 |
logMetacat.debug("Entering putObject: " + pid + "/" + action); |
1554 | 1557 |
OutputStream out = null; |
... | ... | |
1952 | 1955 |
response.setStatus(200); |
1953 | 1956 |
serializeException(e, out); |
1954 | 1957 |
|
1955 |
} catch (JiBXException jibxe) {
|
|
1958 |
} catch (Exception e) {
|
|
1956 | 1959 |
response.setStatus(501); |
1957 |
ServiceFailure e = |
|
1960 |
ServiceFailure se =
|
|
1958 | 1961 |
new ServiceFailure("4841", "Unexpected exception from the service - " + |
1959 |
jibxe.getClass() + ": " + jibxe.getMessage());
|
|
1960 |
serializeException(e, out); |
|
1962 |
e.getClass() + ": " + e.getMessage());
|
|
1963 |
serializeException(se, out);
|
|
1961 | 1964 |
|
1962 | 1965 |
} |
1963 | 1966 |
|
... | ... | |
2012 | 2015 |
response.setStatus(200); |
2013 | 2016 |
serializeException(e, out); |
2014 | 2017 |
|
2015 |
} catch (JiBXException jibxe) {
|
|
2016 |
ServiceFailure e = |
|
2018 |
} catch (Exception e) {
|
|
2019 |
ServiceFailure se =
|
|
2017 | 2020 |
new ServiceFailure("4841", "Unexpected exception from the service - " + |
2018 |
jibxe.getClass() + ": " + jibxe.getMessage());
|
|
2019 |
serializeException(e, out); |
|
2021 |
e.getClass() + ": " + e.getMessage());
|
|
2022 |
serializeException(se, out);
|
|
2020 | 2023 |
|
2021 | 2024 |
} |
2022 | 2025 |
|
... | ... | |
2137 | 2140 |
+ guid.getValue()); |
2138 | 2141 |
boolean result = CNodeService.getInstance().registerSystemMetadata( |
2139 | 2142 |
session, guid, systemMetadata); |
2140 |
serializeServiceType(Boolean.class, result, out);
|
|
2143 |
TypeMarshaller.marshalTypeToOutputStream(result, out);
|
|
2141 | 2144 |
|
2142 | 2145 |
} catch (NotAuthorized e) { |
2143 | 2146 |
response.setStatus(500); |
... | ... | |
2154 | 2157 |
} catch (InvalidRequest e) { |
2155 | 2158 |
response.setStatus(500); |
2156 | 2159 |
serializeException(e, out); |
2157 |
} catch (JiBXException e) { |
|
2160 |
} catch (InvalidSystemMetadata e) { |
|
2161 |
serializeException(e, out); |
|
2162 |
} catch (Exception e) { |
|
2158 | 2163 |
response.setStatus(500); |
2159 | 2164 |
e.printStackTrace(System.out); |
2160 | 2165 |
InvalidSystemMetadata ism = new InvalidSystemMetadata("1080", e |
2161 | 2166 |
.getMessage()); |
2162 | 2167 |
serializeException(ism, out); |
2163 |
} catch (InvalidSystemMetadata e) { |
|
2164 |
serializeException(e, out); |
|
2165 |
} |
|
2168 |
} |
|
2166 | 2169 |
} |
2167 | 2170 |
|
2168 | 2171 |
} |
src/edu/ucsb/nceas/metacat/restservice/CNResourceHandler.java | ||
---|---|---|
28 | 28 |
import java.io.IOException; |
29 | 29 |
import java.io.InputStream; |
30 | 30 |
import java.io.OutputStream; |
31 |
import java.io.UnsupportedEncodingException; |
|
32 | 31 |
import java.util.Date; |
33 | 32 |
import java.util.Map; |
34 | 33 |
|
... | ... | |
64 | 63 |
import org.dataone.service.types.v1.QueryType; |
65 | 64 |
import org.dataone.service.types.v1.Subject; |
66 | 65 |
import org.dataone.service.types.v1.SystemMetadata; |
66 |
import org.dataone.service.util.TypeMarshaller; |
|
67 | 67 |
import org.jibx.runtime.JiBXException; |
68 | 68 |
|
69 | 69 |
import edu.ucsb.nceas.metacat.dataone.CNodeService; |
... | ... | |
316 | 316 |
logMetacat.debug("got checksum " + c.getValue()); |
317 | 317 |
response.setStatus(200); |
318 | 318 |
logMetacat.debug("serializing response"); |
319 |
serializeServiceType(Checksum.class, c, response.getOutputStream());
|
|
319 |
TypeMarshaller.marshalTypeToOutputStream(c, response.getOutputStream());
|
|
320 | 320 |
logMetacat.debug("done serializing response."); |
321 | 321 |
|
322 | 322 |
} |
... | ... | |
383 | 383 |
response.setStatus(200); |
384 | 384 |
response.setContentType("text/xml"); |
385 | 385 |
|
386 |
serializeServiceType(Log.class, log, out);
|
|
386 |
TypeMarshaller.marshalTypeToOutputStream(log, out);
|
|
387 | 387 |
|
388 | 388 |
} |
389 | 389 |
|
... | ... | |
461 | 461 |
OutputStream out = response.getOutputStream(); |
462 | 462 |
|
463 | 463 |
// Serialize and write it to the output stream |
464 |
serializeServiceType(SystemMetadata.class, sysmeta, out);
|
|
464 |
TypeMarshaller.marshalTypeToOutputStream(sysmeta, out);
|
|
465 | 465 |
} |
466 | 466 |
|
467 | 467 |
/** |
... | ... | |
480 | 480 |
* @throws NotAuthorized |
481 | 481 |
* @throws InvalidToken |
482 | 482 |
* @throws IOException |
483 |
* @throws IllegalAccessException |
|
484 |
* @throws InstantiationException |
|
483 | 485 |
*/ |
484 |
protected void putObject(String pid, String action) throws ServiceFailure, InvalidRequest, IdentifierNotUnique, JiBXException, InvalidToken, NotAuthorized, UnsupportedType, InsufficientResources, InvalidSystemMetadata, NotImplemented, IOException { |
|
486 |
protected void putObject(String pid, String action) throws ServiceFailure, InvalidRequest, IdentifierNotUnique, JiBXException, InvalidToken, NotAuthorized, UnsupportedType, InsufficientResources, InvalidSystemMetadata, NotImplemented, IOException, InstantiationException, IllegalAccessException {
|
|
485 | 487 |
logMetacat.debug("Entering putObject: " + pid + "/" + action); |
486 | 488 |
|
487 | 489 |
// Read the incoming data from its Mime Multipart encoding |
... | ... | |
497 | 499 |
if (action.equals(FUNCTION_NAME_INSERT)) { //handle inserts |
498 | 500 |
|
499 | 501 |
logMetacat.debug("Commence creation..."); |
500 |
SystemMetadata smd = (SystemMetadata) deserializeServiceType(SystemMetadata.class, sysmeta);
|
|
502 |
SystemMetadata smd = TypeMarshaller.unmarshalTypeFromStream(SystemMetadata.class, sysmeta);
|
|
501 | 503 |
|
502 | 504 |
Identifier id = new Identifier(); |
503 | 505 |
id.setValue(pid); |
... | ... | |
508 | 510 |
response.setStatus(200); |
509 | 511 |
response.setContentType("text/xml"); |
510 | 512 |
|
511 |
serializeServiceType(Identifier.class, rId, out);
|
|
513 |
TypeMarshaller.marshalTypeToOutputStream(rId, out);
|
|
512 | 514 |
|
513 | 515 |
} else { |
514 | 516 |
throw new InvalidRequest("1000", "Operation must be create."); |
... | ... | |
534 | 536 |
response.setStatus(200); |
535 | 537 |
response.setContentType("text/xml"); |
536 | 538 |
|
537 |
serializeServiceType(ObjectFormatList.class, objectFormatList, out);
|
|
539 |
TypeMarshaller.marshalTypeToOutputStream(objectFormatList, out);
|
|
538 | 540 |
|
539 | 541 |
} |
540 | 542 |
|
... | ... | |
563 | 565 |
response.setStatus(200); |
564 | 566 |
response.setContentType("text/xml"); |
565 | 567 |
|
566 |
serializeServiceType(ObjectFormat.class, objectFormat, out);
|
|
568 |
TypeMarshaller.marshalTypeToOutputStream(objectFormat, out);
|
|
567 | 569 |
|
568 | 570 |
} |
569 | 571 |
|
... | ... | |
605 | 607 |
OutputStream out = response.getOutputStream(); |
606 | 608 |
response.setStatus(200); |
607 | 609 |
response.setContentType("text/xml"); |
608 |
serializeServiceType(Identifier.class, retPid, out);
|
|
610 |
TypeMarshaller.marshalTypeToOutputStream(retPid, out);
|
|
609 | 611 |
|
610 | 612 |
} |
611 | 613 |
|
... | ... | |
628 | 630 |
OutputStream out = response.getOutputStream(); |
629 | 631 |
response.setStatus(200); |
630 | 632 |
response.setContentType("text/xml"); |
631 |
serializeServiceType(ObjectLocationList.class, locationList, out);
|
|
633 |
TypeMarshaller.marshalTypeToOutputStream(locationList, out);
|
|
632 | 634 |
|
633 | 635 |
} |
634 | 636 |
|
... | ... | |
676 | 678 |
* @throws NotImplemented |
677 | 679 |
* @throws InvalidRequest |
678 | 680 |
* @throws IOException |
681 |
* @throws IllegalAccessException |
|
682 |
* @throws InstantiationException |
|
679 | 683 |
*/ |
680 |
private void owner(String id) throws JiBXException, InvalidToken, ServiceFailure, NotFound, NotAuthorized, NotImplemented, InvalidRequest, IOException { |
|
684 |
private void owner(String id) throws JiBXException, InvalidToken, ServiceFailure, NotFound, NotAuthorized, NotImplemented, InvalidRequest, IOException, InstantiationException, IllegalAccessException {
|
|
681 | 685 |
Identifier pid = new Identifier(); |
682 | 686 |
pid.setValue(id); |
683 | 687 |
String subjectStr = params.get("subject")[0]; |
684 |
Subject subject = (Subject) deserializeServiceType(Subject.class, new ByteArrayInputStream(subjectStr.getBytes("UTF-8")));
|
|
688 |
Subject subject = TypeMarshaller.unmarshalTypeFromStream(Subject.class, new ByteArrayInputStream(subjectStr.getBytes("UTF-8")));
|
|
685 | 689 |
Identifier retPid = CNodeService.getInstance().setOwner(session, pid, subject); |
686 | 690 |
OutputStream out = response.getOutputStream(); |
687 | 691 |
response.setStatus(200); |
688 | 692 |
response.setContentType("text/xml"); |
689 |
serializeServiceType(Identifier.class, retPid, out);
|
|
693 |
TypeMarshaller.marshalTypeToOutputStream(retPid, out);
|
|
690 | 694 |
} |
691 | 695 |
|
692 | 696 |
/** |
... | ... | |
721 | 725 |
* @throws InvalidSystemMetadata |
722 | 726 |
* @throws NotAuthorized |
723 | 727 |
* @throws NotImplemented |
728 |
* @throws IllegalAccessException |
|
729 |
* @throws InstantiationException |
|
724 | 730 |
*/ |
725 |
protected boolean registerSystemMetadata(String pid) throws ServiceFailure, InvalidRequest, IOException, FileUploadException, JiBXException, NotImplemented, NotAuthorized, InvalidSystemMetadata { |
|
731 |
protected boolean registerSystemMetadata(String pid) throws ServiceFailure, InvalidRequest, IOException, FileUploadException, JiBXException, NotImplemented, NotAuthorized, InvalidSystemMetadata, InstantiationException, IllegalAccessException {
|
|
726 | 732 |
logMetacat.debug("Entering registerSystemMetadata: " + pid); |
727 | 733 |
|
728 | 734 |
// get the system metadata from the request |
... | ... | |
742 | 748 |
/** |
743 | 749 |
* set the access perms on a document |
744 | 750 |
* @throws JiBXException |
745 |
* @throws UnsupportedEncodingException |
|
746 | 751 |
* @throws InvalidRequest |
747 | 752 |
* @throws NotImplemented |
748 | 753 |
* @throws NotAuthorized |
749 | 754 |
* @throws NotFound |
750 | 755 |
* @throws ServiceFailure |
751 | 756 |
* @throws InvalidToken |
757 |
* @throws IllegalAccessException |
|
758 |
* @throws InstantiationException |
|
759 |
* @throws IOException |
|
752 | 760 |
*/ |
753 |
protected void setAccess() throws UnsupportedEncodingException, JiBXException, InvalidToken, ServiceFailure, NotFound, NotAuthorized, NotImplemented, InvalidRequest {
|
|
761 |
protected void setAccess() throws JiBXException, InvalidToken, ServiceFailure, NotFound, NotAuthorized, NotImplemented, InvalidRequest, IOException, InstantiationException, IllegalAccessException {
|
|
754 | 762 |
|
755 | 763 |
String guid = params.get("guid")[0]; |
756 | 764 |
Identifier id = new Identifier(); |
757 | 765 |
id.setValue(guid); |
758 | 766 |
String accesspolicy = params.get("accesspolicy")[0]; |
759 |
AccessPolicy accessPolicy = (AccessPolicy) deserializeServiceType(AccessPolicy.class, new ByteArrayInputStream(accesspolicy.getBytes("UTF-8")));
|
|
767 |
AccessPolicy accessPolicy = TypeMarshaller.unmarshalTypeFromStream(AccessPolicy.class, new ByteArrayInputStream(accesspolicy.getBytes("UTF-8")));
|
|
760 | 768 |
CNodeService.getInstance().setAccessPolicy(session, id, accessPolicy); |
761 | 769 |
|
762 | 770 |
} |
src/edu/ucsb/nceas/metacat/restservice/D1ResourceHandler.java | ||
---|---|---|
56 | 56 |
import org.dataone.service.exceptions.ServiceFailure; |
57 | 57 |
import org.dataone.service.types.v1.Session; |
58 | 58 |
import org.dataone.service.types.v1.SystemMetadata; |
59 |
import org.dataone.service.types.util.ServiceTypeUtil;
|
|
59 |
import org.dataone.service.util.TypeMarshaller;
|
|
60 | 60 |
import org.jibx.runtime.JiBXException; |
61 | 61 |
|
62 | 62 |
import edu.ucsb.nceas.metacat.MetacatHandler; |
... | ... | |
150 | 150 |
} |
151 | 151 |
} |
152 | 152 |
|
153 |
protected SystemMetadata collectSystemMetadata() throws IOException, FileUploadException, ServiceFailure, InvalidRequest, JiBXException { |
|
153 |
protected SystemMetadata collectSystemMetadata() throws IOException, FileUploadException, ServiceFailure, InvalidRequest, JiBXException, InstantiationException, IllegalAccessException {
|
|
154 | 154 |
|
155 | 155 |
// Read the incoming data from its Mime Multipart encoding |
156 | 156 |
logMetacat.debug("Disassembling MIME multipart form"); |
... | ... | |
221 | 221 |
sysmeta = new FileInputStream(smFile); |
222 | 222 |
|
223 | 223 |
logMetacat.debug("Commence creation..."); |
224 |
SystemMetadata systemMetadata = (SystemMetadata) deserializeServiceType(SystemMetadata.class, sysmeta);
|
|
224 |
SystemMetadata systemMetadata = TypeMarshaller.unmarshalTypeFromStream(SystemMetadata.class, sysmeta);
|
|
225 | 225 |
return systemMetadata; |
226 | 226 |
} |
227 | 227 |
|
... | ... | |
335 | 335 |
} |
336 | 336 |
} |
337 | 337 |
|
338 |
/** |
|
339 |
* serialize an object of type to out |
|
340 |
* @param type the class of the object to serialize (i.e. SystemMetadata.class) |
|
341 |
* @param object the object to serialize |
|
342 |
* @param out the stream to serialize it to |
|
343 |
* @throws JiBXException |
|
344 |
*/ |
|
345 |
protected void serializeServiceType(Class type, Object object, OutputStream out) |
|
346 |
throws JiBXException { |
|
347 |
ServiceTypeUtil.serializeServiceType(type, object, out); |
|
348 |
} |
|
349 |
|
|
350 |
/** |
|
351 |
* deserialize an object of type from is |
|
352 |
* @param type the class of the object to serialize (i.e. SystemMetadata.class) |
|
353 |
* @param is the stream to deserialize from |
|
354 |
* @throws JiBXException |
|
355 |
*/ |
|
356 |
protected Object deserializeServiceType(Class type, InputStream is) |
|
357 |
throws JiBXException { |
|
358 |
return ServiceTypeUtil.deserializeServiceType(type, is); |
|
359 |
} |
|
360 | 338 |
|
361 | 339 |
/** |
362 | 340 |
* locate the boundary marker for an MMP |
src/edu/ucsb/nceas/metacat/MetacatHandler.java | ||
---|---|---|
84 | 84 |
import org.dataone.service.types.v1.Subject; |
85 | 85 |
import org.dataone.service.types.v1.SystemMetadata; |
86 | 86 |
import org.dataone.service.types.v1.util.ChecksumUtil; |
87 |
import org.dataone.service.types.util.ServiceTypeUtil; |
|
88 | 87 |
import org.ecoinformatics.datamanager.DataManager; |
89 | 88 |
import org.ecoinformatics.datamanager.database.DatabaseConnectionPoolInterface; |
90 | 89 |
import org.ecoinformatics.datamanager.parser.DataPackage; |
91 |
import org.ecoinformatics.datamanager.parser.TextComplexDataFormat; |
|
92 | 90 |
import org.ecoinformatics.eml.EMLParser; |
93 | 91 |
import org.jibx.runtime.JiBXException; |
94 | 92 |
import org.xml.sax.SAXException; |
src/edu/ucsb/nceas/metacat/dataone/MNodeService.java | ||
---|---|---|
81 | 81 |
import org.dataone.service.types.v1.Synchronization; |
82 | 82 |
import org.dataone.service.types.v1.SystemMetadata; |
83 | 83 |
import org.dataone.service.types.v1.util.ChecksumUtil; |
84 |
import org.dataone.service.types.util.ServiceTypeUtil; |
|
85 | 84 |
|
86 | 85 |
import edu.ucsb.nceas.metacat.DocumentImpl; |
87 | 86 |
import edu.ucsb.nceas.metacat.EventLog; |
src/edu/ucsb/nceas/metacat/replication/ReplicationHandler.java | ||
---|---|---|
55 | 55 |
|
56 | 56 |
import org.apache.log4j.Logger; |
57 | 57 |
import org.dataone.service.types.v1.SystemMetadata; |
58 |
import org.dataone.service.types.util.ServiceTypeUtil;
|
|
58 |
import org.dataone.service.util.TypeMarshaller;
|
|
59 | 59 |
import org.xml.sax.ContentHandler; |
60 | 60 |
import org.xml.sax.ErrorHandler; |
61 | 61 |
import org.xml.sax.InputSource; |
... | ... | |
442 | 442 |
// process system metadata |
443 | 443 |
if (systemMetadataXML != null) { |
444 | 444 |
SystemMetadata sysMeta = |
445 |
(SystemMetadata) ServiceTypeUtil.deserializeServiceType(
|
|
445 |
TypeMarshaller.unmarshalTypeFromStream(
|
|
446 | 446 |
SystemMetadata.class, |
447 | 447 |
new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8"))); |
448 | 448 |
String guid = sysMeta.getIdentifier().getValue(); |
... | ... | |
601 | 601 |
// process system metadata |
602 | 602 |
if (systemMetadataXML != null) { |
603 | 603 |
SystemMetadata sysMeta = |
604 |
(SystemMetadata) ServiceTypeUtil.deserializeServiceType(
|
|
604 |
TypeMarshaller.unmarshalTypeFromStream(
|
|
605 | 605 |
SystemMetadata.class, |
606 | 606 |
new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8"))); |
607 | 607 |
String guid = sysMeta.getIdentifier().getValue(); |
... | ... | |
837 | 837 |
|
838 | 838 |
// process system metadata |
839 | 839 |
if (systemMetadataXML != null) { |
840 |
SystemMetadata sysMeta = (SystemMetadata) ServiceTypeUtil |
|
841 |
.deserializeServiceType(SystemMetadata.class, |
|
840 |
SystemMetadata sysMeta = TypeMarshaller.unmarshalTypeFromStream(SystemMetadata.class, |
|
842 | 841 |
new ByteArrayInputStream(systemMetadataXML |
843 | 842 |
.getBytes("UTF-8"))); |
844 | 843 |
// String guid = sysMeta.getIdentifier().getValue(); |
src/edu/ucsb/nceas/metacat/replication/ReplicationService.java | ||
---|---|---|
58 | 58 |
|
59 | 59 |
import org.apache.log4j.Logger; |
60 | 60 |
import org.dataone.service.types.v1.SystemMetadata; |
61 |
import org.dataone.service.types.util.ServiceTypeUtil;
|
|
61 |
import org.dataone.service.util.TypeMarshaller;
|
|
62 | 62 |
import org.xml.sax.InputSource; |
63 | 63 |
import org.xml.sax.SAXException; |
64 | 64 |
import org.xml.sax.XMLReader; |
... | ... | |
586 | 586 |
// process system metadata |
587 | 587 |
if (systemMetadataXML != null) { |
588 | 588 |
SystemMetadata sysMeta = |
589 |
(SystemMetadata) ServiceTypeUtil.deserializeServiceType(
|
|
589 |
TypeMarshaller.unmarshalTypeFromStream(
|
|
590 | 590 |
SystemMetadata.class, |
591 | 591 |
new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8"))); |
592 | 592 |
String guid = sysMeta.getIdentifier().getValue(); |
... | ... | |
867 | 867 |
// process system metadata |
868 | 868 |
if (systemMetadataXML != null) { |
869 | 869 |
SystemMetadata sysMeta = |
870 |
(SystemMetadata) ServiceTypeUtil.deserializeServiceType(
|
|
870 |
TypeMarshaller.unmarshalTypeFromStream(
|
|
871 | 871 |
SystemMetadata.class, |
872 | 872 |
new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8"))); |
873 | 873 |
String guid = sysMeta.getIdentifier().getValue(); |
... | ... | |
977 | 977 |
String guid = IdentifierManager.getInstance().getGUID(doc.getDocID(), doc.getRev()); |
978 | 978 |
SystemMetadata systemMetadata = IdentifierManager.getInstance().getSystemMetadata(guid); |
979 | 979 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
980 |
ServiceTypeUtil.serializeServiceType(SystemMetadata.class, systemMetadata, baos);
|
|
980 |
TypeMarshaller.marshalTypeToOutputStream(systemMetadata, baos);
|
|
981 | 981 |
String systemMetadataXML = baos.toString("UTF-8"); |
982 | 982 |
sb.append("<systemMetadata>"); |
983 | 983 |
sb.append(systemMetadataXML); |
... | ... | |
1038 | 1038 |
// serialize the System Metadata as XML |
1039 | 1039 |
SystemMetadata systemMetadata = IdentifierManager.getInstance().getSystemMetadata(guid); |
1040 | 1040 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
1041 |
ServiceTypeUtil.serializeServiceType(SystemMetadata.class, systemMetadata, baos);
|
|
1041 |
TypeMarshaller.marshalTypeToOutputStream(systemMetadata, baos);
|
|
1042 | 1042 |
systemMetadataXML = baos.toString("UTF-8"); |
1043 | 1043 |
|
1044 | 1044 |
// get a writer for sending back to response |
... | ... | |
1078 | 1078 |
// process system metadata |
1079 | 1079 |
if (systemMetadataXML != null) { |
1080 | 1080 |
SystemMetadata sysMeta = |
1081 |
(SystemMetadata) ServiceTypeUtil.deserializeServiceType(
|
|
1081 |
TypeMarshaller.unmarshalTypeFromStream(
|
|
1082 | 1082 |
SystemMetadata.class, |
1083 | 1083 |
new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8"))); |
1084 | 1084 |
if (!IdentifierManager.getInstance().identifierExists(guid)) { |
Also available in: Unified diff
remove ServiceTypeUtil - replace with TypeMarshaller