Project

General

Profile

« Previous | Next » 

Revision 51831

Bug fixes

View differences:

modules/uoa-repository-manager-service/branches/dev-api/src/main/java/eu/dnetlib/repo/manager/service/config/FrontEndLinkURIAuthenticationSuccessHandler.java
19 19
    private static final Logger LOGGER = Logger
20 20
            .getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
21 21

  
22
    @PostConstruct
23 22
    public void init(){
24
        LOGGER.debug(frontEndURI);
23
        LOGGER.debug("Front end uri : " + frontEndURI);
25 24
    }
26 25

  
27 26
    @Override
modules/uoa-repository-manager-service/branches/dev-api/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApiImpl.java
57 57

  
58 58
    private HashMap<String,Term> topics = new HashMap<String, Term>();
59 59

  
60
    @Autowired
61
    private EmailUtils emailUtils;
62

  
60 63
    @PostConstruct
61 64
    private void initDnetTopicsMap() {
62 65

  
......
75 78
            for (JsonNode term : root.path("terms") )
76 79
                topics.put(term.path("code").textValue(), parseTerm(term));
77 80
        } catch (IOException e) {
78
            LOGGER.debug(e);
79
            e.printStackTrace();
81
            LOGGER.debug("Exception on initDnetTopicsMap" , e);
82
            emailUtils.reportException(e);
80 83
        }
81 84
    }
82 85

  
......
108 111
                ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
109 112
            }
110 113
        } catch (BrokerException e) {
111
            e.printStackTrace();
114
            LOGGER.debug("Exception on getDatasourcesOfUser" , e);
115
            emailUtils.reportException(e);
112 116
        }
113 117

  
114 118
        return ret;
......
130 134
                    new ParameterizedTypeReference<List<BrowseEntry>>() {
131 135
                    });
132 136
        } catch (RestClientException e) {
137
            LOGGER.debug("Exception on getTopicsForDatasource" , e);
138
            emailUtils.reportException(e);
133 139
            throw new BrokerException(e);
134 140
        }
135 141

  
......
163 169
                    }
164 170
            );
165 171
        } catch (RestClientException e) {
172
            LOGGER.debug("Exception on advancedShowEvents" , e);
173
            emailUtils.reportException(e);
166 174
            throw new BrokerException(e);
167 175
        }
168 176
        return resp.getBody();
......
241 249
                    new ParameterizedTypeReference<EventsPage>() {
242 250
                    });
243 251
        } catch (RestClientException e) {
252
            LOGGER.debug("Exception on showEvents" , e);
253
            emailUtils.reportException(e);
244 254
            throw new BrokerException(e);
245 255
        }
246 256
        return resp.getBody();
......
266 276
                    new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() {
267 277
                    });
268 278
        } catch (RestClientException e) {
269
            LOGGER.debug("Error " , e);
279
            LOGGER.debug("Exception on getSimpleSubscriptionsOfUser" , e);
280
            emailUtils.reportException(e);
270 281
            throw new BrokerException(e);
271 282
        }
272 283
        return resp.getBody();
......
295 306
                    new ParameterizedTypeReference<Subscription>() {
296 307
                    });
297 308
        } catch (RestClientException e) {
309
            LOGGER.debug("Exception on OpenaireSubscription" , e);
310
            emailUtils.reportException(e);
298 311
            throw new BrokerException(e);
299 312
        }
300 313

  
......
318 331
                    new ParameterizedTypeReference<Void>() {
319 332
                    });
320 333
        } catch (RestClientException e) {
334
            LOGGER.debug("Exception on unsubscribe" , e);
335
            emailUtils.reportException(e);
321 336
            throw new BrokerException(e);
322 337
        }
323 338
    }
......
340 355
                    new ParameterizedTypeReference<Subscription>() {
341 356
                    });
342 357
        } catch (RestClientException e) {
358
            LOGGER.debug("Exception on getSubscription" , e);
359
            emailUtils.reportException(e);
343 360
            throw new BrokerException(e);
344 361
        }
345 362
        return resp.getBody();
......
371 388
                    new ParameterizedTypeReference<EventsPage>() {
372 389
                    });
373 390
        } catch (RestClientException e) {
391
            LOGGER.debug("Exception on getNotificationsBySubscriptionId" , e);
392
            emailUtils.reportException(e);
374 393
            throw new BrokerException(e);
375 394
        }
376 395
        return resp.getBody();
modules/uoa-repository-manager-service/branches/dev-api/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApiImpl.java
53 53
    private static final Logger LOGGER = Logger
54 54
            .getLogger(ValidatorApiImpl.class);
55 55

  
56
    @Autowired
57
    private EmailUtils emailUtils;
58

  
56 59
    @PostConstruct
57 60
    private void loadRules(){
58 61
        LOGGER.debug("PostConstruct method! Load rules!");
......
89 92
        try {
90 93
            this.getValidationService().submitValidationJob(jobForValidation);
91 94
        } catch (ValidatorServiceException e) {
92
            e.printStackTrace();
95
            LOGGER.debug("Exception on submitJobForValidation" , e);
96
            emailUtils.reportException(e);
93 97
        }
94 98
    }
95 99

  
......
135 139
        try {
136 140
            return OaiTools.getSetsOfRepo(url);
137 141
        } catch (Exception e) {
138
            e.printStackTrace();
142
            LOGGER.debug("Exception on getSetsOfRepository" , e);
143
            emailUtils.reportException(e);
139 144
        }
140 145
        return null;
141 146
    }
......
147 152
            return OaiTools.identifyRepository(url);
148 153
        } catch (Exception e) {
149 154
            LOGGER.error("Error while identifying repository with url: " + url, e);
155
            emailUtils.reportException(e);
150 156
            return false;
151 157
        }
152 158
    }
......
166 172
            return ruleSet;
167 173
        } catch (Exception e) {
168 174
            LOGGER.error("Error getting ruleset", e);
175
            emailUtils.reportException(e);
169 176
            return null;
170 177
        }
171 178
    }
......
201 208
            return interfaceInformation;
202 209
        } catch (Exception e) {
203 210
            LOGGER.error("Error getting interface information with url: " + baseUrl, e);
204
//            emailUtils.reportException(e);
211
            emailUtils.reportException(e);
205 212
            throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR);
206 213
        }
207 214
    }
modules/uoa-repository-manager-service/branches/dev-api/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApiImpl.java
62 62
    @Autowired
63 63
    private PiWikApi piWikApi;
64 64

  
65
    @Autowired
66
    private EmailUtils emailUtils;
67

  
65 68
    private Map<String, Vocabulary> vocabularyMap = new ConcurrentHashMap<String, Vocabulary>();
66 69

  
67 70
    private Map<String, String> countriesMap = new HashMap<>();
......
160 163
        RequestFilter requestFilter = new RequestFilter();
161 164
        requestFilter.setCountry(countryCode);
162 165

  
163
        String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
164
        JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
165
        while (jsonArray.length() > 0 ) {
166
            resultSet.addAll(this.getRepositoriesByMode(filterKey, Converter.jsonToRepositoryList(new JSONObject(rs))));
167
            page += 1;
168
            uriComponents = searchDatasource(String.valueOf(page),String.valueOf(size));
169
            rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
170
            jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
166
        try{
167
            String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
168
            JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
169
            while (jsonArray.length() > 0 ) {
170
                resultSet.addAll(this.getRepositoriesByMode(filterKey, Converter.jsonToRepositoryList(new JSONObject(rs))));
171
                page += 1;
172
                uriComponents = searchDatasource(String.valueOf(page),String.valueOf(size));
173
                rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
174
                jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
175
            }
176
            for (Repository r : resultSet)
177
                this.getRepositoryInfo(r);
178

  
179
            return resultSet;
180
        }catch (Exception e){
181
            LOGGER.debug("Exception on getRepositoriesByCountry" , e);
182
            emailUtils.reportException(e);
183
            throw e;
171 184
        }
172
        for (Repository r : resultSet)
173
            this.getRepositoryInfo(r);
174 185

  
175
        return resultSet;
186

  
176 187
    }
177 188

  
178 189
    private void getRepositoryInfo(Repository r) throws JSONException {
......
209 220
        UriComponents uriComponents = searchDatasource(page,size);
210 221
        RequestFilter requestFilter = new RequestFilter();
211 222
        requestFilter.setRegisteredby(userEmail);
212
        String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
213 223

  
214
        List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
215
        for (Repository r : repos)
216
            this.getRepositoryInfo(r);
224
        try{
225
            String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
217 226

  
218
        return repos;
227
            List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
228
            for (Repository r : repos)
229
                this.getRepositoryInfo(r);
230

  
231
            return repos;
232
        }catch (Exception e){
233
            LOGGER.debug("Exception on getRepositoriesOfUser" , e);
234
            emailUtils.reportException(e);
235
            throw e;
236
        }
219 237
    }
220 238

  
221 239
    @Override
......
226 244
        UriComponents uriComponents = searchDatasource("0","100");
227 245
        RequestFilter requestFilter = new RequestFilter();
228 246
        requestFilter.setId(id);
229
        String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
230
        JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
231
        if(jsonArray.length() > 0)
232
            repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0));
233
        if (repo != null)
234
            getRepositoryInfo(repo);
235
        return repo;
247

  
248
        try{
249
            String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
250
            JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
251
            if(jsonArray.length() > 0)
252
                repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0));
253
            if (repo != null)
254
                getRepositoryInfo(repo);
255
            return repo;
256
        }catch (Exception e){
257
            LOGGER.debug("Exception on getRepositoryById" , e);
258
            emailUtils.reportException(e);
259
            throw e;
260
        }
261

  
236 262
    }
237 263

  
238 264

  
......
243 269
        UriComponents uriComponents = searchDatasource("0","100");
244 270
        RequestFilter requestFilter = new RequestFilter();
245 271
        requestFilter.setId(id);
246
        String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
247
        JSONObject repository = new JSONObject(rs);
248

  
249 272
        Aggregations aggregations = new Aggregations();
250 273

  
251 274
        try {
252
            LOGGER.debug(repository.getJSONArray("datasourceInfo").getJSONObject(0));
275
            String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
276
            JSONObject repository = new JSONObject(rs);
277

  
253 278
            aggregations.setAggregationHistory(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
254 279
            aggregations.setLastCollection(Converter.getLastCollectionFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
255 280
            aggregations.setLastTransformation(Converter.getLastTransformationFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
256 281
            return aggregations;
257 282
        } catch (JSONException e) {
258
            LOGGER.debug("JSON aggregation exception ", e);
283
            LOGGER.debug("Exception on getRepositoryAggregations" , e);
284
            emailUtils.reportException(e);
259 285
            throw e;
260 286
        }
261 287

  
......
270 296
        UriComponents uriComponents = searchDatasource("0","100");
271 297
        RequestFilter requestFilter = new RequestFilter();
272 298
        requestFilter.setOfficialname(name);
273
        String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
274 299

  
275
        List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
276
        for (Repository r : repos)
277
            getRepositoryInfo(r);
278
        return repos;
300
        try{
301
            String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
302
            List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
303
            for (Repository r : repos)
304
                getRepositoryInfo(r);
305
            return repos;
306
        }catch (Exception e){
307
            LOGGER.debug("Exception on getRepositoriesByName" , e);
308
            emailUtils.reportException(e);
309
            throw e;
310
        }
311

  
279 312
    }
280 313

  
281 314
    @Override
......
286 319
                .path("/{id}")
287 320
                .build().expand(id).encode();
288 321

  
289
        String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
290
        return Converter.jsonToRepositoryInterfaceList(new JSONObject(rs));
322
        try{
323
            String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
324
            return Converter.jsonToRepositoryInterfaceList(new JSONObject(rs));
325
        }catch (Exception e ){
326
            LOGGER.debug("Exception on getRepositoryInterface" , e);
327
            emailUtils.reportException(e);
328
            throw e;
329
        }
330

  
291 331
    }
292 332

  
293 333
    @Override
......
308 348
                .fromHttpUrl(baseAddress + "/ds/update/")
309 349
                .build()
310 350
                .encode();
311
        String json_repository = Converter.repositoryObjectToJson(repository);
312 351

  
313
        LOGGER.debug(json_repository);
352
        try {
353
            String json_repository = Converter.repositoryObjectToJson(repository);
354
            HttpEntity<String> httpEntity = new HttpEntity <String> (json_repository,httpHeaders);
355
            restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
356
            return repository;
357
        }catch (Exception e){
358
            LOGGER.debug("Exception on updateRepository" , e);
359
            emailUtils.reportException(e);
360
            throw e;
361
        }
314 362

  
315
        HttpEntity<String> httpEntity = new HttpEntity <String> (json_repository,httpHeaders);
316
        restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
317
        return repository;
318 363
    }
319 364

  
320 365
    private Repository setRepositoryFeatures(String datatype, Repository repository) {
......
416 461
            restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
417 462
            return repositoryInterface;
418 463

  
419
        } catch (JSONException e1) {
420
            LOGGER.debug("Error parsing json ",e1);
464
        } catch (JSONException e) {
465
            LOGGER.debug("Exception on addRepositoryInterface" , e);
466
            emailUtils.reportException(e);
467
            throw e;
421 468
        }
422
        return null;
423 469
    }
424 470

  
425 471
    private RepositoryInterface createRepositoryInterface(Repository repo, RepositoryInterface iFace, String datatype) {
......
482 528
                .path("/{page}/{size}")
483 529
                .build().expand(page,size).encode();
484 530

  
485

  
486
        RequestFilter requestFilter = new RequestFilter();
487
        requestFilter.setRegisteredby(userEmail);
488
        return Arrays.asList(restTemplate.postForObject(uriComponents.toUri(),requestFilter, String[].class));
531
        try{
532
            RequestFilter requestFilter = new RequestFilter();
533
            requestFilter.setRegisteredby(userEmail);
534
            return Arrays.asList(restTemplate.postForObject(uriComponents.toUri(),requestFilter, String[].class));
535
        }catch (Exception e){
536
            LOGGER.debug("Exception on addRepositoryInterface" , e);
537
            emailUtils.reportException(e);
538
            throw e;
539
        }
489 540
    }
490 541

  
491 542
    @Override
......
602 653

  
603 654
        } catch (Exception e) {
604 655
            LOGGER.error("Error while getting metrics info for repository: ", e);
605
            //emailUtils.reportException(e);
656
            emailUtils.reportException(e);
606 657
            throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
607 658
        }
608 659
    }
......
678 729
                    new ParameterizedTypeReference<MetricsNumbers>() {
679 730
                    });
680 731
        } catch (RestClientException e) {
732
            LOGGER.debug("Exception on getMetricsNumbers" , e);
733
            emailUtils.reportException(e);
681 734
            throw e;
682 735
        }
683 736

  
modules/uoa-repository-manager-service/branches/dev-api/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApi.java
18 18
@Api(description = "Broker API",  tags = {"broker"})
19 19
public interface BrokerApi {
20 20

  
21
    @RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.POST,
21
    @RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.GET,
22 22
            produces = MediaType.APPLICATION_JSON_VALUE)
23 23
    @ResponseBody
24 24
    DatasourcesBroker getDatasourcesOfUser(String user,String includeShared,String includeByOthers) throws BrokerException, JSONException;
modules/uoa-repository-manager-service/branches/dev-api/src/main/webapp/WEB-INF/aai-security.xml
48 48
    </util:map>
49 49

  
50 50

  
51
    <bean class="eu.dnetlib.repo.manager.service.config.FrontEndLinkURIAuthenticationSuccessHandler" id="frontEndRedirect">
51
    <bean class="eu.dnetlib.repo.manager.service.config.FrontEndLinkURIAuthenticationSuccessHandler" id="frontEndRedirect"
52
          init-method="init">
52 53
        <property name="frontEndURI" value="${webapp.dev.front}"/>
53 54
    </bean>
54 55

  

Also available in: Unified diff