@Override public Map<String, Object> provideData() { Map<String, Object> jsonMap = new HashMap<>(); String instanceId = this.instanceIdManagerProvider.get().getInstanceId().toString(); jsonMap.put(PROPERTY_INSTANCE_ID, instanceId); CoreExtension distributionExtension = this.coreExtensionRepository.getEnvironmentExtension(); if (distributionExtension != null) { String distributionId = distributionExtension.getId().getId(); if (distributionId != null) { jsonMap.put(PROPERTY_DISTRIBUTION_ID, distributionId); } Version distributionVersion = distributionExtension.getId().getVersion(); if (distributionVersion != null) { jsonMap.put(PROPERTY_DISTRIBUTION_VERSION, distributionVersion.toString()); } Collection<String> features = distributionExtension.getFeatures(); if (!features.isEmpty()) { jsonMap.put(PROPERTY_DISTRIBUTION_FEATURES, distributionExtension.getFeatures().toArray()); } } return jsonMap; } }
private List<String> getEnvironmentPropertyList(String property) { // Get flavors from environment extension CoreExtension extension = this.coreRepository.getEnvironmentExtension(); if (extension != null) { String listString = extension.getProperty(property); return ExtensionUtils.importPropertyStringList(listString, true); } return Collections.emptyList(); }
@Override public URL getURL() { return getWrapped().getURL(); }
/** * Gets the PhenoTips version from the XWiki Distribution Manager and adds it to the patient data being loaded. * * @param versions the list of version data being constructed */ private void addPhenoTipsVersion(Map<String, String> versions) { try { DistributionManager distribution = ComponentManagerRegistry.getContextComponentManager().getInstance(DistributionManager.class); versions.put("phenotips_version", distribution.getDistributionExtension().getId().getVersion().toString()); } catch (ComponentLookupException ex) { // Shouldn't happen this.logger.error("Could not find DistributionManager component"); } }
@Override public boolean isGuessed() { return getWrapped().isGuessed(); } }
private boolean checkCoreDependency(ExtensionDependency extensionDependency, List<ModifableExtensionPlanNode> parentBranch) throws InstallException { CoreExtension coreExtension = this.coreExtensionRepository.getCoreExtension(extensionDependency.getId()); if (coreExtension != null) { ExtensionId feature = coreExtension.getExtensionFeature(extensionDependency.getId()); if (!extensionDependency.getVersionConstraint().isCompatible(feature.getVersion())) { throw new InstallException("Dependency [" + extensionDependency + "] is not compatible with core extension feature [" + feature + "] ([" + coreExtension + "])"); } else { if (getRequest().isVerbose()) { this.logger.debug( "There is already a core extension feature [{}] ([{}]) covering extension dependency [{}]", feature, coreExtension, extensionDependency); } ModifableExtensionPlanNode node = new ModifableExtensionPlanNode(extensionDependency, extensionDependency.getVersionConstraint()); node.setAction( new DefaultExtensionPlanAction(coreExtension, coreExtension, null, Action.NONE, null, true)); parentBranch.add(node); return true; } } return false; }
/** * Gets the PhenoTips version from the XWiki Distribution Manager and adds it to the patient data being loaded. * * @param versions the list of version data being constructed */ private void addPhenoTipsVersion(Map<String, String> versions) { try { CoreExtensionRepository coreExtensionRepository = ComponentManagerRegistry.getContextComponentManager().getInstance(CoreExtensionRepository.class); Version v = coreExtensionRepository.getCoreExtension("org.phenotips:patient-data-api").getId().getVersion(); versions.put("phenotips_version", v.toString()); } catch (ComponentLookupException ex) { // Shouldn't happen this.logger.error("Could not find DistributionManager component"); } }
String phenotipsVersion = this.distribution.getDistributionExtension().getId().getVersion().toString();
protected List<String> getRecommendedVersions() { // Try configuration Object configurationValue = this.configuration.get().getProperty(CK_PREFIX + "recommendedVersions"); if (configurationValue != null) { if (configurationValue instanceof List) { return (List) configurationValue; } else { return ExtensionUtils.importPropertyStringList(configurationValue.toString(), true); } } // Try environment extension CoreExtensionRepository repository = this.coreExtensionRepository.get(); CoreExtension environmentExtension = repository.getEnvironmentExtension(); if (environmentExtension != null) { String listString = environmentExtension.getProperty("xwiki.extension.recommendedVersions"); return ExtensionUtils.importPropertyStringList(listString, true); } return null; }
@Override public CoreExtension resolve(ExtensionId extensionId) throws ResolveException { CoreExtension extension = getCoreExtension(extensionId.getId()); if (extension == null || (extensionId.getVersion() != null && !extension.getId().getVersion().equals(extensionId.getVersion()))) { throw new ExtensionNotFoundException("Could not find extension [" + extensionId + "]"); } return extension; }
@Override public CoreExtension resolve(ExtensionDependency extensionDependency) throws ResolveException { CoreExtension extension = getCoreExtension(extensionDependency.getId()); if (extension == null || (!extensionDependency.getVersionConstraint().containsVersion(extension.getId().getVersion()))) { throw new ExtensionNotFoundException("Could not find extension dependency [" + extensionDependency + "]"); } return extension; }
if (!isCompatible(coreExtension.getId().getVersion(), dependency.getVersionConstraint())) { throw new InvalidExtensionException(String .format("Dependency [%s] is incompatible with the core extension [%s]", dependency, coreExtension));