Project

General

Profile

« Previous | Next » 

Revision 6367

remove ServiceTypeUtil - replace with TypeMarshaller

View differences:

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
        

Also available in: Unified diff