Project

General

Profile

« Previous | Next » 

Revision 6367

remove ServiceTypeUtil - replace with TypeMarshaller

View differences:

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
    }

Also available in: Unified diff