public ApiInfoImpl(org.eclipse.che.api.core.rest.shared.dto.ApiInfo origin) { this.specificationTitle = origin.getSpecificationTitle(); this.scmRevision = origin.getScmRevision(); this.ideVersion = origin.getIdeVersion(); this.specificationVersion = origin.getSpecificationVersion(); this.implementationVendor = origin.getImplementationVendor(); this.specificationVendor = origin.getSpecificationVendor(); this.implementationVersion = origin.getImplementationVersion(); }
private ApiInfo readApiInfo() throws ServerException { try { URL url = ApiInfoService.class.getProtectionDomain().getCodeSource().getLocation(); try (JarFile jar = new JarFile(new File(url.toURI()))) { final Manifest manifest = requireNonNull(jar.getManifest(), "Manifest must not be null"); final Attributes mainAttributes = manifest.getMainAttributes(); final DtoFactory dtoFactory = DtoFactory.getInstance(); return dtoFactory .createDto(ApiInfo.class) .withSpecificationVendor(mainAttributes.getValue("Specification-Vendor")) .withImplementationVendor(mainAttributes.getValue("Implementation-Vendor")) .withSpecificationTitle("Codenvy REST API") .withSpecificationVersion(mainAttributes.getValue("Specification-Version")) .withImplementationVersion(mainAttributes.getValue("Implementation-Version")) .withScmRevision(mainAttributes.getValue("SCM-Revision")); } } catch (Exception e) { LOG.error(e.getMessage(), e); throw new ServerException("Unable read info about API. Contact support for assistance."); } }