Project

General

Profile

« Previous | Next » 

Revision 6367

remove ServiceTypeUtil - replace with TypeMarshaller

View differences:

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
}

Also available in: Unified diff