Changeset 7505


Ignore:
Timestamp:
22/09/10 12:50:06 (9 years ago)
Author:
mnagni
Message:

Removed the JAXB deprecated class (from ndg.common)
Added some copyright disclaimers
Added some SuppressWarning?("uncheked")

Location:
RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/EJBBeanFactory.java

    r7389 r7505  
    5757        } 
    5858 
     59        @SuppressWarnings("unchecked") 
    5960        private synchronized static <T> T getEJBInstance(String ejbName, Class<T> remoteEJBclass) 
    6061                        throws NdgExecutionException { 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/HiProcessModel.java

    r7465 r7505  
     1/* 
     2 * BSD Licence 
     3 * Copyright (c) 2009, Science & Technology Facilities Council (STFC) 
     4 * All rights reserved. 
     5 
     6 * See the LICENSE file in the source distribution of this software for 
     7 * the full license text.        
     8 * Copyright (C) 2007 STFC & NERC (Science and Technology Facilities Council). 
     9 * This software may be distributed under the terms of the 
     10 * Q Public License, version 1.0 or later. 
     11 * http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt 
     12 */ 
    113package ndg.services.revitalization.ejb; 
    214 
     
    6476        } 
    6577 
     78        @SuppressWarnings("unchecked") 
    6679        public List<HiProcess> getHiProcess(List<Integer> processIDs) { 
    6780                Query query = em.createQuery(GET_HI_PROCESS); 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/JMSConsumer.java

    r7389 r7505  
    4646        private AsyncProcessManagerLocal executor; 
    4747 
     48        @SuppressWarnings("unchecked") 
    4849        public void onMessage(Message message) { 
    4950                try { 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/ModelManager.java

    r7469 r7505  
     1/* 
     2 * BSD Licence 
     3 * Copyright (c) 2009, Science & Technology Facilities Council (STFC) 
     4 * All rights reserved. 
     5 
     6 * See the LICENSE file in the source distribution of this software for 
     7 * the full license text.        
     8 * Copyright (C) 2007 STFC & NERC (Science and Technology Facilities Council). 
     9 * This software may be distributed under the terms of the 
     10 * Q Public License, version 1.0 or later. 
     11 * http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt 
     12 */ 
    113package ndg.services.revitalization.ejb; 
    214 
     
    2436import ndg.services.revitalization.jpa.HiProcess; 
    2537import ndg.services.revitalization.jpa.IngestSearchLogging; 
    26 import ndg.services.revitalization.jpa.OaiProvider; 
    2738import ndg.services.revitalization.jpa.ProviderCommon; 
    2839import ndg.services.revitalization.jpa.ProviderEmail; 
     
    6172        private SessionContext sessionContext; 
    6273        */ 
    63  
     74        @SuppressWarnings("unchecked") 
    6475        public List<String> getServiceParameterNames() { 
    6576                        Query query = em.createQuery(GET_SERVICE_PARAMETER_NAMES); 
     
    6778        } 
    6879 
     80        @SuppressWarnings("unchecked") 
    6981        public List<String> getServiceParameterNamesValues(String parName) { 
    7082                        Query query = em.createQuery(GET_SERVICE_PARAMETER_VALUES); 
     
    96108         * @return a <code>List</code> of {@link HarvestLog} 
    97109         * */ 
     110        @SuppressWarnings("unchecked") 
    98111        public <T> List<ProviderLogs<T>> getHistoryByProvider(Timestamp start, Timestamp end, int providerId, Class<T> clazz) { 
    99112                Query query = null; 
     
    149162        } 
    150163 
     164        @SuppressWarnings("unchecked") 
    151165        public List<IngestSearchLogging> getIngestLogs(List<Integer> processIds) { 
    152166                        Query query = em.createQuery(GET_INGESTER_HISTORY); 
     
    155169        } 
    156170 
     171        @SuppressWarnings("unchecked") 
    157172        public List<HarvestLog> getHarvestLog(List<Integer> processIds) { 
    158173                        Query query = em.createQuery(GET_HARVEST_HISTORY); 
     
    214229        } 
    215230 
     231        @SuppressWarnings("unchecked") 
    216232        public ProviderCommon getProviderCommon(int commonId) { 
    217233                        Query query = em.createQuery(GET_PROVIDER_COMMON_BY_ID); 
     
    224240        } 
    225241 
     242        @SuppressWarnings("unchecked") 
    226243        public String getConfigurationParameter(ServiceConfigurationParameter param) { 
    227244                        Query query = em.createQuery(GET_CONFIGURATION_PARAMETER); 
     
    241258         * @return an Harvester instance, otherwise <code>null</code> 
    242259         * */ 
     260        @SuppressWarnings("unchecked") 
    243261        public ProviderCommon getHarvesterConfiguration(int commonID) { 
    244262                        ProviderCommon ret = null; 
     
    249267        } 
    250268 
     269        @SuppressWarnings("unchecked") 
    251270        @Override 
    252271        public List<? extends ProviderCommon> getHarvesterConfiguration(List<Integer> commonIDs) { 
     
    265284        } 
    266285 
     286        @SuppressWarnings("unchecked") 
    267287        private <T extends ProviderCommon> T getProvider(int id, String queryText) { 
    268288                        Query query = em.createQuery(queryText); 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/executor/ExecuteDoNewProvider.java

    r7389 r7505  
     1/* 
     2 * BSD Licence 
     3 * Copyright (c) 2009, Science & Technology Facilities Council (STFC) 
     4 * All rights reserved. 
     5 
     6 * See the LICENSE file in the source distribution of this software for 
     7 * the full license text.        
     8 * Copyright (C) 2007 STFC & NERC (Science and Technology Facilities Council). 
     9 * This software may be distributed under the terms of the 
     10 * Q Public License, version 1.0 or later. 
     11 * http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt 
     12 */ 
    113package ndg.services.revitalization.executor; 
    214 
     
    98110        } 
    99111         
     112        @SuppressWarnings("unchecked") 
    100113        private void prepareResponse(ProviderCommon ret) throws NdgExecutionException{ 
    101114                ProviderDetail pd = getOf().createProviderDetail(); 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/executor/ExecuteGetIngestHistory.java

    r7393 r7505  
    2828 
    2929        @Override 
    30         protected void execute(GetHistoryRequest request) throws NdgExecutionException { 
     30        protected void execute(GetHistoryRequest request) throws NdgExecutionException {  
    3131                DataRangeType dateRange = request.getDateRange(); 
    3232                Timestamp end = new Timestamp(Calendar.getInstance().getTimeInMillis()); 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/executor/ProviderLogs.java

    r7393 r7505  
     1/* 
     2 * BSD Licence 
     3 * Copyright (c) 2009, Science & Technology Facilities Council (STFC) 
     4 * All rights reserved. 
     5 
     6 * See the LICENSE file in the source distribution of this software for 
     7 * the full license text.        
     8 * Copyright (C) 2007 STFC & NERC (Science and Technology Facilities Council). 
     9 * This software may be distributed under the terms of the 
     10 * Q Public License, version 1.0 or later. 
     11 * http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt 
     12 */ 
    113package ndg.services.revitalization.executor; 
    214 
     
    3446        } 
    3547 
     48        @SuppressWarnings("unchecked") 
    3649        @Override 
    3750        public boolean equals(Object obj) { 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/executor/ServiceExecutor.java

    r7360 r7505  
    4747                response = getResponse(); 
    4848                try { 
     49                        if (request == null) 
     50                                throw new NdgExecutionException("The request is not valid"); 
    4951                        execute(request); 
    5052                        manageSuccess(getResponse().getConfirmation()); 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/harvest/ProviderAdapter.java

    r7389 r7505  
    4545        } 
    4646 
     47        @SuppressWarnings("unchecked") 
    4748        public JAXBElement<? extends ProviderDetailsType> extractDetails(ProviderCommon provider, ObjectFactory of) 
    4849                        throws NdgExecutionException { 
     
    5051        } 
    5152 
     53        @SuppressWarnings("unchecked") 
    5254        public Harvester<T> getHarvester(HarvestRequest request) throws NdgExecutionException { 
    5355                ModelManagerRemote mm = EJBBeanFactory.getModelManager(); 
     
    6870 
    6971                ModelManagerRemote mm = EJBBeanFactory.getModelManager(); 
     72                @SuppressWarnings("unused") 
    7073                ProviderCommon provider = mm.getHarvesterConfiguration(doRequest.getProviderID()); 
    7174                return new HarvestRequest(hiProcess, doRequest.getEmailReportID()); 
     
    8083         * @return the internal representation of the given data 
    8184         **/ 
     85        @SuppressWarnings("unchecked") 
    8286        public ProviderCommon getProvider(ProviderDetail pdetails) throws NdgExecutionException { 
    8387                ProviderCommon ret = getHelper(pdetails.getProviderType().getValue().getClass()).assembleProvider( 
     
    8892        } 
    8993 
     94        @SuppressWarnings("unchecked") 
    9095        private ProviderAdapterHelper getHelper(Class<?> clazz) throws NdgExecutionException { 
    9196                return ProviderAdapterFactory.getProviderAdapterHelper(clazz); 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/harvest/ProviderAdapterFactory.java

    r7389 r7505  
    1919public class ProviderAdapterFactory { 
    2020 
     21        @SuppressWarnings("unchecked") 
    2122        public static ProviderAdapterHelper  
    2223                        getProviderAdapterHelper(Class<?> clazz) throws NdgExecutionException { 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/harvest/csw/CSWHarvester.java

    r7465 r7505  
    1616import java.io.IOException; 
    1717import java.io.InputStream; 
    18 import java.io.OutputStream; 
    19 import java.io.OutputStreamWriter; 
    2018import java.net.HttpURLConnection; 
    2119import java.net.MalformedURLException; 
    2220import java.net.URL; 
     21import java.util.HashSet; 
    2322import java.util.Iterator; 
    2423 
    25 import javax.xml.bind.JAXBElement; 
     24import javax.xml.bind.JAXBException; 
    2625import javax.xml.transform.OutputKeys; 
    2726import javax.xml.transform.Result; 
     
    3534import ndg.common.exception.NdgException; 
    3635import ndg.common.exception.NdgExecutionException; 
    37 import ndg.common.jaxb.JaxbService; 
    38 import ndg.common.jaxb.MarshallerHelper; 
     36import ndg.common.exception.ResourceNotAvailable; 
     37import ndg.common.jaxb.JAXBManager; 
    3938import ndg.services.revitalization.harvest.HarvesterBase; 
    4039import ndg.services.revitalization.jpa.HiProcess; 
     
    5655public class CSWHarvester extends HarvesterBase<CSWHarvestRequest> { 
    5756 
    58          private final JaxbService jaxbService = new JaxbService("net.opengis.gml:net.opengis.csw:net.opengis.ogc", new CSWMarshallerHelper()); 
    59          
     57         //private final JaxbService jaxbService = new JaxbService("net.opengis.gml:net.opengis.csw:net.opengis.ogc", new CSWMarshallerHelper()); 
     58         private JAXBManager manager = null; 
    6059        /** 
    6160         *  
     
    6766        } 
    6867         
     68        private void init() throws NdgExecutionException { 
     69                HashSet<String> factories = new HashSet<String>(); 
     70                factories.add("net.opengis"); 
     71                try { 
     72                        this.manager = new JAXBManager(null, factories); 
     73                } catch (ResourceNotAvailable e) { 
     74                        throw new NdgExecutionException(e.getMessage(), e); 
     75                } catch (JAXBException e) { 
     76                        throw new NdgExecutionException(e.getMessage(), e); 
     77                } 
     78        } 
     79         
    6980        @Override 
    70         protected void doHarvest() throws NdgExecutionException {        
     81        protected void doHarvest() throws NdgExecutionException { 
     82                if (this.manager == null) 
     83                        init(); 
     84                 
    7185                try { 
    72                         String request = jaxbService.executeMarshaller(doGetRecordsType()); 
    7386                        URL url = new URL(getHarvestRequest().getUrl()); 
    7487                        HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 
     
    8194                        conn.setRequestProperty("Content-Type", "text/xml"); 
    8295                        ((HttpURLConnection) conn).setRequestMethod("POST"); 
    83                         conn.setRequestProperty("Content-Length", Integer.toString(request.length())); 
    84                         OutputStream os = conn.getOutputStream(); 
    85                         OutputStreamWriter wr = new OutputStreamWriter(os); 
    86                         wr.write(request); 
     96                        //conn.setRequestProperty("Content-Length", Integer.toString(request.length())); 
     97                        //OutputStream os = ; 
     98                        this.manager.marshall(doGetRecordsType(), conn.getOutputStream()); 
     99                        //OutputStreamWriter wr = new OutputStreamWriter(os); 
     100                        //wr.write(request); 
    87101                        // Send data 
    88                         wr.flush(); 
    89                         wr.close(); 
     102                        //wr.flush(); 
     103                        //wr.close(); 
    90104                        // Read response data 
    91105                        extractRecords(conn.getInputStream()); 
     
    95109                        throw new NdgExecutionException(e.getMessage(), e); 
    96110                } catch (NdgException e) { 
     111                        throw new NdgExecutionException(e.getMessage(), e); 
     112                } catch (JAXBException e) { 
    97113                        throw new NdgExecutionException(e.getMessage(), e); 
    98114                }  
     
    117133         
    118134        private void extractRecords(InputStream is) throws NdgException { 
    119                 GetRecordsResponseType response = jaxbService.executeUnmarshaller(is, GetRecordsResponseType.class); 
     135                GetRecordsResponseType response; 
     136                try { 
     137                        response = this.manager.unmarshall(is, GetRecordsResponseType.class); 
     138                } catch (JAXBException e) { 
     139                        throw new NdgExecutionException(e.getMessage(), e); 
     140                } 
    120141                 
    121142                Iterator<Object> iter = response.getSearchResults().getAny().iterator(); 
     
    155176                return new StreamResult(file); 
    156177        } 
    157          
    158         private class CSWMarshallerHelper implements MarshallerHelper { 
    159                 /** 
    160                  *  
    161                  */ 
    162                 private static final long serialVersionUID = -2974710194689581066L; 
    163                 private final ObjectFactory cswOF = new ObjectFactory(); 
    164  
    165                 public <T> JAXBElement<?> marshallerHelper(T res) { 
    166                         if (res.getClass().isAssignableFrom(net.opengis.csw._202.GetCapabilitiesType.class)) 
    167                                 return cswOF.createGetCapabilities((net.opengis.csw._202.GetCapabilitiesType) res); 
    168                         if (res.getClass().isAssignableFrom(net.opengis.csw._202.CapabilitiesType.class)) 
    169                                 return cswOF.createCapabilities((net.opengis.csw._202.CapabilitiesType) res); 
    170                         if (res.getClass().isAssignableFrom(net.opengis.csw._202.GetRecordsType.class)) 
    171                                 return cswOF.createGetRecords((net.opengis.csw._202.GetRecordsType) res); 
    172                         if (res.getClass().isAssignableFrom(net.opengis.csw._202.GetRecordsResponseType.class)) 
    173                                 return cswOF.createGetRecordsResponse((net.opengis.csw._202.GetRecordsResponseType) res); 
    174                         return null; 
    175                 } 
    176         } 
    177178} 
Note: See TracChangeset for help on using the changeset viewer.