public static final String space(@NotNull Space _space) { final StringBuilder b = new StringBuilder(); b.append(spaces()).append("/"); b.append(_space.getSpaceToken()); return b.toString(); }
protected void updateFromConfig(Space _s) { final Configuration c = this.getConfiguration().getConfiguration(); _s.setSpaceName(c.getString(CoreConfiguration.SPACE_NAME, null)); _s.setSpaceDescription(c.getString(CoreConfiguration.SPACE_DESCR, null)); _s.setExportConfiguration(ExportConfiguration.parse(c.getString(CoreConfiguration.SPACE_EXPCFG, "AGGREGATED"))); _s.setPublic(c.getBoolean(CoreConfiguration.SPACE_PUBLIC, true)); _s.setBugFilter(c.getInt(CoreConfiguration.SPACE_BUGFLT, -1)); _s.setOwnerEmails(new HashSet<String>(Arrays.asList(c.getStringArray(CoreConfiguration.SPACE_OWNERS)))); } }
public Space(String _t, String _n, String _d) { this.setSpaceToken(_t); this.setSpaceName(_n); this.setSpaceDescription(_d); }
@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); } }
/** * 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 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); } }
final Space space = new Space(); space.setSpaceToken(c.getString(CoreConfiguration.SPACE_TOKEN)); ctx.setSpace(space);
space_token = this.context.getSpace().getSpaceToken(); connection.setRequestProperty(Constants.HTTP_SPACE_HEADER, space_token);
@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 = 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); } }