public ReachabilityAnalyzer(GoalContext _ctx) { this.goalContext = _ctx; this.app_ctx = _ctx.getApplication(); }
/** * All {@link Space}-related goals need to have a tenant configured. * @throws GoalConfigurationException if no tenant is specified */ protected void checkPreconditions() throws GoalConfigurationException { if(!this.getGoalContext().hasTenant()) throw new GoalConfigurationException("No tenant configured"); }
/** * 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; }
if(this.context!=null && this.context.hasTenant()) { tenant_token = this.context.getTenant().getTenantToken(); connection.setRequestProperty(Constants.HTTP_TENANT_HEADER, tenant_token); if(this.context!=null && this.context.hasSpace()) { space_token = this.context.getSpace().getSpaceToken(); connection.setRequestProperty(Constants.HTTP_SPACE_HEADER, space_token);
if(_ctx.getApplication()!=null) { final Application app = _ctx.getApplication(); if(this.isAppExisting(_ctx, app)) { final BasicHttpRequest cond_req = new BasicHttpRequest(HttpMethod.OPTIONS, PathBuilder.goalExcecution(null, _ctx.getSpace(), app, _gexe.getId()), null); cond_req.setGoalContext(_ctx); params.put("skipResponseBody", "true"); req_list.addRequest( new ConditionalHttpRequest(HttpMethod.POST, PathBuilder.goalExcecutions(null, _ctx.getSpace(), app), params) .setConditionRequest(cond_req) .addCondition(new StatusCondition(HttpURLConnection.HTTP_NOT_FOUND)) ); req_list.addRequest( new ConditionalHttpRequest(HttpMethod.PUT, PathBuilder.goalExcecution(null, _ctx.getSpace(), app, _gexe.getId()), params) .setConditionRequest(cond_req) .addCondition(new StatusCondition(HttpURLConnection.HTTP_OK)) BackendConnector.log.info("App " + _ctx.getApplication() + " does not exist in backend, upload of goal execution [" + _gexe.getId() + "] skipped"); ret = true;
@Override protected void executeTasks() throws Exception { final Space s = this.getGoalContext().getSpace(); final BackendConnector bc = BackendConnector.getInstance(); // Check that space exists if(!bc.isSpaceExisting(this.getGoalContext(), s)) throw new GoalExecutionException("Space with token [" + s.getSpaceToken() + "] does not exist", null); bc.cleanSpace(this.getGoalContext(), s); } }
@Override protected void executeTasks() throws Exception { final Space s = new Space(); this.updateFromConfig(s); // Warn that any provided space token is ignored when creating a new space if(s.isValidSpaceToken()) log.warn("Upon space creation a new token will be generated, the current token [" + s.getSpaceToken() + "] will be ignored"); // Check that name and description are provided if(!s.hasNameAndDescription()) { this.skipGoalUpload(); throw new GoalExecutionException("Space creation requires name and description, adjust the configuration accordingly", null); } // Create space and print token to be used in configuration this.createdSpace = BackendConnector.getInstance().createSpace(this.getGoalContext(), s); if(this.createdSpace==null) { log.error("Space creation failed"); } else { log.info("Space creation succeeded: Use space token [" + this.createdSpace.spaceToken + "] for configuration setting [" + CoreConfiguration.SPACE_TOKEN + "]"); // Update context so that goal execution is uploaded properly this.getGoalContext().setSpace(this.createdSpace); } }
g.getGoalContext().setApplication(this.getApplicationContext()); ((AbstractAppGoal)g).addAppPaths(new HashSet<Path>(this.getAppPaths()));
final GoalContext ctx = new GoalContext(); if(!VulasConfiguration.getGlobal().isEmpty(CoreConfiguration.TENANT_TOKEN)) { tenant = new Tenant(c.getString(CoreConfiguration.TENANT_TOKEN)); ctx.setTenant(tenant); final Space space = new Space(); space.setSpaceToken(c.getString(CoreConfiguration.SPACE_TOKEN)); ctx.setSpace(space); ctx.setApplication(a); else log.warn("Incomplete application context: " + a.toString());
@Override protected void executeTasks() throws Exception { final Space s = this.getGoalContext().getSpace(); final BackendConnector bc = BackendConnector.getInstance(); // Check that space exists if(!bc.isSpaceExisting(this.getGoalContext(), s)) throw new GoalExecutionException("Space with token [" + s.getSpaceToken() + "] does not exist", null); bc.deleteSpace(this.getGoalContext(), s); } }
protected Application getApplicationContext() { return this.getGoalContext().getApplication(); }
@Override protected void executeTasks() throws Exception { final Space s = this.getGoalContext().getSpace(); this.updateFromConfig(s); final BackendConnector bc = BackendConnector.getInstance(); // Check that name and description are provided if(!s.hasNameAndDescription()) throw new GoalExecutionException("Space modification requires a name and description, adjust the configuration accordingly", null); // Check that space exists if(!bc.isSpaceExisting(this.getGoalContext(), s)) throw new GoalExecutionException("Space with token [" + s.getSpaceToken() + "] does not exist", null); bc.modifySpace(this.getGoalContext(), s); } }
dep = new Dependency(this.goal.getGoalContext().getApplication(), lib, Scope.valueOf(a.getScope().toUpperCase()), !direct_artifacts.contains(a), null, a.getFile().toPath().toString()); dep_for_path.put(a.getFile().toPath(), dep);