Java 类javax.ws.rs.ClientErrorException 实例源码

项目:device-modbus    文件:Scheduler.java   
public void addDefaultSchedules() {     

    for (int i = 0; i < defaultSchedules.getSize(); i++) {
        String name = defaultSchedules.getName()[i];
        String start = defaultSchedules.getStart()[i];
        String end = defaultSchedules.getEnd()[i];
        String frequency = defaultSchedules.getFrequency()[i];
        String cron = defaultSchedules.getCron()[i];
        Boolean runOnce = Boolean.valueOf(defaultSchedules.getRunOnce()[i]);

        Schedule schedule = new Schedule(name, start, end, frequency, cron, runOnce);

        try {
            scheduleClient.add(schedule);
        } catch (ClientErrorException e) {
            // Ignore if the schedule is already present
            // schedule.setId(scheduleClient.scheduleForName(name).getId());
            // scheduleClient.update(schedule);
        }
    }

}
项目:oscm    文件:RestNotificationServiceAdapter.java   
@Override
public void onUnsubscribeFromProduct(VOTriggerProcess triggerProcess,
        String subId) {

    try {
        TriggerProcess process = ds.getReference(TriggerProcess.class,
                triggerProcess.getKey());

        Query q = ds.createNamedQuery("Subscription.findByBusinessKey");

        q.setParameter("subscriptionId", subId);
        q.setParameter("organizationKey", new Long(process
                .getTriggerDefinition().getOrganization().getKey()));

        Subscription sub = (Subscription) q.getSingleResult();

        Product prod = sub.getProduct();

        handleRequest(process, sub, prod);

    } catch (ObjectNotFoundException | ClientErrorException e) {
        throw new SaaSSystemException(
                "Failed to send notification to rest endpoint");
    }
}
项目:device-opcua-java    文件:Scheduler.java   
public void addDefaultSchedules() {

    for (int i = 0; i < defaultSchedules.getSize(); i++) {
      String name = defaultSchedules.getName()[i];
      String start = defaultSchedules.getStart()[i];
      String end = defaultSchedules.getEnd()[i];
      String frequency = defaultSchedules.getFrequency()[i];
      String cron = defaultSchedules.getCron()[i];
      Boolean runOnce = Boolean.valueOf(defaultSchedules.getRunOnce()[i]);
      Schedule schedule = new Schedule(name, start, end, frequency, cron, runOnce);

      try {
        scheduleClient.add(schedule);
      } catch (ClientErrorException e) {
        // Ignore if the schedule is already present
        // schedule.setId(scheduleClient.scheduleForName(name).getId());
        // scheduleClient.update(schedule);
      }
    }

  }
项目:device-bacnet    文件:Scheduler.java   
public void addDefaultSchedules() {

    for (int i = 0; i < defaultSchedules.getSize(); i++) {
      String name = defaultSchedules.getName()[i];
      String start = defaultSchedules.getStart()[i];
      String end = defaultSchedules.getEnd()[i];
      String frequency = defaultSchedules.getFrequency()[i];
      String cron = defaultSchedules.getCron()[i];
      Boolean runOnce = Boolean.valueOf(defaultSchedules.getRunOnce()[i]);

      Schedule schedule = new Schedule(name, start, end, frequency, cron, runOnce);

      try {
        scheduleClient.add(schedule);
      } catch (ClientErrorException e) {
        // Ignore if the schedule is already present
        // schedule.setId(scheduleClient.scheduleForName(name).getId());
        // scheduleClient.update(schedule);
      }
    }

  }
项目:opencps-v2    文件:KPRest.java   
public String QuerryBillStatus(String merchant_trans_id, String good_code, String trans_id, String merchant_code, String secure_hash) throws ClientErrorException {
    WebTarget resource = webTarget;
    if (merchant_code != null) {
        resource = resource.queryParam("merchant_code", merchant_code);
    }
    if (good_code != null) {
        resource = resource.queryParam("good_code", good_code);
    }
    if (merchant_trans_id != null) {
        resource = resource.queryParam("merchant_trans_id", merchant_trans_id);
    }
    if (secure_hash != null) {
        resource = resource.queryParam("secure_hash", secure_hash);
    }
    if (trans_id != null) {
        resource = resource.queryParam("trans_id", trans_id);
    }
    resource = resource.path("QuerryBillStatus");
    return resource.request(javax.ws.rs.core.MediaType.TEXT_PLAIN).get(String.class);
}
项目:opencps-v2    文件:KPJsonRest.java   
public String QuerryBillStatus(String merchant_trans_id, String good_code, String trans_id, String merchant_code,
        String secure_hash) throws ClientErrorException {
    WebTarget resource = webTarget;
    if (merchant_code != null) {
        resource = resource.queryParam("merchant_code", merchant_code);
    }
    if (good_code != null) {
        resource = resource.queryParam("good_code", good_code);
    }
    if (merchant_trans_id != null) {
        resource = resource.queryParam("merchant_trans_id", merchant_trans_id);
    }
    if (secure_hash != null) {
        resource = resource.queryParam("secure_hash", secure_hash);
    }
    if (trans_id != null) {
        resource = resource.queryParam("trans_id", trans_id);
    }
    resource = resource.path("QuerryBillStatus");
    return resource.request(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(String.class);
}
项目:Biliomi    文件:ExceptionResponseMapper.java   
@Override
public Response toResponse(Throwable throwable) {

  // IF this is a client error simply pas through the original response
  if (throwable instanceof ClientErrorException) {
    return ((ClientErrorException) throwable).getResponse();
  } else if (BiliomiContainer.getParameters().isDebugMode())  {
    ServerErrorResponse response = new ServerErrorResponse();

    response.setErrorMessage(throwable.getMessage());

    if (throwable.getCause() != null) {
      response.setCausedBy(throwable.getCause().getMessage());
    }

    return Responses.serverError(response);
  } else {
    return Responses.serverError();
  }
}
项目:device-mqtt    文件:Scheduler.java   
public void addDefaultSchedules() {

    for (int i = 0; i < defaultSchedules.getSize(); i++) {
      String name = defaultSchedules.getName()[i];
      String start = defaultSchedules.getStart()[i];
      String end = defaultSchedules.getEnd()[i];
      String frequency = defaultSchedules.getFrequency()[i];
      String cron = defaultSchedules.getCron()[i];
      Boolean runOnce = Boolean.valueOf(defaultSchedules.getRunOnce()[i]);
      Schedule schedule = new Schedule(name, start, end, frequency, cron, runOnce);

      try {
        scheduleClient.add(schedule);
      } catch (ClientErrorException e) {
        // Ignore if the schedule is already present
        // schedule.setId(scheduleClient.scheduleForName(name).getId());
        // scheduleClient.update(schedule);
      }
    }

  }
项目:device-bluetooth    文件:Scheduler.java   
public void addDefaultSchedules() {

    for (int i = 0; i < defaultSchedules.getSize(); i++) {
      String name = defaultSchedules.getName()[i];
      String start = defaultSchedules.getStart()[i];
      String end = defaultSchedules.getEnd()[i];
      String frequency = defaultSchedules.getFrequency()[i];
      String cron = defaultSchedules.getCron()[i];
      Boolean runOnce = Boolean.valueOf(defaultSchedules.getRunOnce()[i]);
      Schedule schedule = new Schedule(name, start, end, frequency, cron, runOnce);

      try {
        scheduleClient.add(schedule);
      } catch (ClientErrorException e) {
        // Ignore if the schedule is already present
        // schedule.setId(scheduleClient.scheduleForName(name).getId());
        // scheduleClient.update(schedule);
      }
    }

  }
项目:TranskribusSwtGui    文件:ThumbnailManager.java   
private void changeVersionStatus(String text){
    Storage storage = Storage.getInstance();
    String pages = getPagesString();

    String[] pageList = pages.split(",");

    if (!pages.equals("") && pageList.length >= 1){

        for (String page : pageList){
            int pageNr = Integer.valueOf(page);
            int colId = storage.getCurrentDocumentCollectionId();
            int docId = storage.getDocId();
            int transcriptId = storage.getPage().getCurrentTranscript().getTsId();
            try {
                storage.getConnection().updatePageStatus(colId, docId, pageNr, transcriptId, EditStatus.fromString(text), "test");
            } catch (SessionExpiredException | ServerErrorException | ClientErrorException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

}
项目:TranskribusSwtGui    文件:OAuthGuiUtil.java   
public static void revokeOAuthToken(final String refreshToken, final OAuthProvider prov) throws IOException{

    final String uriStr;
    switch (prov) {
    case Google:
        uriStr = "https://accounts.google.com/o/oauth2/revoke?token=";
        break;
    default:
        throw new IOException("Unknown OAuth Provider: " + prov);
    }

    CloseableHttpClient client = HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier()).build();       
    HttpGet get = new HttpGet(uriStr + refreshToken);
    HttpResponse response = client.execute(get);
    final int status = response.getStatusLine().getStatusCode();        
    if (status != 200) {
        String reason = response.getStatusLine().getReasonPhrase();
        logger.error(reason);
        throw new ClientErrorException(reason, status);
    }
}
项目:microbule    文件:AbstractErrorResponseStrategyTest.java   
@Test
public void testCreateException() {
    assertExceptionType(Response.Status.INTERNAL_SERVER_ERROR, InternalServerErrorException.class);
    assertExceptionType(Response.Status.NOT_FOUND, NotFoundException.class);
    assertExceptionType(Response.Status.FORBIDDEN, ForbiddenException.class);
    assertExceptionType(Response.Status.BAD_REQUEST, BadRequestException.class);
    assertExceptionType(Response.Status.METHOD_NOT_ALLOWED, NotAllowedException.class);
    assertExceptionType(Response.Status.UNAUTHORIZED, NotAuthorizedException.class);
    assertExceptionType(Response.Status.NOT_ACCEPTABLE, NotAcceptableException.class);
    assertExceptionType(Response.Status.UNSUPPORTED_MEDIA_TYPE, NotSupportedException.class);
    assertExceptionType(Response.Status.SERVICE_UNAVAILABLE, ServiceUnavailableException.class);
    assertExceptionType(Response.Status.TEMPORARY_REDIRECT, RedirectionException.class);
    assertExceptionType(Response.Status.LENGTH_REQUIRED, ClientErrorException.class);
    assertExceptionType(Response.Status.BAD_GATEWAY, ServerErrorException.class);
    assertExceptionType(Response.Status.NO_CONTENT, WebApplicationException.class);
}
项目:jcronofy    文件:CronofyClientImplTest.java   
/**
 * When client error exception has been thrown
 */
@Test
public void testCreateNotificationChannelScenario4() {
    resetAll();
    // test data
    final CreateNotificationChannelRequest request = getHelper().getCreateNotificationChannelRequest();
    final CronofyResponse<CreateNotificationChannelResponse> expectedResponse = new CronofyResponse<>(
            ErrorTypeModel.UNPROCESSABLE
    );
    // expectations
    expect(client.target(BASE_PATH)).andThrow(new ClientErrorException(Response.Status.CONFLICT));
    replayAll();
    final CronofyResponse<CreateNotificationChannelResponse> result = cronofyClient.createNotificationChannel(request);
    getHelper().assertResultResponse(expectedResponse, result);
    verifyAll();
}
项目:jcronofy    文件:CronofyClientImplTest.java   
/**
 * When client error exception has been thrown
 */
@Test
public void testListCalendarsScenario5() {
    resetAll();
    // test data
    final ListCalendarsRequest request = getHelper().getListCalendarsRequest();
    final CronofyResponse<ListCalendarsResponse> expectedResponse = new CronofyResponse<>(
            ErrorTypeModel.UNPROCESSABLE
    );
    // expectations
    expect(client.target(BASE_PATH)).andThrow(new ClientErrorException(Response.Status.CONFLICT));
    replayAll();
    final CronofyResponse<ListCalendarsResponse> result = cronofyClient.listCalendars(request);
    getHelper().assertResultResponse(expectedResponse, result);
    verifyAll();
}
项目:TranskribusSwtGui    文件:Storage.java   
public List<String> analyzeLayoutOnCurrentTranscript(List<String> regIds, boolean doBlockSeg, boolean doLineSeg, boolean doWordSeg, boolean doPolygonToBaseline, boolean doBaselineToPolygon, String jobImpl, String pars) throws SessionExpiredException, ServerErrorException, ClientErrorException, IllegalArgumentException, NoConnectionException, IOException {
    checkConnection(true);

    if (!isRemoteDoc()) {
        throw new IOException("No remote doc loaded!");
    }
    int colId = getCurrentDocumentCollectionId();

    DocumentSelectionDescriptor dd = new DocumentSelectionDescriptor(getDocId());
    PageDescriptor pd = dd.addPage(getPage().getPageId());
    if (regIds != null && !regIds.isEmpty()) {
        pd.getRegionIds().addAll(regIds);
    }
    pd.setTsId(getTranscriptMetadata().getTsId());

    List<DocumentSelectionDescriptor> dsds = new ArrayList<>();
    dsds.add(dd);

    List<String> jobids = new ArrayList<>();
    List<TrpJobStatus> jobs = conn.analyzeLayout(colId, dsds, doBlockSeg, doLineSeg, doWordSeg, doPolygonToBaseline, doBaselineToPolygon, jobImpl, pars);
    for (TrpJobStatus j : jobs) {
        jobids.add(j.getJobId());
    }

    return jobids;
}
项目:jcronofy    文件:CronofyClientImplTest.java   
/**
 * When client error exception has been thrown
 */
@Test
public void testFreeBusyScenario5() {
    resetAll();
    // test data
    final FreeBusyRequest request = getHelper().getFreeBusyRequest();
    final CronofyResponse<FreeBusyResponse> expectedResponse = new CronofyResponse<>(
            ErrorTypeModel.UNPROCESSABLE
    );
    // expectations
    expect(client.target(BASE_PATH)).andThrow(new ClientErrorException(Response.Status.CONFLICT));
    replayAll();
    final CronofyResponse<FreeBusyResponse> result = cronofyClient.freeBusy(request);
    getHelper().assertResultResponse(expectedResponse, result);
    verifyAll();
}
项目:syndesis    文件:ClientErrorExceptionMapper.java   
@Override
public Response toResponse(final ClientErrorException exception) {
    final Response response = exception.getResponse();

    final RestError error = new RestError(exception.getMessage(), "Given request is not acceptable", null,
        response.getStatus());

    return Response.fromResponse(response).type(MediaType.APPLICATION_JSON_TYPE).entity(error).build();
}
项目:oscm    文件:RestNotificationServiceAdapter.java   
@Override
public void onSubscribeToProduct(VOTriggerProcess triggerProcess,
        VOSubscription subscription, VOService product,
        List<VOUsageLicense> users) {

    try {
        TriggerProcess process = ds.getReference(TriggerProcess.class,
                triggerProcess.getKey());

        Subscription sub = new Subscription();
        sub.setKey(0);
        sub.setSubscriptionId(subscription.getSubscriptionId());

        ParameterSet set = new ParameterSet();

        List<Parameter> params = new ArrayList<Parameter>();

        for (VOParameter vop : product.getParameters()) {
            Parameter p = new Parameter();
            ParameterDefinition pd = new ParameterDefinition();
            pd.setParameterId(vop.getParameterDefinition().getParameterId());
            p.setParameterDefinition(pd);
            p.setValue(vop.getValue());
            params.add(p);
        }
        set.setParameters(params);

        Product prod = new Product();
        prod.setProductId(product.getServiceId());
        prod.setParameterSet(set);

        handleRequest(process, sub, prod);

    } catch (ObjectNotFoundException | ClientErrorException e) {
        throw new SaaSSystemException(
                "Failed to send notification to rest endpoint");
    }
}
项目:oscm    文件:RestNotificationServiceAdapter.java   
@Override
public void onModifySubscription(VOTriggerProcess triggerProcess,
        VOSubscription subscription, List<VOParameter> modifiedParameters) {

    try {
        TriggerProcess process = ds.getReference(TriggerProcess.class,
                triggerProcess.getKey());

        Subscription sub = ds.getReference(Subscription.class,
                subscription.getKey());

        Product prod = new Product();
        prod.setProductId(sub.getProduct().getProductId());

        ParameterSet set = new ParameterSet();

        List<Parameter> params = new ArrayList<Parameter>();

        for (VOParameter vop : modifiedParameters) {
            Parameter p = new Parameter();
            ParameterDefinition pd = new ParameterDefinition();
            pd.setParameterId(vop.getParameterDefinition().getParameterId());
            p.setParameterDefinition(pd);
            p.setValue(vop.getValue());
            params.add(p);
        }
        set.setParameters(params);

        prod.setParameterSet(set);

        handleRequest(process, sub, prod);

    } catch (ObjectNotFoundException | ClientErrorException e) {
        throw new SaaSSystemException(
                "Failed to send notification to rest endpoint");
    }
}
项目:app-ms    文件:JsonExceptionMapper.java   
/**
 * Log the exception if it is not NotFoundException and only use warn if it is a
 * client error.
 *
 * @param exception
 */
private void log(final Throwable exception) {

    if (exception instanceof ClientErrorException) {
        if (!(exception instanceof NotFoundException)) {
            LOG.warn("uri={} message={}", uriInfo.getRequestUri(), exception.getMessage(), exception);
        }
    } else {
        LOG.error("uri={} message={}", uriInfo.getRequestUri(), exception.getMessage(), exception);
    }
}
项目:com-liferay-apio-architect    文件:ClientErrorExceptionConverter.java   
@Override
public APIError convert(ClientErrorException exception) {
    Response response = exception.getResponse();

    int status = response.getStatus();

    return new APIErrorImpl(
        exception, "General server error", "client-error", status);
}
项目:mentor    文件:CourseResource.java   
@DELETE
@Path("{id}")
@Transactional
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response delete(@PathParam("id") UUID id, Course course) {
    if(!id.equals(course.getId()))
        throw new ClientErrorException("Course ID error", 400);
    return Response.status(200).entity(courseProvider.get().delete(course)).build();
}
项目:TranskribusSwtGui    文件:ThumbnailManager.java   
protected void setup_layout_recognition(String pages) throws SessionExpiredException, ServerErrorException, ClientErrorException, IllegalArgumentException, NoConnectionException {
    LayoutAnalysisDialog laD = new LayoutAnalysisDialog(shell);

    laD.create();
    //all selected pages are shown as default and are taken for segmentation
    laD.setPageSelectionToSelectedPages(pages);

    int ret = laD.open();

    if (ret == IDialogConstants.OK_ID) {
        try {
            List<String> jobIds = Storage.getInstance().analyzeLayoutOnLatestTranscriptOfPages(laD.getPages(),
                    laD.isDoBlockSeg(), laD.isDoLineSeg(), laD.isDoWordSeg(), false, false, laD.getJobImpl(), null);

            if (jobIds != null && mw != null) {
                logger.debug("started jobs: "+jobIds.size());
                String jobIdsStr = mw.registerJobsToUpdate(jobIds);             
                Storage.getInstance().sendJobListUpdateEvent();
                mw.updatePageLock();

                DialogUtil.showInfoMessageBox(getShell(), jobIds.size()+ " jobs started", jobIds.size()+ " jobs started\nIDs:\n "+jobIdsStr);
            }
        } catch (Exception e) {
            mw.onError("Error", e.getMessage(), e);
        }
    }
}
项目:syndesis-rest    文件:ClientErrorExceptionMapper.java   
@Override
public Response toResponse(final ClientErrorException exception) {
    final Response response = exception.getResponse();

    final RestError error = new RestError(exception.getMessage(), "Given request is not acceptable", null,
        response.getStatus());

    return Response.fromResponse(response).type(MediaType.APPLICATION_JSON_TYPE).entity(error).build();
}
项目:TranskribusSwtGui    文件:ThumbnailManagerVirtual.java   
protected void setup_layout_recognition(String pages) throws SessionExpiredException, ServerErrorException, ClientErrorException, IllegalArgumentException, NoConnectionException {
    LayoutAnalysisDialog laD = new LayoutAnalysisDialog(shell);

    laD.create();
    //all selected pages are shown as default and are taken for segmentation
    laD.setPageSelectionToSelectedPages(pages);

    int ret = laD.open();

    if (ret == IDialogConstants.OK_ID) {            
        try {
            List<String> jobIds = Storage.getInstance().analyzeLayoutOnLatestTranscriptOfPages(laD.getPages(),
                    laD.isDoBlockSeg(), laD.isDoLineSeg(), laD.isDoWordSeg(), false, false, laD.getJobImpl(), null);

            if (jobIds != null && mw != null) {
                logger.debug("started jobs: "+jobIds.size());
                String jobIdsStr = mw.registerJobsToUpdate(jobIds);             
                Storage.getInstance().sendJobListUpdateEvent();
                mw.updatePageLock();

                DialogUtil.showInfoMessageBox(getShell(), jobIds.size()+ " jobs started", jobIds.size()+ " jobs started\nIDs:\n "+jobIdsStr);
            }
        } catch (Exception e) {
            mw.onError("Error", e.getMessage(), e);
        }           
    }
}
项目:TranskribusSwtGui    文件:HtrModelsComposite.java   
private void updateHtrs() {
    List<TrpHtr> uroHtrs = new ArrayList<>(0);
    try {
        uroHtrs = store.listHtrs("CITlab");
    } catch (SessionExpiredException | ServerErrorException | ClientErrorException | NoConnectionException e1) {
        DialogUtil.showErrorMessageBox(getShell(), "Error", "Could not load HTR model list!");
        logger.error(e1.getMessage(), e1);
        return;
    }

    htw.refreshList(uroHtrs);
}
项目:TranskribusSwtGui    文件:ActivityDialog.java   
/**
     * Create contents of the dialog.
     * @param parent
     */
    @Override protected Control createDialogArea(Composite parent) {
        Composite container = (Composite) super.createDialogArea(parent);
        container.setLayout(new GridLayout(1, true));

        pageLocksGroup = new Group(container, 0);
        pageLocksGroup.setLayout(new FillLayout());
        pageLocksGroup.setText("Opened pages per collection");
        pageLocksGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
        pageLockTable = new PageLockTablePagination(pageLocksGroup, 0, 25);
//      pageLockTable.setLayoutData(new GridData(GridData.FILL_BOTH));

        /*
         * shows the users with a open session in TranskribusX (WebUI, rest service users are not included)
         */
        Label users = new Label(container, 0);
        try {
            int users_nr = Storage.getInstance().getConnection().countUsersLoggedIn();
            String user = ( (users_nr > 0 && users_nr == 1)? "user" : "users");
            users.setText( users_nr + " " + user + " currently working with TranskribusX.");
        } catch (SessionExpiredException | ServerErrorException | ClientErrorException | IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return container;
    }
项目:TranskribusSwtGui    文件:HtrTextRecognitionConfigDialog_Old.java   
private void updateHtrs() {
    List<TrpHtr> uroHtrs = new ArrayList<>(0);
    try {
        uroHtrs = store.listHtrs("CITlab");
    } catch (SessionExpiredException | ServerErrorException | ClientErrorException | NoConnectionException e1) {
        DialogUtil.showErrorMessageBox(this.getParentShell(), "Error", "Could not load HTR model list!");
        logger.error(e1.getMessage(), e1);
        return;
    }

    htw.refreshList(uroHtrs);
}
项目:TranskribusSwtGui    文件:PageLockTablePaginationTest.java   
public static void main(String[] args) throws ClientErrorException, Exception {
        Storage s = Storage.getInstance();
        s.login(TrpServerConn.SERVER_URIS[0], args[0], args[1]);

        ApplicationWindow aw = new ApplicationWindow(null) {
            @Override
            protected Control createContents(Composite parent) {
                // getShell().setLayout(new FillLayout());
                getShell().setSize(600, 600);

                PageLockTablePagination w = new PageLockTablePagination(getShell(), 0, 25);
//              Button btn = new Button(parent, SWT.PUSH);
//              btn.setText("Open upload dialog");
//              btn.addSelectionListener(new SelectionAdapter() {
//                  @Override public void widgetSelected(SelectionEvent e) {
//                      (new UploadDialogUltimate(getShell(), null)).open();
//                  }
//              });

                SWTUtil.centerShell(getShell());

                return parent;
            }
        };
        aw.setBlockOnOpen(true);
        aw.open();

        Display.getCurrent().dispose();
    }
项目:TranskribusSwtGui    文件:KeywordSpottingComposite.java   
/**
         * TODO allow to filter jobs by collection in REST API
         * 
         * @return
         * @throws SessionExpiredException
         * @throws ServerErrorException
         * @throws ClientErrorException
         * @throws IllegalArgumentException
         */
        private List<TrpJobStatus> getKwsJobs() throws SessionExpiredException, ServerErrorException, ClientErrorException, IllegalArgumentException {
            //final int colId = getCurrentCollection().getColId();
            Integer docId = store.getDocId();
//          Integer docId = null;
//          if(SCOPE_DOC.equals(getSelectedScope())) {
//              docId = store.getDocId();
//          }
            List<TrpJobStatus> jobs = new ArrayList<>(0);
            if (store != null && store.isLoggedIn()) {
                jobs = store.getConnection().getJobs(true, null, "CITlab Keyword Spotting", docId, 0, 0, null, null);
            }
            return jobs;
        }
项目:Plume    文件:BasicAuthenticator.java   
/**
 * Check that users accessing the resource are well authenticated.
 * A {@link ClientErrorException} will be raised if a user is not authenticated.
 * This error is usually interpreted by Jersey,
 * so an appropriate {@link Response} will be sent to the user.
 *
 * @return The authenticated user object
 */
public U requireAuthentication(ContainerRequestContext requestContext) {
    Credentials credentials = parseBasicHeader(
        requestContext.getHeaderString(HttpHeaders.AUTHORIZATION)
    );

    if(credentials == null) {
        throw new ClientErrorException(
            Response
                .status(Status.UNAUTHORIZED)
                .header(
                    HttpHeaders.WWW_AUTHENTICATE,
                    // currently Firefox does not support UTF-8 encoding for Basic Auth
                    // see https://bugzilla.mozilla.org/show_bug.cgi?id=41489
                    "Basic realm=\""+realm+"\", charset=\"UTF-8\""
                )
                .build()
        );
    }

    U authenticatedUser = authenticator.apply(credentials);

    if(authenticatedUser == null) {
        throw new ForbiddenException();
    }

    return authenticatedUser;
}
项目:TranskribusSwtGui    文件:JobTableWidgetListener.java   
@Override public void doubleClick(DoubleClickEvent event) {
    TrpMainWidget mw = TrpMainWidget.getInstance();

    TrpJobStatus jobStatus = jw.getFirstSelected();
    logger.debug("double click on transcript: "+jobStatus);

    if (jobStatus!=null) {
        logger.debug("Loading doc: " + jobStatus.getDocId());
        int col = 0;
        TrpDocMetadata el = null;
        try {
            List<TrpDocMetadata> docList = 
                    storage.getConnection().findDocuments(0, jobStatus.getDocId(), "", "", "", "", true, false, 0, 0, null, null);
            if (docList != null && docList.size() > 0){
                col = docList.get(0).getColList().get(0).getColId();
                el = docList.get(0);
            }

        } catch (SessionExpiredException | ServerErrorException
                | ClientErrorException | IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        String pages = jobStatus.getPages();
        int pageNr = ( (pages == null || pages.equals("") || pages.contains("-") ) ? 0 : Integer.parseInt(pages));
        mw.loadRemoteDoc(jobStatus.getDocId(), col, pageNr-1);
    }       
}
项目:TranskribusSwtGui    文件:ThumbnailManagerVirtual.java   
private void movePage(int fromPageNr, int toPageNr) {
    try {
        Storage.getInstance().movePage(tw.getDoc().getCollection().getColId(), tw.getDoc().getId(), fromPageNr, toPageNr);
    } catch (SessionExpiredException | ServerErrorException | ClientErrorException | NoConnectionException e) {
        logger.error(e.toString());
    }

}
项目:incubator-pulsar    文件:LookupImpl.java   
private PulsarAdminException getLookupApiException(Exception e) {
    if (e instanceof ClientErrorException) {
        return new PulsarAdminException((ClientErrorException) e, e.getMessage());
    } else {
        return getApiException(e);
    }
}
项目:incubator-pulsar    文件:BaseResource.java   
public PulsarAdminException getApiException(Throwable e) {
    if (e instanceof ServiceUnavailableException) {
        if (e.getCause() instanceof java.net.ConnectException) {
            return new ConnectException(e.getCause());
        } else {
            return new HttpErrorException(e);
        }
    } else if (e instanceof WebApplicationException) {
        // Handle 5xx exceptions
        if (e instanceof ServerErrorException) {
            ServerErrorException see = (ServerErrorException) e;
            return new ServerSideErrorException(see);
        }

        // Handle 4xx exceptions
        ClientErrorException cee = (ClientErrorException) e;
        int statusCode = cee.getResponse().getStatus();
        switch (statusCode) {
        case 401:
        case 403:
            return new NotAuthorizedException(cee);
        case 404:
            return new NotFoundException(cee);
        case 405:
            return new NotAllowedException(cee);
        case 409:
            return new ConflictException(cee);
        case 412:
            return new PreconditionFailedException(cee);

        default:
            return new PulsarAdminException(cee);
        }
    } else {
        return new PulsarAdminException(e);
    }
}
项目:TranskribusSwtGui    文件:SimpleDocSearchComposite.java   
public SimpleDocSearchComposite(Composite parent, int style, int collectiondId, CollectionManagerDialog colDialog) {
    super(parent, style);
        try{

        colId = collectiondId;
        this.colDialog = colDialog;
        userDocs = store.getConnection().getAllDocsByUser(0, -1, null, null);
        createContents();
        //updateCollections();
        } catch (ServerErrorException | IllegalArgumentException | SessionExpiredException | ClientErrorException e) {
            TrpMainWidget.getInstance().onError("Error loading documents", e.getMessage(), e);
    }
}
项目:TranskribusSwtGui    文件:DocumentManager.java   
private void deletePage(TrpPage page) {
    try {
        Storage.getInstance().deletePage(colId, page.getDocId(), page.getPageNr());
    } catch (SessionExpiredException | ServerErrorException | ClientErrorException | NoConnectionException e) {
        logger.error(e.toString());
    }
}
项目:TranskribusSwtGui    文件:Storage.java   
public void login(String serverUri, String username, String password) throws ClientErrorException, LoginException {
    logger.debug("Logging in as user: " + username);
    if (conn != null)
        conn.close();

    conn = new TrpServerConn(serverUri);
    user = conn.login(username, password);
    logger.debug("Logged in as user: " + user + " connection: " + conn);

    sendEvent(new LoginOrLogoutEvent(this, true, user, conn.getServerUri()));
}
项目:syndesis    文件:IntegrationSupportHandler.java   
@POST
@Path("/import")
@Produces(MediaType.APPLICATION_JSON)
public List<ChangeEvent> importIntegration(@Context SecurityContext sec, InputStream is) {
    try (ZipInputStream zis = new ZipInputStream(is)) {
        HashSet<String> extensionIds = new HashSet<>();
        ArrayList<ChangeEvent> changeEvents = new ArrayList<>();
        while (true) {
            ZipEntry entry = zis.getNextEntry();
            if( entry == null ) {
                break;
            }
            if (EXPORT_MODEL_FILE_NAME.equals(entry.getName())) {
                ModelExport models = Json.mapper().readValue(new DontClose(zis), ModelExport.class);
                changeEvents.addAll(importModels(sec, models));
                for (ChangeEvent changeEvent : changeEvents) {
                    if( changeEvent.getKind().get().equals("extension") ) {
                        extensionIds.add(changeEvent.getId().get());
                    }
                }
            }

            // import missing extensions that were in the model.
            if( entry.getName().startsWith("extensions/") ) {
                for (String extensionId : extensionIds) {
                    if( entry.getName().equals("extensions/" + Names.sanitize(extensionId) + ".jar") ) {
                        String path = "/extensions/" + extensionId;
                        InputStream existing = extensionDataManager.getExtensionDataAccess().read(path);
                        if( existing == null ) {
                            extensionDataManager.getExtensionDataAccess().write(path, zis);
                        } else {
                            existing.close();
                        }
                    }
                }
            }

            zis.closeEntry();
        }
        if (changeEvents.isEmpty()) {
            LOG.info("Could not import integration: No integration data model found.");
            throw new ClientErrorException("Does not look like an integration export.", Response.Status.BAD_REQUEST);
        }
        return changeEvents;
    } catch (IOException e) {
        if (LOG.isInfoEnabled()) {
            LOG.info("Could not import integration: " + e, e);
        }
        throw new ClientErrorException("Could not import integration: " + e, Response.Status.BAD_REQUEST, e);
    }
}
项目:opencps-v2    文件:KPRest.java   
public String sendOrder(String return_url,
        String version, String current_locale,
        String currency_code, String command,
        String merchant_trans_id, String country_code,
        String good_code, String xml_description,
        String net_cost, String ship_fee, String tax,
        String merchant_code,
        String service_code, String secure_hash,
        String desc_1, String desc_2, String desc_3,
        String desc_4, String desc_5, String internal_bank) throws ClientErrorException {
    WebTarget resource = webTarget;
    if (return_url != null) {
        resource = resource.queryParam("return_url", return_url);
    }
    if (version != null) {
        resource = resource.queryParam("version", version);
    }
    if (current_locale != null) {
        resource = resource.queryParam("current_locale", current_locale);
    }
    if (currency_code != null) {
        resource = resource.queryParam("currency_code", currency_code);
    }
    if (command != null) {
        resource = resource.queryParam("command", command);
    }
    if (country_code != null) {
        resource = resource.queryParam("country_code", country_code);
    }
    if (xml_description != null) {
        resource = resource.queryParam("xml_description", xml_description);
    }
    if (net_cost != null) {
        resource = resource.queryParam("net_cost", net_cost);
    }
    if (ship_fee != null) {
        resource = resource.queryParam("ship_fee", ship_fee);
    }
    if (tax != null) {
        resource = resource.queryParam("tax", tax);
    }
    if (service_code != null) {
        resource = resource.queryParam("service_code", service_code);
    }
    if (desc_1 != null) {
        resource = resource.queryParam("desc_1", desc_1);
    }
    if (desc_2 != null) {
        resource = resource.queryParam("desc_2", desc_2);
    }
    if (desc_3 != null) {
        resource = resource.queryParam("desc_3", desc_3);
    }
    if (desc_4 != null) {
        resource = resource.queryParam("desc_4", desc_4);
    }
    if (desc_5 != null) {
        resource = resource.queryParam("desc_5", desc_5);
    }
    if (internal_bank != null) {
        resource = resource.queryParam("internal_bank", internal_bank);
    }

    if (merchant_code != null) {
        resource = resource.queryParam("merchant_code", merchant_code);
    }
    if (good_code != null) {
        resource = resource.queryParam("good_code", good_code);
    }
    if (merchant_trans_id != null) {
        resource = resource.queryParam("merchant_trans_id", merchant_trans_id);
    }
    if (secure_hash != null) {
        resource = resource.queryParam("secure_hash", secure_hash);
    }

    resource = resource.path("sendOrder");
    return resource.request(javax.ws.rs.core.MediaType.TEXT_PLAIN).get(String.class);
}