當前位置: 首頁>>代碼示例>>Java>>正文


Java Validate類代碼示例

本文整理匯總了Java中org.folio.rest.annotations.Validate的典型用法代碼示例。如果您正苦於以下問題:Java Validate類的具體用法?Java Validate怎麽用?Java Validate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Validate類屬於org.folio.rest.annotations包,在下文中一共展示了Validate類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: putAdminLoglevel

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
@Validate
@Override
public void putAdminLoglevel(Level level, String javaPackage, java.util.Map<String, String>okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  try {
    JsonObject updatedLoggers = LogUtil.updateLogConfiguration(javaPackage, level.name());
    OutStream os = new OutStream();
    os.setData(updatedLoggers);
    asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutAdminLoglevelResponse.withJsonOK(os)));
  } catch (Exception e) {
    asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutAdminLoglevelResponse.withPlainInternalServerError("ERROR"
        + e.getMessage())));
    log.error(e.getMessage(), e);
  }

}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:18,代碼來源:AdminAPI.java

示例2: getAdminPostgresActiveSessions

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
@Validate
@Override
public void getAdminPostgresActiveSessions(String dbname, Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  PostgresClient.getInstance(vertxContext.owner(), "public").select("SELECT pid , usename, "
      + "application_name, client_addr, client_hostname, "
      + "query, state from pg_stat_activity where datname='"+dbname+"'", reply -> {

        if(reply.succeeded()){

          OutStream stream = new OutStream();
          stream.setData(reply.result().getRows());

          asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminPostgresActiveSessionsResponse.
            withJsonOK(stream)));
        }
        else{
          log.error(reply.cause().getMessage(), reply.cause());
          asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
        }
      });
}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:24,代碼來源:AdminAPI.java

示例3: getAdminPostgresTableAccessStats

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
@Validate
@Override
public void getAdminPostgresTableAccessStats(Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  PostgresClient.getInstance(vertxContext.owner()).select(
      "SELECT schemaname,relname,seq_scan,idx_scan,cast(idx_scan "
      + "AS numeric) / (idx_scan + seq_scan) AS idx_scan_pct "
      + "FROM pg_stat_user_tables WHERE (idx_scan + seq_scan)>0 "
      + "ORDER BY idx_scan_pct;", reply -> {

        if(reply.succeeded()){

          OutStream stream = new OutStream();
          stream.setData(reply.result().getRows());

          asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminPostgresTableAccessStatsResponse.
            withJsonOK(stream)));
        }
        else{
          log.error(reply.cause().getMessage(), reply.cause());
          asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
        }
      });
}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:26,代碼來源:AdminAPI.java

示例4: getAdminPostgresTableSize

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
@Validate
@Override
public void getAdminPostgresTableSize(String dbname, Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  PostgresClient.getInstance(vertxContext.owner()).select(
    "SELECT relname as \"Table\", pg_size_pretty(pg_relation_size(relid)) As \" Table Size\","
    + " pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as \"Index Size\""
    + " FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC;", reply -> {
      if(reply.succeeded()){

        OutStream stream = new OutStream();
        stream.setData(reply.result().getRows());

        asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminPostgresTableAccessStatsResponse.
          withJsonOK(stream)));
      }
      else{
        log.error(reply.cause().getMessage(), reply.cause());
        asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
      }
    });

}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:25,代碼來源:AdminAPI.java

示例5: postAdminGetPassword

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
@Validate
@Override
public void postAdminGetPassword(String key, Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  String tenantId = TenantTool.calculateTenantId( okapiHeaders.get(ClientGenerator.OKAPI_HEADER_TENANT) );

  if(tenantId == null){
    asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
      PostAdminGetPasswordResponse.withPlainBadRequest("Tenant id is null")));
  }
  else{
    try {
      String password = AES.encryptPasswordAsBase64(tenantId, AES.getSecretKeyObject(key));
      asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostAdminGetPasswordResponse.withPlainOK(password)));
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
        PostAdminGetPasswordResponse.withPlainInternalServerError(e.getMessage())));
    }

  }

}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:25,代碼來源:AdminAPI.java

示例6: getAdminSlowQueries

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
@Validate
@Override
public void getAdminSlowQueries(int querytimerunning, Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  /** the queries returned are of this backend's most recent query. If state is active this field shows the currently
   * executing query. In all other states, it shows the last query that was executed.*/
  PostgresClient.getInstance(vertxContext.owner()).select(
    "SELECT EXTRACT(EPOCH FROM now() - query_start) as runtime, client_addr, usename, datname, state, query "+
    "FROM  pg_stat_activity " +
    "WHERE now() - query_start > '"+querytimerunning+" seconds'::interval "+
    "ORDER BY runtime DESC;", reply -> {
      if(reply.succeeded()){

        OutStream stream = new OutStream();
        stream.setData(reply.result().getRows());

        asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminSlowQueriesResponse.
          withJsonOK(stream)));
      }
      else{
        log.error(reply.cause().getMessage(), reply.cause());
        asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
      }
    });
}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:27,代碼來源:AdminAPI.java

示例7: getAdminTotalDbSize

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
@Validate
@Override
public void getAdminTotalDbSize(String dbname, Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
  PostgresClient.getInstance(vertxContext.owner()).select(
    "select pg_size_pretty(pg_database_size('"+dbname+"')) as db_size", reply -> {
      if(reply.succeeded()){

        OutStream stream = new OutStream();
        stream.setData(reply.result().getRows());

        asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetAdminTotalDbSizeResponse.
          withJsonOK(stream)));
      }
      else{
        log.error(reply.cause().getMessage(), reply.cause());
        asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
      }
    });
}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:21,代碼來源:AdminAPI.java

示例8: deleteAdminKillQuery

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
@Validate
@Override
public void deleteAdminKillQuery(String pid, Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  PostgresClient.getInstance(vertxContext.owner()).select(
    "SELECT pg_terminate_backend('"+pid+"');", reply -> {
      if(reply.succeeded()){
        System.out.println("locking q -> " + reply.result().getResults().get(0).getBoolean(0));

        if(false == (reply.result().getResults().get(0).getBoolean(0))){
          asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(DeleteAdminKillQueryResponse.withPlainNotFound(pid)));
        }
        else{
          asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(DeleteAdminKillQueryResponse.withNoContent()));
        }
      }
      else{
        log.error(reply.cause().getMessage(), reply.cause());
        asyncResultHandler.handle(io.vertx.core.Future.failedFuture(reply.cause().getMessage()));
      }
  });

}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:25,代碼來源:AdminAPI.java

示例9: deleteLoanPolicyStorageLoanPolicies

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
@Override
@Validate
public void deleteLoanPolicyStorageLoanPolicies(
  String lang, Map<String, String> okapiHeaders,
  Handler<AsyncResult<Response>> asyncResultHandler,
  Context vertxContext) throws Exception {

  String tenantId = okapiHeaders.get(TENANT_HEADER);

  vertxContext.runOnContext(v -> {
    try {
      PostgresClient postgresClient = PostgresClient.getInstance(
        vertxContext.owner(), TenantTool.calculateTenantId(tenantId));

      postgresClient.mutate(String.format("TRUNCATE TABLE %s_%s.%s",
        tenantId, "mod_circulation_storage", LOAN_POLICY_TABLE),
        reply -> {
          asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
            LoanPolicyStorageResource.DeleteLoanPolicyStorageLoanPoliciesResponse
              .noContent().build()));
        });
    }
    catch(Exception e) {
      asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(
        LoanPolicyStorageResource.DeleteLoanPolicyStorageLoanPoliciesResponse
          .withPlainInternalServerError(e.getMessage())));
    }
  });
}
 
開發者ID:folio-org,項目名稱:mod-circulation-storage,代碼行數:30,代碼來源:LoanPoliciesAPI.java

示例10: getRmbtestsBooks

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
/**
 * validate to test the validation aspect
 */
@Validate
@Override
public void getRmbtestsBooks(String author, BigDecimal publicationYear, BigDecimal rating,
    String isbn, List<String> facets, Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetRmbtestsBooksResponse.withJsonOK(new Book())));

}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:13,代碼來源:BooksDemoAPI.java

示例11: putRmbtestsBooks

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
@Validate
@Override
public void putRmbtestsBooks(BigDecimal accessToken, Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(null));

}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:9,代碼來源:BooksDemoAPI.java

示例12: postRmbtestsBooks

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
@Validate
@Override
public void postRmbtestsBooks(Book entity, Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
  OutStream stream = new OutStream();
  stream.setData(entity);
  asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostRmbtestsBooksResponse.withJsonCreated("/dummy/location", stream)));
}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:9,代碼來源:BooksDemoAPI.java

示例13: getTenant

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
@Validate
@Override
public void getTenant(Map<String, String> headers, Handler<AsyncResult<Response>> handlers,
    Context context) throws Exception {

  context.runOnContext(v -> {
    try {

      String tenantId = TenantTool.calculateTenantId( headers.get(ClientGenerator.OKAPI_HEADER_TENANT) );
      log.info("sending... postTenant for " + tenantId);

      tenantExists(context, tenantId, res -> {
        boolean exists = false;
        if(res.succeeded()){
          exists = res.result();
          handlers.handle(io.vertx.core.Future.succeededFuture(GetTenantResponse.withPlainOK(String.valueOf(
            exists))));
        }
        else{
          log.error(res.cause().getMessage(), res.cause());
          handlers.handle(io.vertx.core.Future.succeededFuture(GetTenantResponse
            .withPlainInternalServerError(res.cause().getMessage())));
        }
      });
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      handlers.handle(io.vertx.core.Future.succeededFuture(GetTenantResponse
        .withPlainInternalServerError(e.getMessage())));
    }
  });
}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:32,代碼來源:TenantAPI.java

示例14: getAdminLoglevel

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
@Validate
@Override
public void getAdminLoglevel(java.util.Map<String, String>okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  try {
    JsonObject loggers = LogUtil.getLogConfiguration();
    OutStream os = new OutStream();
    os.setData(loggers);
    asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutAdminLoglevelResponse.withJsonOK(os)));
  } catch (Exception e) {
    asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PutAdminLoglevelResponse.withPlainInternalServerError("ERROR"
        + e.getMessage())));
    log.error(e.getMessage(), e);
  }
}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:16,代碼來源:AdminAPI.java

示例15: postAdminUploadmultipart

import org.folio.rest.annotations.Validate; //導入依賴的package包/類
@Validate
@Override
public void postAdminUploadmultipart(PersistMethod persistMethod, String busAddress,
    String fileName, MimeMultipart entity, Map<String, String> okapiHeaders,
    Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {

  if(entity != null){
    int parts = entity.getCount();
    for (int i = 0; i < parts; i++) {
      BodyPart bp = entity.getBodyPart(i);
      System.out.println(bp.getFileName());
      //System.out.println(bp.getContent());
      //System.out.println("-----------------------------------------");
    }
    String name = "";
    try{
      if(fileName == null){
        name = entity.getBodyPart(0).getFileName();
      }
      else{
        name = fileName;
      }
    }
    catch(Exception e){
      log.error(e.getMessage(), e);
    }
  }

  asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostAdminUploadmultipartResponse.withOK("TODO"
      )));
}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:32,代碼來源:AdminAPI.java


注:本文中的org.folio.rest.annotations.Validate類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。