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


Java UriUtils类代码示例

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


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

示例1: handlePut

import com.vmware.xenon.common.UriUtils; //导入依赖的package包/类
@Override
public void handlePut(Operation put) {
    UserToken body = put.getBody(UserToken.class);
    Map<String, String> queryParams = UriUtils.parseUriQueryParams(put.getUri());
    String appendValue = queryParams.get("append");

    UserToken currentState = new UserToken();
    currentState.token = body.token;
    currentState.user = body.user;
    if (Boolean.valueOf(appendValue)) {
        currentState.internalId = body.user + body.internalId;
    }
    log(Level.INFO, "user:%s token:%s internal:%s", currentState.user, currentState.token,
            currentState.internalId);
    put.setBody(currentState).complete();
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:17,代码来源:TokenService.java

示例2: handleGet

import com.vmware.xenon.common.UriUtils; //导入依赖的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

示例3: getDescriptionInJson

import com.vmware.xenon.common.UriUtils; //导入依赖的package包/类
@Test
public void getDescriptionInJson() throws Throwable {
    TestRequestSender sender = host.getTestRequestSender();

    Operation op = Operation
            .createGet(UriUtils.buildUri(host, SwaggerDescriptorService.SELF_LINK))
            .setReferer(host.getUri());

    Operation result = null;
    Throwable error = null;
    try {
        result = sender.sendAndWait(op);
    } catch (Throwable e) {
        error = e;
    }

    assertDescriptorJson(result, error);
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:19,代码来源:TestSwaggerDescriptorService.java

示例4: getDescriptionInCompressedJson

import com.vmware.xenon.common.UriUtils; //导入依赖的package包/类
@Test
public void getDescriptionInCompressedJson() throws Throwable {
    TestRequestSender sender = host.getTestRequestSender();

    Operation op = Operation
            .createGet(UriUtils.buildUri(host, SwaggerDescriptorService.SELF_LINK))
            .setReferer(host.getUri())
            .addRequestHeader(Operation.ACCEPT_ENCODING_HEADER, Operation.CONTENT_ENCODING_GZIP);
    Operation result = null;
    Throwable error = null;
    try {
        result = sender.sendAndWait(op);
    } catch (Throwable e) {
        error = e;
    }

    assertDescriptorJson(result, error);
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:19,代码来源:TestSwaggerDescriptorService.java

示例5: getParentDescription

import com.vmware.xenon.common.UriUtils; //导入依赖的package包/类
/**
 * Populate context with parent {@code ComputeStateWithDescription}.
 * <p>
 * <p>
 * By default {@code context.child.parentLink} is used as source.
 */
protected DeferredResult<T> getParentDescription(T context) {

    URI ref = context.child != null
            // 'child' is already resolved so used it
            ? UriUtils.buildUri(context.service.getHost(), context.child.parentLink)
            // state machine starts from here so resRef should point to the parent
            : context.resourceReference;

    ref = ComputeStateWithDescription.buildUri(ref);

    Operation op = Operation.createGet(ref);

    return context.service
            .sendWithDeferredResult(op, ComputeStateWithDescription.class)
            .thenApply(state -> {
                context.parent = state;
                return context;
            });
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:26,代码来源:BaseAdapterContext.java

示例6: performDiskRequest

import com.vmware.xenon.common.UriUtils; //导入依赖的package包/类
private String performDiskRequest(DiskState diskState, SubStage subStage) throws Throwable {
    ProvisionDiskTaskService.ProvisionDiskTaskState provisionTask = new ProvisionDiskTaskService.ProvisionDiskTaskState();
    provisionTask.taskSubStage = subStage;

    provisionTask.diskLink = diskState.documentSelfLink;
    provisionTask.isMockRequest = isMock();

    provisionTask.documentExpirationTimeMicros =
            Utils.getNowMicrosUtc() + TimeUnit.MINUTES.toMicros(
                    DISK_REQUEST_TIMEOUT_MINUTES);
    provisionTask.tenantLinks = this.endpointState.tenantLinks;

    provisionTask = TestUtils.doPost(this.host,
            provisionTask, ProvisionDiskTaskService.ProvisionDiskTaskState.class,
            UriUtils.buildUri(this.host, ProvisionDiskTaskService.FACTORY_LINK));

    return provisionTask.documentSelfLink;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:19,代码来源:TestVSphereDiskService.java

示例7: createVmDescription

import com.vmware.xenon.common.UriUtils; //导入依赖的package包/类
private ComputeDescription createVmDescription() throws Throwable {
    ComputeDescription computeDesc = new ComputeDescription();

    computeDesc.id = nextName("vm");
    computeDesc.regionId = this.datacenterId;
    computeDesc.documentSelfLink = computeDesc.id;
    computeDesc.supportedChildren = new ArrayList<>();
    computeDesc.instanceAdapterReference = UriUtils
            .buildUri(this.host, VSphereUriPaths.INSTANCE_SERVICE);
    computeDesc.authCredentialsLink = this.auth.documentSelfLink;
    computeDesc.name = computeDesc.id;
    computeDesc.dataStoreId = this.dataStoreId;
    computeDesc.cpuCount = 2;
    // 1G
    computeDesc.totalMemoryBytes = 1024 * 1024 * 1024;

    return TestUtils.doPost(this.host, computeDesc,
            ComputeDescription.class,
            UriUtils.buildUri(this.host, ComputeDescriptionService.FACTORY_LINK));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:21,代码来源:TestVSphereProvisionWithStaticIpTask.java

示例8: test

import com.vmware.xenon.common.UriUtils; //导入依赖的package包/类
@Test
public void test() throws Throwable {
    StatelessService parentService = new StatelessService() {
        @Override
        public void handleRequest(Operation op) {
            if (op.getAction() == Action.PATCH) {
                ComputeService.ComputeState state = op
                        .getBody(ComputeService.ComputeState.class);
                Assert.assertNotNull(state.customProperties);
                Assert.assertNotNull(
                        state.customProperties.get(AWSConstants.RESERVED_INSTANCE_PLAN_DETAILS));
                TestAWSReservedInstancePlansService.this.host.completeIteration();
            }
        }
    };
    String servicePath = COMPUTE_SELF_LINK;
    Operation startOp = Operation.createPost(UriUtils.buildUri(this.host, servicePath));
    this.host.startService(startOp, parentService);

    this.host.sendAndWait(Operation.createPost(UriUtils.buildUri(
            this.host, MockAWSReservedInstancePlansService.SELF_LINK))
            .setBody(COMPUTE_SELF_LINK)
            .setReferer(this.host.getUri()));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:25,代码来源:TestAWSReservedInstancePlansService.java

示例9: createComputes

import com.vmware.xenon.common.UriUtils; //导入依赖的package包/类
/**
 * Create given number of computes with given endpointLinks and tenantLink.
 */
private List<String> createComputes(int count, Set<String> endpointLinks, String tenantLink) {
    List<String> computeLinks = new ArrayList<>();

    ComputeState computeState = new ComputeState();
    computeState.descriptionLink = "description-link";
    computeState.id = UUID.randomUUID().toString();
    computeState.name = computeState.id;
    computeState.tenantLinks = Collections.singletonList(tenantLink);
    computeState.endpointLinks = endpointLinks;

    for (int i = 0; i < count; i++) {
        Operation op = Operation
                .createPost(UriUtils.buildUri(this.host, ComputeService.FACTORY_LINK))
                .setBody(computeState);

        Operation response = this.host.waitForResponse(op);

        if (response.getStatusCode() == Operation.STATUS_CODE_OK) {
            computeLinks.add(response.getBody(ComputeState.class).documentSelfLink);
        }
    }
    return computeLinks;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:27,代码来源:ResourceGroomerTaskServiceTest.java

示例10: checkInMemoryStatsPresent

import com.vmware.xenon.common.UriUtils; //导入依赖的package包/类
/**
 * Perform check to verify that every compute resource has stats generated for all the metric
 * keys using which stats aggregation was performed on resources.
 */
private void checkInMemoryStatsPresent(ServiceDocumentQueryResult res) {
    for (Map.Entry<String, Object> resourceMap : res.documents.entrySet()) {
        ServiceStats resStats = this.host.getServiceState(null, ServiceStats.class,
                UriUtils.buildStatsUri(createServiceURI(host, null, resourceMap.getKey())));
        int statCount = 0;
        for (ServiceStat stat : resStats.entries.values()) {
            for (String key : AzureTestUtil.getMetricNames()) {
                if (stat.name.startsWith(key)) {
                    statCount++;
                    break;
                }
            }
        }
        // after stats aggregation all resources should have all metrics.
        assertEquals("Did not find in-memory stats",
                AzureTestUtil.getMetricNames().size(), statCount);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:23,代码来源:LongRunEndToEndAzureStatsAggregation.java

示例11: verifySocialNetworkHost

import com.vmware.xenon.common.UriUtils; //导入依赖的package包/类
private void verifySocialNetworkHost() throws Throwable {
    host.waitForServiceAvailable(RootNamespaceService.SELF_LINK);

    URI rootUri = UriUtils.buildUri(socialNetworkHost, RootNamespaceService.class);
    host.testStart(1);

    Operation get = Operation
            .createGet(rootUri)
            .setCompletion((operation, error) -> {
                if (error != null) {
                    host.failIteration(error);
                } else {
                    validateRootResponse(operation);
                    host.completeIteration();
                }
            });
    host.send(get);
    host.testWait();
}
 
开发者ID:stonebai,项目名称:SocialNetworkWithXenon,代码行数:20,代码来源:TestSocialNetworkHost.java

示例12: testCRUD

import com.vmware.xenon.common.UriUtils; //导入依赖的package包/类
@Test
public void testCRUD() throws Throwable {
    URI factoryUri = UriUtils.buildUri(host, UserAccountService.FACTORY_LINK);
    UserAccountService.UserAccountServiceState userAccountServiceState = new
            UserAccountService.UserAccountServiceState();

    userAccountServiceState.email = INITIAL_USER_ACCOUNT_EMAIL;
    userAccountServiceState.userName = INITIAL_USER_ACCOUNT_USER_NAME;
    userAccountServiceState.password = INITIAL_USER_ACCOUNT_PASSWORD;
    userAccountServiceState.documentSelfLink = UUID.randomUUID().toString();
    URI childUri = UriUtils.buildUri(host, UserAccountService.FACTORY_LINK + "/" +
            userAccountServiceState.documentSelfLink);

    testCreateService(factoryUri, userAccountServiceState);
    testPost(childUri);
    testPatch(childUri);
    testPut(childUri);
    testDelete(childUri);
}
 
开发者ID:stonebai,项目名称:SocialNetworkWithXenon,代码行数:20,代码来源:TestUserAccountService.java

示例13: getDocumentTemplate

import com.vmware.xenon.common.UriUtils; //导入依赖的package包/类
@Override
public ServiceDocument getDocumentTemplate() {
    ServiceDocument td = super.getDocumentTemplate();
    // enable metadata indexing
    td.documentDescription.documentIndexingOptions =
            EnumSet.of(DocumentIndexingOption.INDEX_METADATA);
    ServiceUtils.setRetentionLimit(td);
    SubnetState template = (SubnetState) td;

    template.id = UUID.randomUUID().toString();
    template.subnetCIDR = "10.1.0.0/16";
    template.name = "sub-network";
    template.networkLink = UriUtils.buildUriPath(NetworkService.FACTORY_LINK,
            "on-prem-network");
    template.dnsServerAddresses = new ArrayList<>();
    template.dnsServerAddresses.add("10.12.14.12");
    template.gatewayAddress = "10.1.0.1";
    template.supportPublicIpAddress = Boolean.TRUE;
    template.defaultForZone = Boolean.TRUE;

    return template;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:23,代码来源:SubnetService.java

示例14: performDiskRequest

import com.vmware.xenon.common.UriUtils; //导入依赖的package包/类
private String performDiskRequest(DiskService.DiskState diskState,
        ProvisionDiskTaskService.ProvisionDiskTaskState.SubStage subStage) throws Throwable {
    ProvisionDiskTaskService.ProvisionDiskTaskState provisionTask = new ProvisionDiskTaskService.ProvisionDiskTaskState();
    provisionTask.taskSubStage = subStage;

    provisionTask.diskLink = diskState.documentSelfLink;
    provisionTask.isMockRequest = isMock();

    provisionTask.documentExpirationTimeMicros =
            Utils.getNowMicrosUtc() + TimeUnit.MINUTES.toMicros(
                    DISK_REQUEST_TIMEOUT_MINUTES);
    provisionTask.tenantLinks = this.endpointState.tenantLinks;

    provisionTask = TestUtils.doPost(this.host,
            provisionTask, ProvisionDiskTaskService.ProvisionDiskTaskState.class,
            UriUtils.buildUri(this.host, ProvisionDiskTaskService.FACTORY_LINK));

    return provisionTask.documentSelfLink;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:20,代码来源:TestVSphereComputeDiskDay2Service.java

示例15: patchAdapter

import com.vmware.xenon.common.UriUtils; //导入依赖的package包/类
private void patchAdapter(NicSecurityGroupsTaskState taskState) {
    // use the first security group
    sendRequest(Operation.createGet(
            UriUtils.buildUri(this.getHost(), taskState.securityGroupLinks.get(0)))
            .setCompletion((o, e) -> {
                if (e != null) {
                    sendSelfPatch(TaskState.TaskStage.FAILED, e);
                    return;
                }
                SecurityGroupState securityGroupState = o.getBody(SecurityGroupState.class);
                NicSecurityGroupsRequest req = toReq(taskState,
                        securityGroupState);

                sendRequest(Operation
                        .createPatch(
                                taskState.adapterReference)
                        .setBody(req)
                        .setCompletion(
                                (oo, ee) -> {
                                    if (ee != null) {
                                        sendSelfPatch(TaskState.TaskStage.FAILED, ee);
                                        return;
                                    }
                                }));
            }));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:27,代码来源:NicSecurityGroupsTaskService.java


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