当前位置: 首页>>代码示例>>Java>>正文


Java OperationStatus类代码示例

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


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

示例1: checkQueryAccess

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
/**
 * Checks if the caller has access to all the query fields. Returns false if
 * not, and sets the error status in ctx
 */
private boolean checkQueryAccess(OperationContext ctx, QueryExpression query) {
    boolean ret = true;
    if (query != null) {
        CompositeMetadata md = ctx.getTopLevelEntityMetadata();
        FieldAccessRoleEvaluator eval = new FieldAccessRoleEvaluator(md, ctx.getCallerRoles());
        AnalyzeQuery analyzer=new AnalyzeQuery(md,null);
        analyzer.iterate(query,Path.EMPTY);
        List<QueryFieldInfo> fields=analyzer.getFieldInfo();
        LOGGER.debug("Checking access for query fields {}", fields);
        for (QueryFieldInfo field : fields) {
            LOGGER.debug("Access checking field {}", field.getFullFieldName());
            if (eval.hasAccess(field.getFullFieldName(), FieldAccessRoleEvaluator.Operation.find)) {
                LOGGER.debug("Field {} is readable", field.getFullFieldName());
            } else {
                LOGGER.debug("Field {} is not readable", field.getFullFieldName());
                ctx.addError(Error.get(CrudConstants.ERR_NO_ACCESS, field.getFullFieldName().toString()));
                ctx.setStatus(OperationStatus.ERROR);
                ret = false;
            }
        }
    }
    return ret;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:28,代码来源:Mediator.java

示例2: disabledVersionTest

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
@Test
public void disabledVersionTest() throws Exception {

    mdManager.md.setStatus(MetadataStatus.DISABLED);
    InsertionRequest req = new InsertionRequest();
    req.setEntityVersion(new EntityVersion("test", "1.0"));
    req.setEntityData(loadJsonNode("./sample1.json"));
    req.setReturnFields(null);

    mdManager.md.getAccess().getInsert().setRoles("role1");
    Response response = mediator.insert(req);

    Assert.assertEquals(OperationStatus.ERROR, response.getStatus());
    Assert.assertEquals(CrudConstants.ERR_DISABLED_METADATA, response.getErrors().get(0).getErrorCode());

}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:17,代码来源:MediatorTest.java

示例3: insertRoleAccessTest

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
@Test
public void insertRoleAccessTest() throws Exception {
    InsertionRequest req = new InsertionRequest();
    req.setEntityVersion(new EntityVersion("test", "1.0"));
    req.setEntityData(loadJsonNode("./sample1.json"));
    req.setReturnFields(null);
    req.setClientId(new RestClientIdentification(Arrays.asList("test-insert", "test-update")));
    mockCrudController.insertResponse=new CRUDInsertionResponse();
    mockCrudController.insertResponse.setNumInserted(1);
    Response response = mediator.insert(req);

    Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
    Assert.assertEquals(1, response.getModifiedCount());
    Assert.assertEquals(0, response.getMatchCount());
    Assert.assertEquals(0, response.getDataErrors().size());
    Assert.assertEquals(0, response.getErrors().size());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:18,代码来源:MediatorTest.java

示例4: insertResultMetadataTest

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
@Test
public void insertResultMetadataTest() throws Exception {
    InsertionRequest req = new InsertionRequest();
    req.setEntityVersion(new EntityVersion("test", "1.0"));
    req.setEntityData(loadJsonNode("./sample1.json"));
    req.setReturnFields(null);
    req.setClientId(new RestClientIdentification(Arrays.asList("test-insert", "test-update")));
    mockCrudController.insertCb=ctx->{ctx.getInputDocuments().get(0).setResultMetadata(getRmd("1"));};
    mockCrudController.insertResponse=new CRUDInsertionResponse();
    mockCrudController.insertResponse.setNumInserted(1);
    Response response = mediator.insert(req);

    Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
    Assert.assertEquals(1,response.getResultMetadata().size());
    Assert.assertEquals("1",response.getResultMetadata().get(0).getDocumentVersion());
    Assert.assertEquals(1, response.getModifiedCount());
    Assert.assertEquals(0, response.getMatchCount());
    Assert.assertEquals(0, response.getDataErrors().size());
    Assert.assertEquals(0, response.getErrors().size());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:21,代码来源:MediatorTest.java

示例5: insertFieldAccessTest

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
@Test
public void insertFieldAccessTest() throws Exception {
    InsertionRequest req = new InsertionRequest();
    req.setEntityVersion(new EntityVersion("test", "1.0"));
    req.setEntityData(loadJsonNode("./sample1.json"));
    req.setReturnFields(null);
    req.setClientId(new RestClientIdentification(Arrays.asList("test.field1-insert", "test-insert")));
    mockCrudController.insertResponse=new CRUDInsertionResponse();
    mockCrudController.insertResponse.setNumInserted(1);

    Response response = mediator.insert(req);

    Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
    Assert.assertEquals(1, response.getModifiedCount());
    Assert.assertEquals(0, response.getMatchCount());
    Assert.assertEquals(0, response.getDataErrors().size());
    Assert.assertEquals(0, response.getErrors().size());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:19,代码来源:MediatorTest.java

示例6: saveResultMdTest

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
@Test
public void saveResultMdTest() throws Exception {
    SaveRequest req = new SaveRequest();
    req.setEntityVersion(new EntityVersion("test", "1.0"));
    req.setEntityData(loadJsonNode("./sample1.json"));
    req.setReturnFields(null);
    mockCrudController.saveResponse=new CRUDSaveResponse();
    mockCrudController.saveResponse.setNumSaved(1);
    mockCrudController.saveCb=ctx->{ctx.getInputDocuments().get(0).setResultMetadata(getRmd("1"));};

    mdManager.md.getAccess().getInsert().setRoles("anyone");
    mdManager.md.getAccess().getUpdate().setRoles("anyone");
    Response response = mediator.save(req);

    Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
    Assert.assertEquals(1, response.getModifiedCount());
    Assert.assertEquals(1,response.getResultMetadata().size());
    Assert.assertEquals("1",response.getResultMetadata().get(0).getDocumentVersion());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:20,代码来源:MediatorTest.java

示例7: updateQueryFieldRoleTest

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
@Test
public void updateQueryFieldRoleTest() throws Exception {
    UpdateRequest req = new UpdateRequest();
    req.setEntityVersion(new EntityVersion("test", "1.0"));
    req.setReturnFields(null);
    req.setQuery(new ValueComparisonExpression(new Path("field1"), BinaryComparisonOperator._eq, new Value("x")));
    req.setClientId(new RestClientIdentification(Arrays.asList("test-update")));

    mockCrudController.updateResponse = new CRUDUpdateResponse();
    Response response = mediator.update(req);
    Assert.assertEquals(OperationStatus.ERROR, response.getStatus());

    req.setQuery(new ValueComparisonExpression(new Path("field2"), BinaryComparisonOperator._eq, new Value("x")));
    response = mediator.update(req);
    Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:17,代码来源:MediatorTest.java

示例8: findAndStream_ErrorHandling

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
@Test
public void findAndStream_ErrorHandling() throws Exception {
    mdManager.md = null;

    FindRequest req = new FindRequest();
    req.setEntityVersion(new EntityVersion("foo", "0.0.1"));

    mockCrudController.findCb=ctx->ctx.setDocumentStream(new ListDocumentStream<DocCtx>(new ArrayList<DocCtx>()));
    mockCrudController.findResponse = new CRUDFindResponse();
    StreamingResponse response = mediator.findAndStream(req);

    Assert.assertEquals(OperationStatus.ERROR, response.getStatus());
    Assert.assertEquals(0, response.getModifiedCount());
    Assert.assertEquals(0, response.getMatchCount());
    Assert.assertEquals(0, response.getDataErrors().size());
    Assert.assertEquals(1, response.getErrors().size());
    Assert.assertEquals(CrudConstants.ERR_UNKNOWN_ENTITY, response.getErrors().get(0).getErrorCode());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:19,代码来源:MediatorTest.java

示例9: findResultMdTest

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
@Test
public void findResultMdTest() throws Exception {
    FindRequest req = new FindRequest();
    req.setEntityVersion(new EntityVersion("test", "1.0"));

    mdManager.md.getAccess().getFind().setRoles("anyone");
    mockCrudController.findResponse = new CRUDFindResponse();
    mockCrudController.findResponse.setSize(10);
    mockCrudController.findCb=ctx->{
        ArrayList<DocCtx> docs=new ArrayList<>();
        for(int i=0;i<10;i++)
            docs.add(new DocCtx(new JsonDoc(JsonNodeFactory.instance.objectNode()),getRmd(Integer.toString(i))));
        ctx.setDocumentStream(new ListDocumentStream(docs));
    };
    Response response = mediator.find(req);
    Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
    Assert.assertEquals(0, response.getModifiedCount());
    Assert.assertEquals(10, response.getMatchCount());
    for(int i=0;i<10;i++) {
        Assert.assertEquals(Integer.toString(i),response.getResultMetadata().get(i).getDocumentVersion());
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:23,代码来源:MediatorTest.java

示例10: findQueryFieldRoleTest

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
@Test
public void findQueryFieldRoleTest() throws Exception {
    FindRequest req = new FindRequest();
    req.setEntityVersion(new EntityVersion("test", "1.0"));
    req.setQuery(new ValueComparisonExpression(new Path("field1"), BinaryComparisonOperator._eq, new Value("x")));
    req.setClientId(new RestClientIdentification(Arrays.asList("test-find")));

    mockCrudController.findResponse = new CRUDFindResponse();
    mockCrudController.findCb=ctx->ctx.setDocumentStream(new ListDocumentStream<DocCtx>(new ArrayList<DocCtx>()));
    Response response = mediator.find(req);
    Assert.assertEquals(OperationStatus.ERROR, response.getStatus());

    req.setQuery(new ValueComparisonExpression(new Path("field2"), BinaryComparisonOperator._eq, new Value("x")));
    response = mediator.find(req);
    Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:17,代码来源:MediatorTest.java

示例11: testDependencies

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
@Test
public void testDependencies() {
    String entityName = "fake";
    String version1 = "1.0.0";
    String version2 = "2.0.0";

    FakeMetadata metadata = new FakeMetadata();

    EntityInfo entityInfo = new EntityInfo(entityName);
    metadata.setEntityInfo(entityInfo);

    assertEquals(entityInfo, metadata.getEntityInfo(entityName));

    Response dependencies = new Response(JsonNodeFactory.instance, OperationStatus.ERROR);
    metadata.setDependencies(entityName, version1, dependencies);

    assertEquals(dependencies, metadata.getDependencies(entityName, version1));
    assertNull(metadata.getDependencies(entityName, version2));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:20,代码来源:FakeMetadataTest.java

示例12: testAccess

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
@Test
public void testAccess() {
    String entityName = "fake";
    String version1 = "1.0.0";
    String version2 = "2.0.0";

    FakeMetadata metadata = new FakeMetadata();

    EntityInfo entityInfo = new EntityInfo(entityName);
    metadata.setEntityInfo(entityInfo);

    assertEquals(entityInfo, metadata.getEntityInfo(entityName));

    Response access = new Response(JsonNodeFactory.instance, OperationStatus.ERROR);
    metadata.setAccess(entityName, version1, access);

    assertEquals(access, metadata.getAccess(entityName, version1));
    assertNull(metadata.getAccess(entityName, version2));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:20,代码来源:FakeMetadataTest.java

示例13: runFindWithStream

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
@Test
public void runFindWithStream() throws WebApplicationException, IOException {
    ObjectMapper mapper = new ObjectMapper();

    ObjectNode rootDoc = mapper.createObjectNode().put("foo", "bar");
    ObjectNode projectedDoc = mapper.createObjectNode();

    DocCtx doc = new DocCtx(new JsonDoc(rootDoc));
    doc.setOutputDocument(new JsonDoc(projectedDoc));

    Assert.assertNotNull(doc.getRoot());
    Assert.assertNotNull(doc.getOutputDocument().getRoot());
    Assert.assertNotNull(doc.getRoot().get("foo"));
    Assert.assertNull(doc.getOutputDocument().getRoot().get("foo"));

    StreamingResponse sr = new StreamingResponse(JsonNodeFactory.instance, OperationStatus.COMPLETE);
    sr.documentStream = new ListDocumentStream<>(Arrays.asList(new DocCtx[] { doc }));
    mediator.streamingResponse = sr;

    FindCommand command = new FindCommand(mediator, "name", "version", "{\"request\":\"data\"}", true, new NoopRequestMetrics());

    command.run();

    Assert.assertEquals("findAndStream", mediator.methodCalled);

    StringWriter sw = new StringWriter();
    command.getResponseStream().write(new WriterOutputStream(sw));

    Assert.assertTrue("Should return projected doc: {}, but the response is "+sw.toString(), sw.toString().endsWith("\"processed\":{}}"));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:31,代码来源:FindCommandTest.java

示例14: runStreamFindWithMetrics

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
@Test
public void runStreamFindWithMetrics() throws WebApplicationException, IOException {
    ObjectMapper mapper = new ObjectMapper();

    ObjectNode rootDoc = mapper.createObjectNode().put("foo", "bar");
    ObjectNode projectedDoc = mapper.createObjectNode();

    DocCtx doc = new DocCtx(new JsonDoc(rootDoc));
    doc.setOutputDocument(new JsonDoc(projectedDoc));

    StreamingResponse sr = new StreamingResponse(JsonNodeFactory.instance, OperationStatus.COMPLETE);
    sr.documentStream = new ListDocumentStream<>(Arrays.asList(new DocCtx[] { doc }));
    mediator.streamingResponse = sr;

    FindCommand command = new FindCommand(mediator, "name", "version", "{\"request\":\"data\"}", true, requestMetrics);

    RequestMetric findName = metricNamer.streamingCrud("find", "name", "version");
    Timer completedRequestTimer = findName.requestTimer(metricsRegistry);
    Counter activeRequestCounter = findName.activeRequestCounter(metricsRegistry);
    
    command.run();
    
    Assert.assertEquals(1, activeRequestCounter.getCount());
    Assert.assertEquals(0, completedRequestTimer.getCount());
    Assert.assertEquals("findAndStream", mediator.methodCalled);

    StringWriter sw = new StringWriter();
    command.getResponseStream().write(new WriterOutputStream(sw));

    Assert.assertEquals(0, activeRequestCounter.getCount());
    Assert.assertEquals(1, completedRequestTimer.getCount());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:33,代码来源:FindCommandTest.java

示例15: getAccessEntityVersion

import com.redhat.lightblue.OperationStatus; //导入依赖的package包/类
@Test
public void getAccessEntityVersion() throws IOException, JSONException {
    // setup parser
    Extensions<JsonNode> extensions = new Extensions<>();
    extensions.addDefaultExtensions();
    extensions.registerDataStoreParser("mongo", new MongoDataStoreParser<JsonNode>());
    JSONMetadataParser parser = new JSONMetadataParser(extensions, new DefaultTypes(), new JsonNodeFactory(true));

    // get JsonNode representing metadata
    JsonNode jsonMetadata = AbstractJsonNodeTest.loadJsonNode(getClass().getSimpleName() + "-access-entity-version.json");

    // parser into EntityMetadata
    EntityMetadata e = parser.parseEntityMetadata(jsonMetadata);

    // persist
    md.createNewMetadata(e);

    // ready to test!
    Response response = md.getAccess(e.getName(), e.getVersion().getValue());

    Assert.assertNotNull(response);

    // verify response content
    Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
    Assert.assertTrue(response.getDataErrors().isEmpty());

    // verify data
    Assert.assertNotNull(response.getEntityData());
    String jsonEntityData = response.getEntityData().toString();
    String jsonExpected = "[{\"role\":\"field.find\",\"find\":[\"test.name\"]},{\"role\":\"field.insert\",\"insert\":[\"test.name\"]},{\"role\":\"noone\",\"update\":[\"test.objectType\"]},{\"role\":\"field.update\",\"update\":[\"test.name\"]},{\"role\":\"anyone\",\"find\":[\"test.objectType\"]},{\"role\":\"entity.insert\",\"insert\":[\"test\"]},{\"role\":\"entity.update\",\"update\":[\"test\"]},{\"role\":\"entity.find\",\"find\":[\"test\"]},{\"role\":\"entity.delete\",\"delete\":[\"test\"]}]";
    JSONAssert.assertEquals(jsonExpected, jsonEntityData, false);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:33,代码来源:MongoMetadataTest.java


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