gpt4 book ai didi

org.eclipse.che.api.core.model.workspace.Workspace.getId()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-22 13:39:05 25 4
gpt4 key购买 nike

本文整理了Java中org.eclipse.che.api.core.model.workspace.Workspace.getId()方法的一些代码示例,展示了Workspace.getId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Workspace.getId()方法的具体详情如下:
包路径:org.eclipse.che.api.core.model.workspace.Workspace
类名称:Workspace
方法名:getId

Workspace.getId介绍

[英]Returns the identifier of this workspace instance. It is mandatory and unique.
[中]返回此工作区实例的标识符。它是强制性的和独特的。

代码示例

代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace

private void removeWorkspaceQuietly(Workspace workspace) {
 try {
  workspaceDao.remove(workspace.getId());
 } catch (ServerException x) {
  LOG.error("Unable to remove temporary workspace '{}'", workspace.getId());
 }
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace

private void handleStartupSuccess(Workspace workspace) {
 workspace.getAttributes().remove(STOPPED_ATTRIBUTE_NAME);
 workspace.getAttributes().remove(STOPPED_ABNORMALLY_ATTRIBUTE_NAME);
 workspace.getAttributes().remove(ERROR_MESSAGE_ATTRIBUTE_NAME);
 try {
  updateWorkspace(workspace.getId(), workspace);
 } catch (NotFoundException | ServerException | ValidationException | ConflictException e) {
  LOG.warn(
    String.format(
      "Cannot clear error status status of the workspace %s. Error is: %s",
      workspace.getId(), e.getMessage()));
 }
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace

private void handleStartupError(Workspace workspace, Throwable t) {
 workspace
   .getAttributes()
   .put(
     ERROR_MESSAGE_ATTRIBUTE_NAME,
     t instanceof RuntimeException ? t.getCause().getMessage() : t.getMessage());
 workspace.getAttributes().put(STOPPED_ATTRIBUTE_NAME, Long.toString(currentTimeMillis()));
 workspace.getAttributes().put(STOPPED_ABNORMALLY_ATTRIBUTE_NAME, Boolean.toString(true));
 try {
  updateWorkspace(workspace.getId(), workspace);
 } catch (NotFoundException | ServerException | ValidationException | ConflictException e) {
  LOG.warn(
    String.format(
      "Cannot set error status of the workspace %s. Error is: %s",
      workspace.getId(), e.getMessage()));
 }
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace

private static EnvironmentImpl copyEnv(Workspace workspace, String envName) {
 requireNonNull(workspace, "Workspace should not be null.");
 requireNonNull(envName, "Environment name should not be null.");
 final Environment environment = workspace.getConfig().getEnvironments().get(envName);
 if (environment == null) {
  throw new IllegalArgumentException(
    format("Workspace '%s' doesn't contain environment '%s'", workspace.getId(), envName));
 }
 return new EnvironmentImpl(environment);
}

代码示例来源:origin: org.eclipse.che.infrastructure/infrastructure-openshift

@Override
public void onEvent(WorkspaceRemovedEvent event) {
 try {
  doRemoveProject(event.getWorkspace().getId());
 } catch (InfrastructureException e) {
  LOG.warn(
    "Fail to remove OpenShift project for workspace with id {}. Cause: {}",
    event.getWorkspace().getId(),
    e.getMessage());
 }
}

代码示例来源:origin: org.eclipse.che.selenium/che-selenium-core

/**
 * Ensure workspace has running status, or throw IllegalStateException.
 *
 * @param workspace workspace description to get status and id.
 * @throws IllegalStateException if workspace with certain workspaceId doesn't have RUNNING
 *     status.
 */
@Override
public void ensureRunningStatus(Workspace workspace) throws IllegalStateException {
 if (workspace.getStatus() != WorkspaceStatus.RUNNING) {
  throw new IllegalStateException(
    format(
      "Workspace with id='%s' should has '%s' status, but its actual state='%s'",
      workspace.getId(), WorkspaceStatus.RUNNING, workspace.getStatus()));
 }
}

代码示例来源:origin: org.eclipse.che.selenium/che-selenium-core

@Override
@Nullable
public String getId() throws ExecutionException, InterruptedException {
 if (future == null) {
  try {
   Workspace wsConfig = testWorkspaceServiceClient.getByName(name, owner.getName());
   id.set(wsConfig.getId());
   return id.get();
  } catch (Exception e) {
   String errorMessage =
     format("Failed to obtain id of workspace name='%s' owner='%s'", name, owner.getName());
   LOG.warn(errorMessage, e);
   return null;
  }
 }
 return future.thenApply(aVoid -> id.get()).get();
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace

/** Returns 'rel -> url' map of links for the given workspace. */
public Map<String, String> genLinks(Workspace workspace, ServiceContext serviceContext)
  throws ServerException {
 final UriBuilder uriBuilder = serviceContext.getServiceUriBuilder();
 final LinkedHashMap<String, String> links = new LinkedHashMap<>();
 links.put(
   LINK_REL_SELF,
   uriBuilder
     .clone()
     .path(WorkspaceService.class, "getByKey")
     .build(workspace.getId())
     .toString());
 links.put(
   LINK_REL_IDE_URL,
   uriBuilder
     .clone()
     .replacePath("")
     .path(workspace.getNamespace())
     .path(workspace.getConfig().getName())
     .build()
     .toString());
 if (workspace.getStatus() != WorkspaceStatus.STOPPED) {
  addRuntimeLinks(links, workspace.getId(), serviceContext);
 }
 return links;
}

代码示例来源:origin: org.eclipse.che.selenium/che-selenium-core

String workspaceId = ws.getId();
LOG.info(
  format("Workspace with name='%s' id='%s' is starting...", name, workspaceId));
   "Workspace name='{}' id='{}' started in {} sec.",
   name,
   ws.getId(),
   (System.currentTimeMillis() - start) / 1000);

代码示例来源:origin: org.eclipse.che.multiuser/che-multiuser-permission-workspace

@Override
 public void onEvent(WorkspaceCreatedEvent event) {
  try {
   workerDao.store(
     new WorkerImpl(
       event.getWorkspace().getId(),
       EnvironmentContext.getCurrent().getSubject().getUserId(),
       new ArrayList<>(new WorkspaceDomain().getAllowedActions())));
  } catch (ServerException e) {
   LOG.error(
     "Can't add creator's permissions for workspace with id '"
       + event.getWorkspace().getId()
       + "'",
     e);
  }
 }
}

代码示例来源:origin: org.eclipse.che.selenium/che-selenium-core

requestFactory.fromUrl(getIdBasedUrl(workspace.getId())).useDeleteMethod().request();
      format(
        "Error of waiting on workspace name='%s', id='%s', username='%s' removal.",
        workspaceName, workspace.getId(), userName),
      e);
  "Workspace name='{}', id='{}', username='{}' removed",
  workspaceName,
  workspace.getId(),
  userName);

代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace

public WorkspaceImpl(Workspace workspace, Account account) {
 this(
   workspace.getId(),
   account,
   workspace.getConfig(),
   workspace.getRuntime(),
   workspace.getAttributes(),
   workspace.isTemporary(),
   workspace.getStatus());
}

代码示例来源:origin: org.eclipse.che.selenium/che-selenium-core

/** Sends stop workspace request. */
private void sendStopRequest(String workspaceName, String userName) throws Exception {
 if (!exists(workspaceName, userName)) {
  return;
 }
 Workspace workspace = getByName(workspaceName, userName);
 String apiUrl = getIdBasedUrl(workspace.getId()) + "/runtime/";
 requestFactory.fromUrl(apiUrl).useDeleteMethod().request();
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace

public CompletableFuture<Void> stopAsync(Workspace workspace, Map<String, String> options)
  throws NotFoundException, ConflictException {
 String workspaceId = workspace.getId();
 WorkspaceStatus status = statuses.get(workspaceId);
 if (status == null) {
   workspace.getNamespace(),
   workspace.getConfig().getName(),
   workspace.getId(),
   stoppedBy);
 publishWorkspaceStatusEvent(workspaceId, STOPPING, status, options.get(WORKSPACE_STOP_REASON));

代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace

@Override
public void run() {
 String workspaceId = workspace.getId();

代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace

@Override
public void run() {
 String workspaceId = workspace.getId();
 try {
  runtime.start(options);

代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace

runtime = infra.prepare(identity, internalEnv).getRuntime();
WorkspaceStatus runtimeStatus = runtime.getStatus();
try (Unlocker ignored = lockService.writeLock(workspace.getId())) {
 statuses.replace(identity.getWorkspaceId(), runtimeStatus);
 runtimes.putIfAbsent(identity.getWorkspaceId(), runtime);

代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace

throws ConflictException, NotFoundException, ServerException {
final String workspaceId = workspace.getId();
   workspace.getNamespace(),
   workspaceConfig.getName(),
   workspace.getId(),
   sessionUserNameOr("undefined"));

代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace

private WorkspaceDto asDtoWithLinksAndToken(Workspace workspace) throws ServerException {
 WorkspaceDto workspaceDto =
   asDto(workspace).withLinks(linksGenerator.genLinks(workspace, getServiceContext()));
 RuntimeDto runtimeDto = workspaceDto.getRuntime();
 if (runtimeDto != null) {
  try {
   runtimeDto.setMachineToken(machineTokenProvider.getToken(workspace.getId()));
  } catch (MachineAccessForbidden e) {
   // set runtime to null since user doesn't have the required permissions
   workspaceDto.setRuntime(null);
  } catch (MachineTokenException e) {
   throw new ServerException(e.getMessage(), e);
  }
 }
 return workspaceDto;
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace

/** Converts {@link Workspace} to {@link WorkspaceDto}. */
public static WorkspaceDto asDto(Workspace workspace) {
 WorkspaceDto workspaceDto =
   newDto(WorkspaceDto.class)
     .withId(workspace.getId())
     .withStatus(workspace.getStatus())
     .withNamespace(workspace.getNamespace())
     .withTemporary(workspace.isTemporary())
     .withAttributes(workspace.getAttributes())
     .withConfig(asDto(workspace.getConfig()));
 if (workspace.getRuntime() != null) {
  RuntimeDto runtime = asDto(workspace.getRuntime());
  workspaceDto.setRuntime(runtime);
 }
 return workspaceDto;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com