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


Java Operation.setBody方法代码示例

本文整理汇总了Java中com.vmware.xenon.common.Operation.setBody方法的典型用法代码示例。如果您正苦于以下问题:Java Operation.setBody方法的具体用法?Java Operation.setBody怎么用?Java Operation.setBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vmware.xenon.common.Operation的用法示例。


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

示例1: handleGet

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@RouteDocumentation(description = "@CAR_ENGINE",
        path = "?engine",
        produces = { "application/json" },
        responses = {
            @ApiResponse(statusCode = Operation.STATUS_CODE_OK, description = "OK", response = EngineInfo.class)
        })
@RouteDocumentation(description = "@CAR",
        produces = { "application/json" },
        responses = {
            @ApiResponse(statusCode = Operation.STATUS_CODE_OK, description = "OK", response = Car.class),
            @ApiResponse(statusCode = Operation.STATUS_CODE_NOT_FOUND, description = "Not Found"),
        })
@Override
public void handleGet(Operation get) {
    Map<String,String> queryParams = UriUtils.parseUriQueryParams(get.getUri());
    boolean engineInfo = Boolean.parseBoolean(queryParams.get("engine"));
    if (engineInfo) {
        Car car = this.getState(get);
        get.setBody(car.engineInfo);
        get.complete();
    } else {
        super.handleGet(get);
    }
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:25,代码来源:CarService.java

示例2: handleIdempotentPut

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
public static void handleIdempotentPut(StatefulService s, Operation put) {

        if (put.hasPragmaDirective(Operation.PRAGMA_DIRECTIVE_POST_TO_PUT)) {
            // converted PUT due to IDEMPOTENT_POST option
            s.logFine(() -> String.format("Task %s has already started. Ignoring converted PUT.",
                    put.getUri()));
            put.setBody(s.getState(put));
            put.addPragmaDirective(Operation.PRAGMA_DIRECTIVE_STATE_NOT_MODIFIED);
            put.setStatusCode(Operation.STATUS_CODE_OK);
            put.complete();
            return;
        }

        // normal PUT is not supported
        put.fail(Operation.STATUS_CODE_BAD_METHOD);
    }
 
开发者ID:vmware,项目名称:photon-model,代码行数:17,代码来源:PhotonModelUtils.java

示例3: handlePut

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePut(Operation put) {
    if (!checkForBody(put)) {
        return;
    }

    try {
        SslTrustCertificateState body = put.getBody(SslTrustCertificateState.class);
        SslTrustCertificateState state = getState(put);
        // these properties can't be modified once set:
        body.subscriptionLink = state.subscriptionLink;

        boolean validated = validate(put, () -> validateStateOnStart(body));
        if (!validated) {
            return;
        }

        this.setState(put, body);
        put.setBody(body);
        put.complete();
    } catch (Throwable t) {
        put.fail(t);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:25,代码来源:SslTrustCertificateService.java

示例4: handlePatch

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePatch(Operation patch) {
    if (!checkForBody(patch)) {
        return;
    }

    SslTrustCertificateState body = patch.getBody(SslTrustCertificateState.class);
    SslTrustCertificateState state = getState(patch);
    String stateCert = state.certificate;
    state.certificate = body.certificate != null ? body.certificate : state.certificate;

    boolean validated = validate(patch, () -> validateStateOnStart(state));
    if (!validated) {
        return;
    }

    patch.setBody(state);

    if (isModified(stateCert, body.certificate)) {
        patch.complete();
    } else {
        patch.complete();
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:25,代码来源:SslTrustCertificateService.java

示例5: handleGet

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleGet(Operation get) {
    Map<String, String> params = UriUtils.parseUriQueryParams(get.getUri());
    String deviceType = params.get(DEVICE_TYPE);
    if (deviceType == null || deviceType.isEmpty()) {
        get.fail(new IllegalArgumentException("No deviceType provided."));
        return;
    }
    if (!deviceType.equals(AWSConstants.AWSStorageType.EBS.name().toLowerCase())) {
        get.fail(new IllegalArgumentException("Unsupported device Type"));
        return;
    }

    VolumeTypeList volumeTypeList = new VolumeTypeList();
    for (VolumeType volumeType : VolumeType.values()) {
        volumeTypeList.volumeTypes.add(volumeType.toString());
    }

    get.setBody(volumeTypeList);
    get.complete();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:22,代码来源:AWSVolumeTypeDiscoveryService.java

示例6: testGetAvailableRegions

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Test
public void testGetAvailableRegions() {
    URI uri = UriUtils.buildUri(
            ServiceHost.LOCAL_HOST,
            host.getPort(),
            UriPaths.AdapterTypePath.REGION_ENUMERATION_ADAPTER.adapterLink(
                    PhotonModelConstants.EndpointType.aws.toString().toLowerCase()), null);

    Operation post = Operation.createPost(uri);
    post.setBody(new AuthCredentialsServiceState());

    Operation operation = host.getTestRequestSender().sendAndWait(post);
    RegionEnumerationResponse result = operation.getBody(RegionEnumerationResponse.class);

    assertEquals(Regions.values().length, result.regions.size());
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:17,代码来源:TestAWSEnumerationTask.java

示例7: testGetAvailableRegions

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Test
public void testGetAvailableRegions() throws Throwable {
    Assume.assumeFalse(isMock());

    startAdditionalServices();

    this.host.waitForServiceAvailable(VSphereUriPaths.VSPHERE_REGION_ENUMERATION_ADAPTER_SERVICE);

    URI uri = UriUtils.buildUri(
            ServiceHost.LOCAL_HOST,
            host.getPort(),
            UriPaths.AdapterTypePath.REGION_ENUMERATION_ADAPTER.adapterLink(
                    PhotonModelConstants.EndpointType.vsphere.toString().toLowerCase()), null);

    Operation post = Operation.createPost(uri);
    post.setBody(createEndpoint((a) -> { }, (b) -> { }));

    Operation operation = host.getTestRequestSender().sendAndWait(post);
    RegionEnumerationResponse result = operation.getBody(RegionEnumerationResponse.class);

    assertTrue(!result.regions.isEmpty());
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:23,代码来源:TestVSphereEnumerationTask.java

示例8: testGetAvailableRegions

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Test
public void testGetAvailableRegions() {

    Assume.assumeFalse(this.isMock);

    URI uri = UriUtils.buildUri(
            ServiceHost.LOCAL_HOST,
            host.getPort(),
            UriPaths.AdapterTypePath.REGION_ENUMERATION_ADAPTER.adapterLink(
                    PhotonModelConstants.EndpointType.azure.toString().toLowerCase()), null);

    Operation post = Operation.createPost(uri);
    post.setBody(endpointState);

    Operation operation = host.getTestRequestSender().sendAndWait(post);
    RegionEnumerationResponse result = operation.getBody(RegionEnumerationResponse.class);

    assertTrue(!result.regions.isEmpty());
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:20,代码来源:TestAzureEnumerationTask.java

示例9: handlePost

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
/**
 * Override the handlePost method to set the documentSelfLink. We don't want to have multiple
 * certificate states with the same certificate, so we build the documentSelfLink ourselves
 *
 * @param op
 */
@Override
public void handlePost(Operation op) {
    if (op.isSynchronize()) {
        op.complete();
        return;
    }
    if (op.hasBody()) {
        SslTrustCertificateState body = (SslTrustCertificateState) op.getBody(this.stateType);
        if (body == null) {
            op.fail(new IllegalArgumentException("structured body is required"));
            return;
        }

        if (body.documentSourceLink != null) {
            op.fail(new IllegalArgumentException("clone request not supported"));
            return;
        }

        body.documentSelfLink = generateSelfLink(body);
        op.setBody(body);
        op.complete();
    } else {
        op.fail(new IllegalArgumentException("body is required"));
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:32,代码来源:SslTrustCertificateFactoryService.java

示例10: handleStart

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleStart(Operation start) {
    State state = validateStartState(start);
    if (state == null) {
        return;
    }

    start.setBody(state);
    start.complete();
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:11,代码来源:GatewayConfigService.java

示例11: handlePatch

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePatch(Operation patch) {
    State body = validateUpdateState(patch);
    if (body == null) {
        return;
    }
    State currentState = getState(patch);
    updateState(currentState, body);

    patch.setBody(currentState);
    patch.complete();
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:13,代码来源:GatewayConfigService.java

示例12: handleStart

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleStart(Operation start) {
    State state = validateStartState(start);
    if (state == null) {
        return;
    }
    start.setBody(state);
    start.complete();
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:10,代码来源:GatewayPathService.java

示例13: handleValidationException

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
private static void handleValidationException(Operation op, Throwable e) {
    Throwable ex = e;
    if (!(e instanceof IllegalArgumentException)
            && !(e instanceof LocalizableValidationException)) {
        ex = new IllegalArgumentException(e.getMessage());
    }
    op.setStatusCode(Operation.STATUS_CODE_BAD_REQUEST);
    // with body = null fail(ex) will populate it with the proper ServiceErrorResponse content
    op.setBody(null);
    op.fail(ex);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:12,代码来源:SslTrustCertificateService.java

示例14: handlePatch

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handlePatch(Operation patch) {
    StatsAggregationTaskState currentState = getState(patch);
    StatsAggregationTaskState patchState = getTaskBody(patch);
    validateTransition(patch, currentState, patchState);
    updateState(currentState, patchState);
    patch.setBody(currentState);
    patch.complete();

    switch (currentState.taskInfo.stage) {
    case STARTED:
        // TODO: https://jira-hzn.eng.vmware.com/browse/VSYM-3111
        logFine(() -> String.format("Started stats aggregation. Stage [%s], PageLink [%s]",
                currentState.taskSubStage, currentState.queryResultLink));
        handleStagePatch(currentState);
        break;
    case FINISHED:
    case FAILED:
    case CANCELLED:
        if (TaskState.isFailed(currentState.taskInfo) ||
                TaskState.isCancelled(currentState.taskInfo)) {
            if (currentState.failureMessage != null) {
                logWarning(currentState.failureMessage);
            }
        }
        logInfo(() -> "Finished stats aggregation");
        sendRequest(Operation
                    .createDelete(getUri()));
        break;
    default:
        break;
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:34,代码来源:StatsAggregationTaskService.java

示例15: handleGet

import com.vmware.xenon.common.Operation; //导入方法依赖的package包/类
@Override
public void handleGet(Operation get) {
    if (get.getContentType().equalsIgnoreCase(MEDIA_TYPE_APPLICATION_OCTET_STREAM)) {
        ContentState state = this.getState(get);
        get.setBody(state.binaryData);
        get.complete();
    } else {
        super.handleGet(get);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:11,代码来源:ContentService.java


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