Java Code Examples for org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl#setAttributes()
The following examples show how to use
org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl#setAttributes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkspaceDaoTest.java From che with Eclipse Public License 2.0 | 6 votes |
public static WorkspaceImpl createWorkspaceFromConfig( String id, AccountImpl account, String name) { final WorkspaceConfigImpl wCfg = createWorkspaceConfig(name); // Workspace final WorkspaceImpl workspace = new WorkspaceImpl(); workspace.setId(id); workspace.setAccount(account); wCfg.setName(name); workspace.setConfig(wCfg); workspace.setAttributes( new HashMap<>( ImmutableMap.of( "attr1", "value1", "attr2", "value2", "attr3", "value3"))); workspace.setConfig(wCfg); return workspace; }
Example 2
Source File: WorkspaceDaoTest.java From che with Eclipse Public License 2.0 | 6 votes |
public static WorkspaceImpl createWorkspaceFromDevfile( String id, AccountImpl account, String name) { final DevfileImpl devfile = createDevfile(name); // Workspace final WorkspaceImpl workspace = new WorkspaceImpl(); workspace.setId(id); workspace.setAccount(account); workspace.setDevfile(devfile); workspace.setAttributes( new HashMap<>( ImmutableMap.of( "attr1", "value1", "attr2", "value2", "attr3", "value3"))); return workspace; }
Example 3
Source File: WorkspaceManager.java From che with Eclipse Public License 2.0 | 5 votes |
/** * Updates an existing workspace with a new configuration. * * <p> * * <p>Replace strategy is used for workspace update, it means that existing workspace data will be * replaced with given {@code update}. * * @param update workspace update * @return updated instance of the workspace * @throws NullPointerException when either {@code workspaceId} or {@code update} is null * @throws NotFoundException when workspace with given id doesn't exist * @throws ConflictException when any conflict occurs (e.g Workspace with such name already exists * in {@code namespace}) * @throws ServerException when any other error occurs */ public WorkspaceImpl updateWorkspace(String id, Workspace update) throws ConflictException, ServerException, NotFoundException, ValidationException { requireNonNull(id, "Required non-null workspace id"); requireNonNull(update, "Required non-null workspace update"); checkArgument( update.getConfig() != null ^ update.getDevfile() != null, "Required non-null workspace configuration or devfile update but not both"); if (update.getConfig() != null) { validator.validateConfig(update.getConfig()); } WorkspaceImpl workspace = workspaceDao.get(id); validator.validateUpdateAttributes(workspace.getAttributes(), update.getAttributes()); if (workspace.getConfig() != null) { workspace.setConfig(new WorkspaceConfigImpl(update.getConfig())); } if (workspace.getDevfile() != null) { workspace.setDevfile(new DevfileImpl(update.getDevfile())); } workspace.setAttributes(update.getAttributes()); workspace.getAttributes().put(UPDATED_ATTRIBUTE_NAME, Long.toString(currentTimeMillis())); workspace.setTemporary(update.isTemporary()); return normalizeState(workspaceDao.update(workspace), true); }