@Override public int compareTo(Object _other) { if(_other==null || !(_other instanceof Application)) throw new IllegalArgumentException(); int v = this.getMvnGroup().compareTo(((Application)_other).getMvnGroup()); if(v==0) v = this.getArtifact().compareTo(((Application)_other).getArtifact()); if(v==0) v = this.getVersion().compareTo(((Application)_other).getVersion()); return v; }
public String toString(boolean _deep) { final StringBuilder builder = new StringBuilder(); if(_deep) { builder.append("Application ").append(this.toString(false)).append(System.getProperty("line.separator")); if(this.getConstructs()!=null) for(ConstructId cid: this.getConstructs()) builder.append(" ConstructId ").append(cid).append(System.getProperty("line.separator")); } else { builder.append("[").append(this.getMvnGroup()).append(":").append(this.getArtifact()).append(":").append(this.getVersion()).append("]"); } return builder.toString(); } }
/** * Reads configuration settings in order to instantiate an {@link Application}. * @return an {@link Application) * @throws ConfigurationException if the instantiation fails */ public static Application getAppContext() throws ConfigurationException { final Configuration c = VulasConfiguration.getGlobal().getConfiguration(); Application a = null; try { a = new Application(c.getString(APP_CTX_GROUP), c.getString(APP_CTX_ARTIF), c.getString(APP_CTX_VERSI)); } catch (IllegalArgumentException e) { throw new ConfigurationException("Application incomplete: " + e.getMessage(), e); } if(!a.isComplete()) throw new ConfigurationException("Application incomplete: " + a.toString()); return a; }
/** * Returns true if the application has {@link ConstructId}s and no {@link Dependency}s, false otherwise. * The invocation of {@link Application#isEmpty()} right after {@link Application#clear()} must return true. * @return */ public Boolean isEmpty() { return (this.getConstructs()==null || this.getConstructs().isEmpty()) && (this.getDependencies()==null || this.getDependencies().isEmpty()); }
/** * Returns the context of this goal execution. If the context has not been set before, it is constructed * by reading tenant, space and app information from the configuration obtained from {@link AbstractGoal#getConfiguration()}. * @return */ public synchronized final GoalContext getGoalContext() { if(this.goalContext==null) { final Configuration c = this.getConfiguration().getConfiguration(); this.goalContext = new GoalContext(); // Tenant if(!this.getConfiguration().isEmpty(CoreConfiguration.TENANT_TOKEN)) this.goalContext.setTenant(new Tenant(c.getString(CoreConfiguration.TENANT_TOKEN))); // Space if(!this.getConfiguration().isEmpty(CoreConfiguration.SPACE_TOKEN)) { final Space space = new Space(); space.setSpaceToken(c.getString(CoreConfiguration.SPACE_TOKEN)); this.goalContext.setSpace(space); } // App if(Application.canBuildApplication(c.getString(CoreConfiguration.APP_CTX_GROUP), c.getString(CoreConfiguration.APP_CTX_ARTIF), c.getString(CoreConfiguration.APP_CTX_VERSI))) { final Application a = new Application(c.getString(CoreConfiguration.APP_CTX_GROUP), c.getString(CoreConfiguration.APP_CTX_ARTIF), c.getString(CoreConfiguration.APP_CTX_VERSI)); if(a.isComplete()) this.goalContext.setApplication(a); else log.warn("Incomplete application context: " + a.toString()); } } return this.goalContext; }
@Override public String toString() { return this.toString(false); }
/** * vulas-backend:/apps/{group}/{artifact} * @return */ public static final String artifact(@NotNull Application _app) { final StringBuilder b = new StringBuilder(); b.append(apps()).append("/"); b.append(_app.getMvnGroup()).append("/").append(_app.getArtifact()); return b.toString(); }
final Set<Dependency> no_dupl_deps = DependencyUtil.removeDuplicateLibraryDependencies(a.getDependencies()); a.setDependencies(no_dupl_deps); if(a.getDependencies()!=null) { for(Dependency dep: a.getDependencies()) { if(!a.isEmpty() || app_exists_in_backend || upload_empty) { log.info("Save app " + a + " with [" + a.getDependencies().size() + "] dependencies and [" + a.getConstructs().size() + "] constructs (uploadEmpty=" + upload_empty + ")"); BackendConnector.getInstance().uploadApp(this.getGoalContext(), a);
/** * Recursively loops over the subprojects of the given project in order to build * a complete set of {@link Application} modules. * @param _prj * @param _ids */ private void collectApplicationModules(MavenProject _prj, Set<Application> _ids) { _ids.add(new Application(_prj.getGroupId(), _prj.getArtifactId(), _prj.getVersion())); if(_prj.getPackaging().equalsIgnoreCase("pom")) { for(MavenProject module: _prj.getCollectedProjects()) { this.collectApplicationModules(module, _ids); } } } }
if(pack.getStandardDistributionName().equals(PipInstalledPackage.getStandardDistributionName(this.getApplication().getMvnGroup()))) { prj_package = pack; break;
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((appContext == null) ? 0 : appContext.hashCode()); result = prime * result + ((c == null) ? 0 : c.hashCode()); result = prime * result + ((resourceURL == null) ? 0 : resourceURL.hashCode()); return result; } @Override
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ConstructUsage other = (ConstructUsage) obj; if (appContext == null) { if (other.appContext != null) return false; } else if (!appContext.equals(other.appContext)) return false; if (c == null) { if (other.c != null) return false; } else if (!c.equals(other.c)) return false; if (resourceURL == null) { if (other.resourceURL != null) return false; } else if (!resourceURL.equals(other.resourceURL)) return false; return true; } }
a.addDependencies(this.toDependencies(app_pip_packs)); a.addConstructs(ConstructId.getSharedType(app_constructs));
a.addConstructs(ConstructId.getSharedType(app_constructs)); new_dep.setDeclared( ((dep!=null && ja.getParent()==null) ? new Boolean(true): new Boolean(false)) ); a.addDependency(new_dep); } catch (FileAnalysisException e) { log.error(e.getMessage(), e);
@JsonProperty(value = "countDependencies") public int countDependencies() { return (this.getDependencies()==null ? -1 : this.getDependencies().size()); }
@JsonProperty(value = "constructCounter") public int countConstructs() { return ( this.getConstructs()==null ? 0 : this.getConstructs().size()); }
@Override public String toString() { final StringBuffer b = new StringBuffer(); b.append("[app=").append(this.app.toString()).append(", lib=").append(this.lib.toString()).append(", filename=").append(this.filename).append(", scope=").append(this.scope).append(", trans=").append(this.getTransitive()).append("]"); return b.toString(); } }
u.setArchiveFileName(jar_name); if(_app_groupid!=null && _app_artifactid!=null && _app_version!=null) u.setAppContext(new Application(_app_groupid, _app_artifactid, _app_version));
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((app == null) ? 0 : app.hashCode()); result = prime * result + ((bug == null) ? 0 : bug.hashCode()); result = prime * result + ((dep == null) ? 0 : dep.hashCode()); return result; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Trace other = (Trace) obj; if (app == null) { if (other.app != null) return false; } else if (!app.equals(other.app)) return false; if (constructId == null) { if (other.constructId != null) return false; } else if (!constructId.equals(other.constructId)) return false; if (lib == null) { if (other.lib != null) return false; } else if (!lib.equals(other.lib)) return false; return true; }