• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ServerException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.che.api.core.ServerException的典型用法代码示例。如果您正苦于以下问题:Java ServerException类的具体用法?Java ServerException怎么用?Java ServerException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServerException类属于org.eclipse.che.api.core包,在下文中一共展示了ServerException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getPullRequests

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
/**
 * Returns the list of active pull request in given repository. Generates html url for each pull
 * requests
 *
 * @param repositoryId the id of the repository
 * @throws IOException when any io error occurs
 * @throws ServerException when server responds with unexpected code
 * @throws UnauthorizedException when user in not authorized to call this method
 */
public List<MicrosoftPullRequest> getPullRequests(
    String account, String collection, String project, String repository, String repositoryId)
    throws IOException, ServerException, UnauthorizedException {
  return doGet(
          templates.pullRequestsUrl(account, collection, repositoryId),
          MicrosoftPullRequestList.class)
      .getValue()
      .stream()
      .peek(
          pr ->
              pr.setHtmlUrl(
                  templates.pullRequestHtmlUrl(
                      account,
                      collection,
                      project,
                      repository,
                      String.valueOf(pr.getPullRequestId()))))
      .collect(Collectors.toList());
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:29,代码来源:MicrosoftVstsRestClient.java


示例2: onCreateProject

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Override
public void onCreateProject(
    Path projectPath, Map<String, AttributeValue> attributes, Map<String, String> options)
    throws ForbiddenException, ConflictException, ServerException {

  VirtualFileSystem vfs = virtualFileSystemProvider.getVirtualFileSystem();
  FolderEntry baseFolder = new FolderEntry(vfs.getRoot().createFolder(projectPath.toString()));

  try (InputStream packageJson =
          getClass().getClassLoader().getResourceAsStream("files/default_package");
      InputStream personJson =
          getClass().getClassLoader().getResourceAsStream("files/default_person")) {
    FolderEntry myJsonFiles = baseFolder.createFolder("myJsonFiles");
    baseFolder.createFile(FILE_NAME, packageJson);
    myJsonFiles.createFile("person.json", personJson);
  } catch (IOException ioEx) {
    throw new ServerException(ioEx.getLocalizedMessage(), ioEx);
  }
}
 
开发者ID:eclipse,项目名称:che-archetypes,代码行数:20,代码来源:JsonExampleCreateProjectHandler.java


示例3: countLinesPerFile

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
/**
 * Count LOC for all JSON files within the given project.
 *
 * @param projectPath the path to the project that contains the JSON files for which to calculate
 *     the LOC
 * @return a Map mapping the file name to their respective LOC value
 * @throws ServerException in case the server encounters an error
 * @throws NotFoundException in case the project couldn't be found
 * @throws ForbiddenException in case the operation is forbidden
 */
@GET
@Path("{projectPath}")
public Map<String, String> countLinesPerFile(@PathParam("projectPath") String projectPath)
    throws ServerException, NotFoundException, ForbiddenException {

  Map<String, String> linesPerFile = new LinkedHashMap<>();
  RegisteredProject project = projectManager.getProject(projectPath);

  for (FileEntry child : project.getBaseFolder().getChildFiles()) {
    if (isJsonFile(child)) {
      linesPerFile.put(child.getName(), Integer.toString(countLines(child)));
    }
  }

  return linesPerFile;
}
 
开发者ID:eclipse,项目名称:che-archetypes,代码行数:27,代码来源:JsonLocService.java


示例4: getCurrentUser

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
/**
 * Get current user
 *
 * @return the current user or null if an error occurred during the call to 'getCurrent'
 * @throws org.eclipse.che.api.core.ServerException
 */
public UserDto getCurrentUser() throws ServerException {
  String url =
      fromUri(baseUrl)
          .path(UserService.class)
          .path(UserService.class, "getCurrent")
          .build()
          .toString();
  UserDto user;
  HttpJsonRequest httpJsonRequest = httpJsonRequestFactory.fromUrl(url).useGetMethod();
  try {
    HttpJsonResponse response = httpJsonRequest.request();
    user = response.asDto(UserDto.class);

  } catch (IOException | ApiException e) {
    LOG.error(e.getLocalizedMessage(), e);
    throw new ServerException(e.getLocalizedMessage());
  }
  return user;
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:26,代码来源:UserConnection.java


示例5: getInitiatorInfo

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@VisibleForTesting
String getInitiatorInfo(String initiatorId) throws ServerException {
  User initiator;
  Profile initiatorProfile;
  try {
    initiator = userManager.getById(initiatorId);
    initiatorProfile = profileManager.getById(initiatorId);
  } catch (NotFoundException e) {
    throw new ServerException(e.getLocalizedMessage(), e);
  }

  Map<String, String> profileAttributes = initiatorProfile.getAttributes();
  String firstName = nullToEmpty(profileAttributes.get("firstName"));
  String lastName = nullToEmpty(profileAttributes.get("lastName"));

  if (firstName.isEmpty() || lastName.isEmpty()) {
    return initiator.getEmail();
  } else {
    return firstName + " " + lastName;
  }
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:22,代码来源:EmailInviteSender.java


示例6: invite

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@POST
@Consumes(APPLICATION_JSON)
@ApiOperation(
  value = "Invite unregistered user by email " + "or update permissions for already invited user",
  notes = "Invited user will receive email notification only on invitation creation"
)
@ApiResponses({
  @ApiResponse(code = 204, message = "The invitation successfully created/updated"),
  @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"),
  @ApiResponse(code = 409, message = "User with specified email is already registered"),
  @ApiResponse(code = 500, message = "Internal server error occurred")
})
public void invite(@ApiParam(value = "The invite to store", required = true) InviteDto inviteDto)
    throws BadRequestException, NotFoundException, ConflictException, ServerException {
  checkArgument(inviteDto != null, "Invite required");
  checkArgument(!isNullOrEmpty(inviteDto.getEmail()), "Email required");
  checkArgument(!isNullOrEmpty(inviteDto.getDomainId()), "Domain id required");
  checkArgument(!isNullOrEmpty(inviteDto.getInstanceId()), "Instance id required");
  checkArgument(!inviteDto.getActions().isEmpty(), "One or more actions required");
  emailValidator.validateUserMail(inviteDto.getEmail());

  inviteManager.store(inviteDto);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:24,代码来源:InviteService.java


示例7: launch

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Override
public void launch(Instance machine, Agent agent) throws ServerException, AgentStartException {
  super.launch(machine, agent);

  DockerNode node = (DockerNode) machine.getNode();
  DockerInstance dockerMachine = (DockerInstance) machine;
  try {
    node.bindWorkspace();
  } catch (EnvironmentException e) {
    throw new AgentStartException(
        format(
            "Agent '%s' start failed because of an error with underlying environment. Error: %s",
            agent.getId(), e.getLocalizedMessage()));
  }
  LOG.info(
      "Docker machine has been deployed. "
          + "ID '{}'. Workspace ID '{}'. "
          + "Container ID '{}'. Node host '{}'. Node IP '{}'",
      machine.getId(),
      machine.getWorkspaceId(),
      dockerMachine.getContainer(),
      node.getHost(),
      node.getIp());
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:25,代码来源:MachineInnerRsyncAgentLauncherImpl.java


示例8: checkContainerIsRunning

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Override
protected void checkContainerIsRunning(String container) throws IOException, ServerException {
  // Sometimes Swarm doesn't see newly created containers for several seconds.
  // Here we retry operation to ensure that such behavior of Swarm doesn't affect the product.
  try {
    super.checkContainerIsRunning(container);
  } catch (ContainerNotFoundException e) {
    try {
      Thread.sleep(SWARM_WAIT_BEFORE_REPEAT_WORKAROUND_TIME_MS);
      super.checkContainerIsRunning(container);
    } catch (InterruptedException ignored) {
      // throw original error
      throw e;
    }
  }
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:17,代码来源:HostedMachineProviderImpl.java


示例9: getRepositoryForks

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Override
public List<BitbucketRepository> getRepositoryForks(String owner, String repositorySlug)
    throws IOException, BitbucketException, ServerException, IllegalArgumentException {
  final List<BitbucketRepository> repositories = new ArrayList<>();
  BitbucketServerRepositoriesPage repositoriesPage = null;

  do {
    final String url =
        urlTemplates.forksUrl(owner, repositorySlug)
            + (repositoriesPage != null
                ? "?start=" + valueOf(repositoriesPage.getNextPageStart())
                : "");
    repositoriesPage = getBitbucketPage(this, url, BitbucketServerRepositoriesPage.class);
    repositories.addAll(
        repositoriesPage
            .getValues()
            .stream()
            .map(BitbucketServerDTOConverter::convertToBitbucketRepository)
            .collect(Collectors.toList()));
  } while (!repositoriesPage.isIsLastPage());

  return repositories;
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:24,代码来源:BitbucketServerConnectionImpl.java


示例10: createPingRequest

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Override
protected HttpJsonRequest createPingRequest(Machine devMachine) throws ServerException {
  final HttpJsonRequest pingRequest = super.createPingRequest(devMachine);
  final String tokenServiceUrl =
      UriBuilder.fromUri(apiEndpoint)
          .replacePath("api/machine/token/" + devMachine.getWorkspaceId())
          .build()
          .toString();
  String machineToken = null;
  try {
    machineToken =
        httpJsonRequestFactory
            .fromUrl(tokenServiceUrl)
            .setMethod(HttpMethod.GET)
            .request()
            .asDto(MachineTokenDto.class)
            .getMachineToken();
  } catch (ApiException | IOException ex) {
    LOG.warn("Failed to get machine token", ex);
  }
  return machineToken == null ? pingRequest : pingRequest.setAuthorizationHeader(machineToken);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:23,代码来源:WsAgentHealthCheckerWithAuth.java


示例11: backupShouldThrowErrorIfMachineDoesNotContainServerWithSshPort

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Test(
  expectedExceptions = ServerException.class,
  expectedExceptionsMessageRegExp =
      "Sync port is not exposed in ws-machine. Workspace projects syncing is not possible"
)
public void backupShouldThrowErrorIfMachineDoesNotContainServerWithSshPort() throws Exception {
  // given
  when(machineRuntimeInfo.getServers())
      .thenReturn(
          singletonMap(
              "23/tcp",
              new ServerImpl("ref", "proto", "127.0.0.1:" + PUBLISHED_SSH_PORT, null, null)));

  backupManager.backupWorkspace(WORKSPACE_ID);

  // when
  backupManager.backupWorkspace(WORKSPACE_ID);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:19,代码来源:DockerEnvironmentBackupManagerTest.java


示例12: restoreWorkspaceBackup

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
/**
 * Copy files of workspace from backups storage into container.
 *
 * @param workspaceId id of workspace to backup
 * @param containerId id of container where data should be copied
 * @param nodeHost host of a node where container is running
 * @throws EnvironmentException if restore failed due to abnormal state of machines in environment
 * @throws ServerException if any error occurs
 */
public void restoreWorkspaceBackup(String workspaceId, String containerId, String nodeHost)
    throws ServerException, EnvironmentException {
  try {
    String srcPath =
        workspaceIdHashLocationFinder.calculateDirPath(backupsRootDir, workspaceId).toString();
    User user = getUserInfo(workspaceId, containerId);
    int syncPort = getSyncPort(containerId);

    restoreBackupInsideLock(
        workspaceId,
        srcPath,
        projectFolderPath,
        user.id,
        user.groupId,
        user.name,
        nodeHost,
        syncPort);
  } catch (IOException e) {
    LOG.error(e.getLocalizedMessage(), e);
    throw new ServerException(
        format(
            "Can't restore file system of workspace %s in container %s",
            workspaceId, containerId));
  }
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:35,代码来源:DockerEnvironmentBackupManager.java


示例13: getRepositoryForks

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Override
public List<BitbucketRepository> getRepositoryForks(String owner, String repositorySlug)
    throws IOException, BitbucketException, ServerException {
  final List<BitbucketRepository> repositories = new ArrayList<>();
  BitbucketRepositoriesPage repositoryPage = newDto(BitbucketRepositoriesPage.class);

  do {
    final String nextPageUrl = repositoryPage.getNext();
    final String url =
        nextPageUrl == null ? urlTemplates.forksUrl(owner, repositorySlug) : nextPageUrl;

    repositoryPage = getBitbucketPage(this, url, BitbucketRepositoriesPage.class);
    repositories.addAll(repositoryPage.getValues());
  } while (repositoryPage.getNext() != null);

  return repositories;
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:18,代码来源:BitbucketConnectionImpl.java


示例14: storePullRequestUpdatedWebhook

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
/**
 * Store a 'pull request updated' webhook in webhooks property file. If a webhook with same id
 * already exist it will be replaced.
 *
 * @param pruWebhook the webhook to store in webhooks property file
 * @throws ServerException
 */
private void storePullRequestUpdatedWebhook(final PullRequestUpdatedWebhook pruWebhook)
    throws ServerException {
  final Set<String> factoriesIDs = pruWebhook.getFactoriesIds();
  String propertyValue =
      String.format(
          "%s,%s,%s,%s,%s,%s,%s",
          PULL_REQUEST_UPDATED_WEBHOOK.toString(),
          pruWebhook.getHost(),
          pruWebhook.getAccount(),
          pruWebhook.getCollection(),
          pruWebhook.getApiVersion(),
          pruWebhook.getCredentials().first,
          pruWebhook.getCredentials().second);

  if (factoriesIDs.size() > 0) {
    final String concatedFactoriesIDs = String.join(";", factoriesIDs);
    propertyValue = propertyValue + "," + concatedFactoriesIDs;
  }

  storeProperty(pruWebhook.getId(), propertyValue, VSTS_WEBHOOKS_PROPERTIES_FILENAME);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:29,代码来源:VSTSWebhookService.java


示例15: getFactoriesForRepositoryAndBranch

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
/**
 * Get factories that contain a project for given repository and branch
 *
 * @param factoryIDs the set of id's of factories to check
 * @param headRepositoryUrl repository that factory project must match
 * @param headBranch branch that factory project must match
 * @return list of factories that contain a project for given repository and branch
 */
protected List<FactoryDto> getFactoriesForRepositoryAndBranch(
    final Set<String> factoryIDs,
    final String headRepositoryUrl,
    final String headBranch,
    final CloneUrlMatcher matcher)
    throws ServerException {
  List<FactoryDto> factories = new ArrayList<>();
  for (String factoryID : factoryIDs) {
    factories.add(factoryConnection.getFactory(factoryID));
  }

  return factories
      .stream()
      .filter(
          f ->
              (f != null)
                  && (f.getWorkspace()
                      .getProjects()
                      .stream()
                      .anyMatch(
                          p -> matcher.isCloneUrlMatching(p, headRepositoryUrl, headBranch))))
      .collect(toList());
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:32,代码来源:BaseWebhookService.java


示例16: shouldThrowExceptionWhenStartRestoreIfBackupHasNotFinishedYet

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Test(timeOut = 2_000 * 60) // 2 minutes
public void shouldThrowExceptionWhenStartRestoreIfBackupHasNotFinishedYet() throws Exception {
  // given
  injectWorkspaceLock(WORKSPACE_ID);
  ThreadFreezer backupFreezer = startNewProcessAndFreeze(this::runBackup);

  // when
  try {
    backupManager.restoreWorkspaceBackup(WORKSPACE_ID, CONTAINER_ID, NODE_HOST);
    fail("Restore should not be performed while backup is in progress");
  } catch (ServerException ignore) {
  }

  backupFreezer.unfreeze();
  awaitFinalization();

  // then
  verify(backupManager, times(1))
      .executeCommand(
          cmdCaptor.capture(),
          anyInt(),
          nullable(String.class),
          nullable(String.class),
          anySetOf(Integer.class));
  assertEquals(cmdCaptor.getValue()[0], BACKUP_SCRIPT);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:27,代码来源:DockerEnvironmentBackupManagerTest.java


示例17: shouldReturnAuditReportWithoutUserWorkspacesIfFailedToRetrieveTheListOfHisWorkspaces

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Test
public void shouldReturnAuditReportWithoutUserWorkspacesIfFailedToRetrieveTheListOfHisWorkspaces()
    throws Exception {
  // given
  when(workspaceManager.getWorkspaces(eq("User1Id"), eq(false)))
      .thenThrow(new ServerException("Failed to retrieve workspaces"));

  // when
  auditReport = auditManager.generateAuditReport();

  // then
  assertEquals(
      readFileToString(auditReport.toFile()),
      "Number of users: 2\n"
          + "[ERROR] Failed to retrieve the list of related workspaces for user User1Id!\n"
          + "[email protected] is owner of 1 workspace and has permissions in 1 workspace\n"
          + "   └ Workspace2Name, is owner: true, permissions: [read, use, run, configure, setPermissions, delete]\n");
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:19,代码来源:AuditManagerTest.java


示例18: saveFactory

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
/**
 * Save a new factory
 *
 * @param factory the factory to create
 * @return the created factory or null if an error occurred during the call to 'saveFactory'
 * @throws ServerException
 */
public FactoryDto saveFactory(final FactoryDto factory) throws ServerException {
  final String url = fromUri(baseUrl).path(FactoryService.class).build().toString();
  FactoryDto newFactory;
  HttpJsonRequest httpJsonRequest =
      httpJsonRequestFactory.fromUrl(url).usePostMethod().setBody(factory);
  try {
    HttpJsonResponse response = httpJsonRequest.request();
    newFactory = response.asDto(FactoryDto.class);

  } catch (IOException | ApiException e) {
    LOG.error(e.getLocalizedMessage(), e);
    throw new ServerException(e.getLocalizedMessage());
  }
  return newFactory;
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:23,代码来源:FactoryConnection.java


示例19: throwsServerExceptionWhenAnyInternalServerErrorOccur

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Test
public void throwsServerExceptionWhenAnyInternalServerErrorOccur() throws Exception {
  final String errMsg = "server error";
  when(userManager.getByEmailPart(nullable(String.class), anyInt(), anyLong()))
      .thenThrow(new ServerException(errMsg));
  final Response response =
      given()
          .auth()
          .basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
          .when()
          .expect()
          .statusCode(500)
          .get(SECURE_PATH + "/admin/user/[email protected]");

  final String actual =
      DtoFactory.getInstance()
          .createDtoFromJson(response.body().print(), ServiceError.class)
          .getMessage();
  assertEquals(actual, errMsg);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:21,代码来源:AdminUserServiceTest.java


示例20: updatePullRequest

import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@PUT
@Path("/pullrequests/{account}/{collection}/{project}/{repository}/{pullRequest}")
@Consumes(APPLICATION_JSON)
public MicrosoftPullRequest updatePullRequest(
    @PathParam("account") String account,
    @PathParam("collection") String collection,
    @PathParam("project") String project,
    @PathParam("repository") String repository,
    @PathParam("pullRequest") String pullRequestId,
    MicrosoftPullRequest pullRequest)
    throws IOException, ServerException, UnauthorizedException {
  final String repositoryId =
      microsoftVstsRestClient.getRepository(account, collection, project, repository).getId();
  return microsoftVstsRestClient.updatePullRequests(
      account, collection, repositoryId, pullRequestId, pullRequest);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:17,代码来源:MicrosoftVstsService.java



注:本文中的org.eclipse.che.api.core.ServerException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SharePatchFileUtil类代码示例发布时间:2022-05-22
下一篇:
Java ReactInstanceDevCommandsHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap