Project

General

Profile

« Previous | Next » 

Revision 58384

remoteMdstore API creation in other infrastructure

View differences:

modules/dnet-modular-repositories-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/RepoInternalController.java
81 81
	@Value("${repo.ui.mdstore.sync.button}")
82 82
	private String syncButton;
83 83

  
84
	@Value("${repo.ui.mdstore.sync.desc}")
84
	@Value("${repo.ui.mdstore.sync.remote.desc}")
85 85
	private String syncDesc;
86 86

  
87
	@Value("${repo.ui.mdstore.sync.api.baseUrl}")
87
	@Value("${repo.ui.mdstore.sync.remote.api.baseUrl}")
88 88
	private String syncApiBaseUrl;
89 89

  
90
	@Value("${repo.ui.mdstore.sync.is.baseUrl}")
90
	@Value("${repo.ui.mdstore.sync.remote.is.baseUrl}")
91 91
	private String syncISBaseUrl;
92 92

  
93
	@Value("${repo.ui.mdstore.sync.local.mongodb.url}")
94
	private String mongoUrl;
95

  
93 96
	@Value("${services.mdstore.mongodb.db}")
94 97
	private String mongoDb;
95 98

  
96
	@Value("${services.mdstore.mongodb.host}")
97
	private String mongoHost;
98

  
99
	@Value("${services.mdstore.mongodb.port}")
100
	private int mongoPort;
101

  
102 99
	private static final Log log = LogFactory.getLog(RepoInternalController.class);
103 100

  
104 101
	@RequestMapping(value = "/ui/browseRepoField.do")
......
246 243
			map.addAttribute("syncDesc", syncDesc);
247 244
			map.addAttribute("syncISBaseUrl", syncISBaseUrl);
248 245
			map.addAttribute("mongoDB", mongoDb);
249
			map.addAttribute("mongoUrl", String.format("mongodb://%s:%s", mongoHost, mongoPort));
246
			map.addAttribute("mongoUrl", mongoUrl);
250 247
		}
251 248
	}
252 249

  
......
312 309
		log.info(" - repo id: " + api.getDatasource());
313 310
		log.info(" - api id: " + api.getId());
314 311
		log.info(" - rest call: " + url);
312
		log.info(" - json: " + new Gson().toJson(api));
315 313

  
316 314
		final RestTemplate restTemplate = new RestTemplate();
317 315

  
318
		final String res = restTemplate.postForObject(url, api, String.class);
316
		restTemplate.postForObject(url, api, Void.class);
319 317

  
320
		response.setContentType("application/json;charset=UTF-8");
321

  
322
		IOUtils.write(res, response.getOutputStream());
318
		listRemoteApis(api.getDatasource(), response);
323 319
	}
324 320

  
325 321
	@ExceptionHandler(Exception.class)
modules/dnet-modular-repositories-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/repositories/applicationContext-modular-ui-repositories.properties
8 8
repo.ui.addRepo.show 					= true
9 9
repo.ui.validator.address               = http://dev.openaire.research-infrastructures.eu:8880/validator/compatibility/browseHistory
10 10
repo.ui.validatorService.address        = http://dev.openaire.research-infrastructures.eu:8880/validator-service
11
repo.ui.mdstore.sync.button             = 
12
repo.ui.mdstore.sync.remote.desc        = 
13
repo.ui.mdstore.sync.remote.api.baseUrl = 
14
repo.ui.mdstore.sync.remote.is.baseUrl  = 
15
repo.ui.mdstore.sync.local.mongodb.url  =
11 16

  
12

  
13
repo.ui.mdstore.sync.button             = sync with DEV
14
repo.ui.mdstore.sync.desc               = OpenAIRE DEV Infrastructure
15
repo.ui.mdstore.sync.api.baseUrl        = https://dev-openaire.d4science.org/openaire
16
repo.ui.mdstore.sync.is.baseUrl         = https://dev-openaire.d4science.org/is
17
#repo.ui.mdstore.sync.button             = sync with DEV
18
#repo.ui.mdstore.sync.remote.desc        = OpenAIRE DEV Infrastructure
19
#repo.ui.mdstore.sync.remote.api.baseUrl = https://dev-openaire.d4science.org/openaire
20
#repo.ui.mdstore.sync.remote.is.baseUrl  = https://dev-openaire.d4science.org/is
21
#repo.ui.mdstore.sync.local.mongodb.url  = mongodb://146.48.87.97:27017
modules/dnet-modular-repositories-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/repos/repoApi.st
250 250
				<h4 class="modal-title">Remote API</h4>
251 251
			</div>
252 252
			<div class="modal-body">
253
				The following API has been already registered on
253
				{{syncShowRemoteMessage}}
254 254
				<a href="$syncISBaseUrl$/mvc/ui/repoApis.do#/api/{{syncApi.datasource}}/{{syncApi.id}}/ALL/ALL" target="_blank">
255 255
					 $syncDesc$
256 256
				</a>
......
273 273
			<div class="modal-body">
274 274
				The following API will be created on <b>$syncDesc$</b>:
275 275
				<br /><br />
276
				<pre>{{syncApi | json}}</pre>
276
				
277
				<div>
278
					<ul class="nav nav-tabs" role="tablist">
279
						<li class="active"><a href="javascript:void(0)" data-toggle="tab" data-target="#showAsTable">table</a></li>
280
						<li><a href="javascript:void(0)" data-toggle="tab" data-target="#showAsJson">json</a></li>
281
					</ul>
282
					<div class="tab-content" style="margin-top:4px">
283
						<div class="tab-pane active" id="showAsTable">
284
							<table class="table table-striped table-condensed">
285
								<tr>
286
									<th>id</th>
287
									<td>{{syncApi.id}}</td>
288
								</tr>
289
								<tr>
290
									<th>protocol</th>
291
									<td>{{syncApi.protocol}}</td>
292
								</tr>
293
								<tr>
294
									<th>baseUrl</th>
295
									<td>{{syncApi.baseurl}}</td>
296
								</tr>
297
								<tr ng-repeat="p in syncApi.apiParams">
298
									<th>{{p.param}}</th>
299
									<td>{{p.value}}</td>
300
								</tr>
301
								<tr>
302
									<th>id xpath</th>
303
									<td>{{syncApi.metadataIdentifierPath}}</td>
304
								</tr>
305
							</table>
306
						</div>
307
						<div class="tab-pane" id="showAsJson">
308
							<pre>{{syncApi | json}}</pre>
309
						</div>
310
					</div>
311
				</div>
277 312
			</div>
278 313
			<div class="modal-footer">
279
				<button type="button" class="btn btn-primary" ng-click="createRemoteSyncApi(syncApi)">Confirm</button>
314
				<button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="createRemoteSyncApi(syncApi)">Confirm</button>
280 315
				<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
281 316
			</div>
282 317
		</div>
modules/dnet-modular-repositories-ui/trunk/src/main/resources/eu/dnetlib/web/resources/js/repoControllers.js
105 105
		$scope.selectedSets = [];
106 106

  
107 107
		$scope.syncApi = {};
108
		$scope.syncShowRemoteMessage = "";
108 109

  
109 110
		$scope.loadApi = function() {
110 111
			$scope.showSpinner();
......
434 435
						}
435 436

  
436 437
						if (alreadyPresent) {
438
							$scope.syncShowRemoteMessage = "The synchronization API has been already registered on";
437 439
							$('#showRemoteSyncApiModal').modal('show');
438 440
						} else {
439 441
							$scope.syncApi = {
......
445 447
									"compatibility": compliance,
446 448
									"baseurl": mongoUrl,
447 449
									"removable": true,
450
									"metadataIdentifierPath": path,
448 451
									"apiParams": [
449 452
										{
450 453
											"param": "remote_database",
......
454 457
											"param": "remote_mdstore_id",
455 458
											"value": mdId
456 459
										}
457
									],
458
									"otherParams": [
459
										{
460
											"param": "metadata_identifier_path",
461
											"value": path
462
										}
463 460
									]
464 461
							};
465 462
							$('#newRemoteSyncApiModal').modal('show');	        				
466 463
						}
467 464
					}
468 465
			).error(
469
					function() {
470
						$scope.showError('Something really bad must have happened to our fellow hamster..');
466
					function(err) {
467
						$scope.showError("Error registering the API: probably the datasource has not been registered on the remote infrastructure.");
471 468
						$scope.hideSpinner();
472 469
					}
473 470
			);
......
476 473
		
477 474
		$scope.createRemoteSyncApi = function(api) {
478 475
			$scope.showSpinner();
479
			
476

  
480 477
			$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
481 478
			$http.post('remoteDatasource/api', api).success(function(data) {
482 479
				$scope.hideSpinner();
483

  
484
			}).error(function() {
485
				$scope.showError('Something really bad must have happened to our fellow hamster..');
480
				$scope.syncShowRemoteMessage = "The synchronization API has been created on";
481
				$('#showRemoteSyncApiModal').modal('show');
482
			}).error(function(err) {
483
				$scope.showError("Error registering the API: probably the datasource has not been registered on the remote infrastructure.");
486 484
				$scope.hideSpinner();
487 485
			});
488 486
		}

Also available in: Unified diff