Revision 50075
Added by Panagiotis Kanakakis over 6 years ago
RepositoryApiImpl.java | ||
---|---|---|
29 | 29 |
import org.springframework.web.util.UriComponentsBuilder; |
30 | 30 |
|
31 | 31 |
import javax.annotation.PostConstruct; |
32 |
import javax.ws.rs.Path; |
|
33 |
import javax.ws.rs.QueryParam; |
|
32 | 34 |
import java.io.IOException; |
33 | 35 |
import java.sql.Timestamp; |
34 | 36 |
import java.text.Normalizer; |
... | ... | |
175 | 177 |
.build().expand(page, size).encode(); |
176 | 178 |
rs = restTemplate.getForObject(uriComponents.toUri(), String.class); |
177 | 179 |
} |
178 |
for (Repository r : resultSet) |
|
180 |
for (Repository r : resultSet){ |
|
181 |
r.setInterfaces(this.getRepositoryInterface(r.getId())); |
|
179 | 182 |
r.setCountryName(getCountryName(r.getCountryCode())); |
183 |
} |
|
184 |
|
|
180 | 185 |
return resultSet; |
181 | 186 |
} |
182 | 187 |
|
... | ... | |
288 | 293 |
} |
289 | 294 |
|
290 | 295 |
@Override |
291 |
public void addRepository(@RequestBody String params) throws Exception { |
|
296 |
public void addRepository(@RequestParam("datatype") String datatype, |
|
297 |
@RequestBody Repository repository) throws Exception { |
|
292 | 298 |
|
293 |
JSONObject json_params = new JSONObject(params); |
|
299 |
/*JSONObject json_params = new JSONObject(params);
|
|
294 | 300 |
String datatype = json_params.getString("datatype"); |
295 | 301 |
String json_repository = json_params.getString("repository"); |
296 |
Repository repository = null; |
|
302 |
Repository repository = null;*/
|
|
297 | 303 |
ObjectMapper mapper = new ObjectMapper(); |
298 | 304 |
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); |
299 | 305 |
try { |
300 |
LOGGER.debug("repository -> " + json_repository); |
|
301 |
repository = mapper.readValue(json_repository, Repository.class); |
|
306 |
String json_repo = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(repository); |
|
307 |
LOGGER.debug("repository -> " + json_repo); |
|
308 |
// repository = mapper.readValue(json_repository, Repository.class); |
|
302 | 309 |
} catch (Exception e) { |
303 | 310 |
LOGGER.debug("Error parsing repository ", e); |
304 | 311 |
throw e; |
305 | 312 |
} |
306 |
|
|
307 | 313 |
repository = this.setRepositoryFeatures(datatype,repository); |
308 | 314 |
|
309 | 315 |
LOGGER.debug("storing " + datatype + " repository with id: " + repository.getId()); |
... | ... | |
320 | 326 |
} |
321 | 327 |
} |
322 | 328 |
} else { |
323 |
this.updateRegisteredByValue(repository.getId(),repository.getRegisteredBy());
|
|
329 |
this.updateRepository(repository);
|
|
324 | 330 |
} |
325 | 331 |
|
326 | 332 |
LOGGER.debug("Inserting Interfaces"); |
... | ... | |
341 | 347 |
} |
342 | 348 |
} |
343 | 349 |
|
350 |
private void updateRepository(Repository repository) { |
|
351 |
this.updateRegisteredByValue(repository.getId(),repository.getRegisteredBy()); |
|
352 |
this.updateEnglishName(repository.getId(),repository.getEnglishName()); |
|
353 |
this.updateLogoUrl(repository.getId(),repository.getLogoUrl()); |
|
354 |
this.updateTimezone(repository.getId(), String.valueOf(repository.getTimezone())); |
|
355 |
//TODO update datasource type |
|
356 |
} |
|
357 |
|
|
344 | 358 |
private void updateRegisteredByValue(String id, String registeredBy) { |
345 | 359 |
|
346 | 360 |
LOGGER.debug("Updating registered by value with : " + registeredBy ); |
... | ... | |
470 | 484 |
} |
471 | 485 |
|
472 | 486 |
@Override |
473 |
public RepositoryInterface addRepositoryInterface(@RequestBody String params) throws JSONException { |
|
487 |
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype, |
|
488 |
@RequestParam("repoId") String repoId, |
|
489 |
@RequestBody RepositoryInterface repositoryInterface) throws JSONException { |
|
474 | 490 |
|
475 |
JSONObject json_params = new JSONObject(params); |
|
476 |
|
|
477 |
LOGGER.debug(params); |
|
491 |
/* JSONObject json_params = new JSONObject(params); |
|
492 |
// LOGGER.debug(params); |
|
478 | 493 |
//TODO iFace parameter from gui. Object to json |
479 | 494 |
String datatype = json_params.getString("datatype"); |
480 | 495 |
String repoId = json_params.getString("repoId"); |
... | ... | |
486 | 501 |
iFace = mapper.readValue(json_iFace, RepositoryInterface.class); |
487 | 502 |
} catch (Exception e1) { |
488 | 503 |
LOGGER.debug("Error parsing repository interface ", e1); |
489 |
} |
|
490 |
|
|
491 |
return registerRepositoryInterface(repoId,iFace,datatype); |
|
504 |
}*/ |
|
505 |
return registerRepositoryInterface(repoId,repositoryInterface,datatype); |
|
492 | 506 |
} |
493 | 507 |
|
494 | 508 |
private RepositoryInterface registerRepositoryInterface(String repoId, RepositoryInterface iFace, String datatype) { |
Also available in: Unified diff
1. Update pom
2. New method on repository api ( update values on registration )