@Override public void update(Installer installer) throws InstallerException { checkConfiguration(); try { requestFactory .fromUrl( UriBuilder.fromUri(registryServiceUrl) .path(InstallerRegistryService.class, "update") .build() .toString()) .setBody(asDto(installer)) .usePutMethod() .request(); } catch (NotFoundException e) { throw new InstallerNotFoundException(e.getMessage(), e); } catch (IOException | ApiException e) { throw new InstallerException(e.getMessage(), e); } }
@Override public List<String> getVersions(String id) throws InstallerException { checkConfiguration(); try { @SuppressWarnings("unchecked") List<String> result = requestFactory .fromUrl( UriBuilder.fromUri(registryServiceUrl) .path(InstallerRegistryService.class, "getVersions") .build(id) .toString()) .useGetMethod() .request() .as(List.class, new TypeToken<List<String>>() {}.getType()); return result; } catch (NotFoundException e) { throw new InstallerNotFoundException(e.getMessage(), e); } catch (IOException | ApiException e) { throw new InstallerException(e.getMessage(), e); } }
@Override public Installer getInstaller(String installerKey) throws InstallerException { checkConfiguration(); try { return requestFactory .fromUrl( UriBuilder.fromUri(registryServiceUrl) .path(InstallerRegistryService.class, "getInstaller") .build(installerKey) .toString()) .useGetMethod() .request() .asDto(InstallerDto.class); } catch (NotFoundException e) { throw new InstallerNotFoundException(e.getMessage(), e); } catch (BadRequestException e) { throw new IllegalInstallerKeyException(e.getMessage(), e); } catch (IOException | ApiException e) { throw new InstallerException(e.getMessage(), e); } }
@Override public Map<String, VcsStatus> getStatus(String wsPath, List<String> paths) throws ServerException { Map<String, VcsStatus> result = new HashMap<>(); try { ProjectConfig project = projectManager .getClosest(absolutize(wsPath)) .orElseThrow(() -> new NotFoundException("Can't find project")); Status status = getStatus( project.getName(), pathTransformer.transform(project.getPath()).toString(), paths); paths.forEach( path -> { String itemWsPath = resolve(project.getPath(), path); if (status.getUntracked().contains(path)) { result.put(itemWsPath, UNTRACKED); } else if (status.getAdded().contains(path)) { result.put(itemWsPath, ADDED); } else if (status.getModified().contains(path) || status.getChanged().contains(path)) { result.put(itemWsPath, MODIFIED); } else { result.put(itemWsPath, NOT_MODIFIED); } }); } catch (NotFoundException e) { throw new ServerException(e.getMessage()); } return result; }
@Override public List<Installer> getOrderedInstallers(List<String> installerKeys) throws InstallerException { checkConfiguration(); try { return new ArrayList<>( requestFactory .fromUrl( UriBuilder.fromUri(registryServiceUrl) .path(InstallerRegistryService.class, "getOrderedInstallers") .build() .toString()) .usePostMethod() .setBody(installerKeys) .request() .asList(InstallerDto.class)); } catch (NotFoundException e) { throw new InstallerNotFoundException(e.getMessage(), e); } catch (BadRequestException e) { throw new IllegalInstallerKeyException(e.getMessage(), e); } catch (IOException | ApiException e) { throw new InstallerException(e.getMessage(), e); } }