public void deploy(String symbolicName) throws Exception { repositories = new ArrayList<Repository>(); // Getting all installed repositories populateRepositories(); // Getting subsystem resource from OBR Repository by resource // symbolicName Resource subsystemResource = getSubsystemResource(symbolicName); // Install related repositories or related subsystems if needed LOGGER.log(Level.INFO, "Subsystem dependency manager started."); LOGGER.log(Level.INFO, ""); installSubsystemDependencies(subsystemResource); LOGGER.log(Level.INFO, "Subsystem dependency manager finished."); LOGGER.log(Level.INFO, ""); // Install subsystem using symbolicName Subsystem subsystem = install(subsystemResource.getURI()); // Starting installed subsystem start(subsystem.getSubsystemId()); }
public boolean getAllPossibleValues(final List<Completion> completions, final Class<?> requiredType, final String originalUserInput, final String optionContext, final MethodTarget target) { // Getting installed repositories populateRepositories(); for (Repository repo : repositories) { // Getting all resources from repository Resource[] repositoryResource = repo.getResources(); for (Resource resource : repositoryResource) { // If current resource ends with .esa, means that is a ROO Addon Suite if (resource.getURI().endsWith(".esa")) { completions.add(new Completion(resource.getSymbolicName())); } } } return false; }
@Override public void listAllSubsystemsOnRepository(ObrRepositorySymbolicName obrRepository) { LOGGER.log(Level.INFO, "Getting all 'Roo Addon Suites' located on '" + obrRepository.getKey() + "' repository... "); LOGGER.log(Level.INFO, " "); int repos = 0; // Getting all repositories Repository[] repositories = getRepositoryAdmin().listRepositories(); for (Repository repo : repositories) { if (repo.getURI().equals(obrRepository.getKey())) { // Getting all resources from repository Resource[] repositoryResource = repo.getResources(); for (Resource resource : repositoryResource) { // If current resource ends with .esa, means that is a ROO Addon Suite if (resource.getURI().endsWith(".esa")) { LOGGER.log(Level.INFO, " " + resource.getSymbolicName()); repos++; } } } } LOGGER.log(Level.INFO, " "); LOGGER.log( Level.INFO, String.format("%s Roo Addon Suites were found on '%s' repository", repos, obrRepository.getKey())); }
repoResource.getSize(), repoResource.getVersion(), repoResource.getURI());
repoResource.getSize(), repoResource.getVersion(), repoResource.getURI());
public String getURI() { return resource.getURI(); }
public String getURI() { return resource.getURI(); }
public String getURI() { return resource.getURI(); }
@Override public List<URI> getJarLocations() { List<URI> uris = new ArrayList<URI>(); for (Resource resource : obr.getResources()) { final URI e = URI.create(resource.getURI()); uris.add(e); } return uris; }
private String downloadBundle(Resource resource) throws MalformedURLException, IOException { String uriString = resource.getURI(); URI uri = URI.create(uriString); InputStream stream = null; OutputStream out = null; File destination; try { stream = uri.toURL().openStream(); pluginDir.mkdirs(); destination = new File(pluginDir,resource.getSymbolicName()+"_"+resource.getVersion()+".jar"); out = new FileOutputStream(destination); byte[] buffer = new byte[4096]; int read = 0; while((read=stream.read(buffer))!=-1) { out.write(buffer,0,read); } } finally { if(out!=null) out.close(); if(stream!=null) stream.close(); } return destination.toURI().toString(); }
private BundleInfo toBundleInfo(Resource resource, boolean optional) { Map<String, String> directives = null; if (optional) { directives = new HashMap<String, String>(); directives.put(Constants.RESOLUTION_DIRECTIVE, Constants.RESOLUTION_OPTIONAL); } String location = resource.getURI(); return new OBRBundleInfo(resource.getSymbolicName(), resource.getVersion(), location, null, null, null, null, null, null, directives, null); }
private List<ModuleDefinition> findAll(String name, String version) { List<ModuleDefinition> mds = new ArrayList<ModuleDefinition>(); for (Resource resource : obr.getResources()) { if (name != null) { final String rsn = resource.getSymbolicName(); final Version rv = resource.getVersion(); boolean versionMatching = (version == null) || version.equals(rv.toString()); boolean nameMatching = name.equals(rsn); if (nameMatching && versionMatching) { try { final URI uri = URI.create(resource.getURI()); mds.add(makeModuleDef(new File(uri))); } catch (IOException e) { throw new RuntimeException(e); // TODO(Sahoo): Proper Exception Handling } } } } return mds; }
private StringBuffer getResolverOutput(Resolver resolver) { Resource[] addedResources = resolver.getAddedResources(); Resource[] requiredResources = resolver.getRequiredResources(); Resource[] optionalResources = resolver.getOptionalResources(); Reason[] unsatisfiedRequirements = resolver.getUnsatisfiedRequirements(); StringBuffer sb = new StringBuffer("Added resources: ["); for (Resource r : addedResources) { sb.append("\n").append(r.getSymbolicName()).append(", ").append(r.getVersion()).append(", ").append(r.getURI()); } sb.append("]\nRequired Resources: ["); for (Resource r : requiredResources) { sb.append("\n").append(r.getURI()); } String optionalRequirementsDeployed = deployOptionalRequirements ? "deployed" : "not deployed"; sb.append("]\nOptional resources (" + optionalRequirementsDeployed + "): ["); for (Resource r : optionalResources) { sb.append("\n").append(r.getURI()); } sb.append("]\nUnsatisfied requirements: ["); for (Reason r : unsatisfiedRequirements) { sb.append("\n").append(r.getRequirement()); } sb.append("]"); return sb; }
private BundleInfo toBundleInfo(Resource resource, boolean optional) { Map<String, String> directives = null; if (optional) { directives = new HashMap<String, String>(); directives.put(Constants.RESOLUTION_DIRECTIVE, Constants.RESOLUTION_OPTIONAL); } return new OBRBundleInfo(resource.getSymbolicName(), resource.getVersion(), resource.getURI(), null, null, null, null, null, null, directives, null); }
private BundleInfo toBundleInfo(Resource resource, boolean optional) { Map<String, String> directives = null; if (optional) { directives = new HashMap<String, String>(); directives.put(Constants.RESOLUTION_DIRECTIVE, Constants.RESOLUTION_OPTIONAL); } return new OBRBundleInfo(resource.getSymbolicName(), resource.getVersion(), resource.getURI(), null, null, null, null, null, null, directives, null); }
File bundleFile = new File(repoBaseDir, resource.getURI()); String bundlePath = bundleFile.toURI().toString();
/** * Write out the resource element * * @param r * resource * @param writer * buffer writer * @throws IOException */ private static void writeResource(Resource r, String uri, Document doc, Element root) throws IOException { logger.debug(LOG_ENTRY, "writeResource", new Object[]{r, uri, doc, root}); Element resource = doc.createElement("resource"); resource.setAttribute(Resource.VERSION, r.getVersion().toString()); resource.setAttribute("uri", r.getURI()); resource.setAttribute(Resource.SYMBOLIC_NAME, r.getSymbolicName()); resource.setAttribute(Resource.ID, r.getSymbolicName() + "/" + r.getVersion()); resource.setAttribute(Resource.PRESENTATION_NAME, r.getPresentationName()); root.appendChild(resource); for (Capability c : r.getCapabilities()) writeCapability(c, doc, resource); for (Requirement req : r.getRequirements()) { writeRequirement(req, doc, resource); } logger.debug(LOG_EXIT, "writeResource"); }
/** * Write out the resource element * * @param r * resource * @param writer * buffer writer * @throws IOException */ private static void writeResource(Resource r, String uri, Document doc, Element root) throws IOException { logger.debug(LOG_ENTRY, "writeResource", new Object[]{r, uri, doc, root}); Element resource = doc.createElement("resource"); resource.setAttribute(Resource.VERSION, r.getVersion().toString()); resource.setAttribute("uri", r.getURI()); resource.setAttribute(Resource.SYMBOLIC_NAME, r.getSymbolicName()); resource.setAttribute(Resource.ID, r.getSymbolicName() + "/" + r.getVersion()); resource.setAttribute(Resource.PRESENTATION_NAME, r.getPresentationName()); root.appendChild(resource); for (Capability c : r.getCapabilities()) writeCapability(c, doc, resource); for (Requirement req : r.getRequirements()) { writeRequirement(req, doc, resource); } logger.debug(LOG_EXIT, "writeResource"); }