@Override public void handleStart(Operation post) { if (!post.hasBody()) { post.fail(new IllegalArgumentException("body is required")); return; } TenantState newState = post.getBody(TenantState.class); if (newState.id == null || newState.id.isEmpty()) { newState.id = UUID.randomUUID().toString(); } post.setBody(newState).complete(); }
private void performPut(Operation put, CompositeDescription putBody) { try { AssertUtil.assertTrue(putBody.getClass().equals(CompositeDescription.class), "State should be instance of CompositeDescription, not of any subclass."); this.setState(put, putBody); put.setBody(putBody).complete(); } catch (Throwable e) { put.fail(e); } }
@Override public void handlePatch(Operation patch) { LocalPrincipalState currentState = getState(patch); LocalPrincipalState patchState = patch.getBody(LocalPrincipalState.class); try { validatePrincipalPatch(patchState, currentState); PropertyUtils.mergeServiceDocuments(currentState, patchState); patch.complete(); } catch (Exception ex) { patch.fail(ex); } }
@Override public void handleStart(Operation startOp) { sendRequest(Operation .createGet(getHost(), UriUtils.buildUriPath(ManagementUriParts.CONFIG_PROPS, FileUtil.USER_RESOURCES_PATH_VARIABLE)) .setCompletion((res, ex) -> { if (ex == null && res.hasBody()) { ConfigurationState body = res.getBody(ConfigurationState.class); if (body.value != null && !body.value.isEmpty()) { String userResourcesPath = body.value; startExternalPopularImagesService(userResourcesPath); } } startOp.complete(); })); }
@Override public void handleStart(Operation start) { Operation.createPost(UriUtils.buildUri(this.serverUri, EventStreamService.SELF_LINK)) .setBody(new ServiceDocument()) .setHeadersReceivedHandler(i -> { setStat(STAT_NAME_IS_CONNECTED, 1.0); start.complete(); }) .setServerSentEventHandler(i -> adjustStat(STAT_NAME_EVENT_COUNT, 1.0)) .setCompletion((o, e) -> setStat(STAT_NAME_IS_CONNECTED, 0.0)) .sendWith(this); } }
private void registerClientCred(String caCert, String caKey, Operation startOp) { createClientCredentials(caCert, caKey) .setCompletion((o, e) -> { if (e != null) { startOp.fail(e); return; } startOp.complete(); }) .sendWith(this); }
private void registerClientCredIfNeeded(AuthCredentialsServiceState caCred, String caCert, String caKey, Operation startOp) { Operation.createGet(this, ManagementUriParts.AUTH_CREDENTIALS_CLIENT_LINK) .setCompletion((o, e) -> { if (e != null) { registerClientCred(caCert, caKey, startOp); return; } startOp.complete(); }) .sendWith(this); }
@Override public void handleStart(Operation start) { if (!start.hasBody()) { start.fail(new IllegalStateException("no body given")); return; } LocalFileServiceState state = start.getBody(LocalFileServiceState.class); if (state.localFileUri == null) { start.fail(new IllegalStateException("file scheme uri is required")); return; } start.complete(); }
@Override public void handleStart(Operation op) { if (op.hasBody()) { LoaderServiceState s = op.getBody(LoaderServiceState.class); if (s.loaderType == null) { s.loaderType = LoaderType.FILESYSTEM; } logFine("Initial path is %s", s.path); } super.setMaintenanceIntervalMicros(MAINTENANCE_INTERVAL_MICROS); op.complete(); }
@Override public void handleStart(Operation startOp) { sendRequest(Operation .createGet(getHost(), UriUtils.buildUriPath(ManagementUriParts.CONFIG_PROPS, FileUtil.USER_RESOURCES_PATH_VARIABLE)) .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_QUEUE_FOR_SERVICE_AVAILABILITY) .setCompletion((res, ex) -> { if (ex == null && res.hasBody()) { ConfigurationState body = res.getBody(ConfigurationState.class); if (body.value != null && !body.value.isEmpty()) { String userResourcesPath = body.value; startExternalContainerImageIconResourceServices(userResourcesPath); } } startOp.complete(); })); }
@Override public void handleStart(Operation start) { Operation.createPost(UriUtils.buildUri(this.serverUri, EventStreamService.SELF_LINK)) .setBody(new ServiceDocument()) .setHeadersReceivedHandler(i -> { setStat(STAT_NAME_IS_CONNECTED, 1.0); start.complete(); }) .setServerSentEventHandler(i -> adjustStat(STAT_NAME_EVENT_COUNT, 1.0)) .setCompletion((o, e) -> setStat(STAT_NAME_IS_CONNECTED, 0.0)) .sendWith(this); } }
@Override public void handlePost(Operation op) { if (op.hasBody()) { ServiceDocument body = 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; } } // the real work is done in the completion op.complete(); }