@Override @Get public Representation get() { return new StringRepresentation("OK"); }
@Override @Get public Representation get() { final String opt = (String) getRequest().getAttributes().get("opt"); if ("disable_autobalancing".equalsIgnoreCase(opt)) { _helixMirrorMakerManager.disableAutoBalancing(); LOGGER.info("Disabled autobalancing!"); return new StringRepresentation("Disabled autobalancing!\n"); } else if ("enable_autobalancing".equalsIgnoreCase(opt)) { _helixMirrorMakerManager.enableAutoBalancing(); LOGGER.info("Enabled autobalancing!"); return new StringRepresentation("Enabled autobalancing!\n"); } LOGGER.info("No valid input!"); return new StringRepresentation("No valid input!\n"); }
@Override @Get public Representation get() { final String option = (String) getRequest().getAttributes().get("option"); if ("srcKafka".equals(option)) { if (_srcKafkaValidationManager == null) { LOGGER.warn("SourceKafkaClusterValidationManager is null!"); return new StringRepresentation("SrcKafkaValidationManager is not been initialized!"); } LOGGER.info("Trying to call validation on source kafka cluster!"); return new StringRepresentation(_srcKafkaValidationManager.validateSourceKafkaCluster()); } else { LOGGER.info("Trying to call validation on current cluster!"); return new StringRepresentation(_validationManager.validateExternalView()); } }
@Override @Delete public Representation delete() { final String topicName = (String) getRequest().getAttributes().get("topicName"); if (_autoTopicWhitelistingManager != null) { _autoTopicWhitelistingManager.addIntoBlacklist(topicName); } if (!_helixMirrorMakerManager.isTopicExisted(topicName)) { getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND); return new StringRepresentation( String.format("Failed to delete not existed topic: %s", topicName)); } try { _helixMirrorMakerManager.deleteTopicInMirrorMaker(topicName); return new StringRepresentation( String.format("Successfully finished delete topic: %s", topicName)); } catch (Exception e) { getResponse().setStatus(Status.SERVER_ERROR_INTERNAL); LOGGER.error("Failed to delete topic: {}, with exception: {}", topicName, e); return new StringRepresentation( String.format("Failed to delete topic: %s, with exception: %s", topicName, e)); } }
return new StringRepresentation(String.format( "Failed to add new topic: %s, it's not exsited in source kafka cluster!", topicName)); return new StringRepresentation(String.format( "Failed to add new topic: %s, it is already existed!", topicPartitionInfo.getTopic())); } else { _helixMirrorMakerManager.addTopicToMirrorMaker(topicPartitionInfo); return new StringRepresentation( String.format("Successfully add new topic: %s", topicPartitionInfo)); LOGGER.error("Got error during processing Post request", e); getResponse().setStatus(Status.SERVER_ERROR_INTERNAL); return new StringRepresentation( String.format("Failed to add new topic, with exception: %s", e));
@Override @Put("json") public Representation put(Representation entity) { try { String jsonRequest = entity.getText(); TopicPartition topicPartitionInfo = TopicPartition.init(jsonRequest); if (_autoTopicWhitelistingManager != null) { _autoTopicWhitelistingManager.removeFromBlacklist(topicPartitionInfo.getTopic()); } if (_helixMirrorMakerManager.isTopicExisted(topicPartitionInfo.getTopic())) { _helixMirrorMakerManager.expandTopicInMirrorMaker(topicPartitionInfo); return new StringRepresentation( String.format("Successfully expand topic: %s", topicPartitionInfo)); } else { getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND); return new StringRepresentation(String.format( "Failed to expand topic, topic: %s is not existed!", topicPartitionInfo.getTopic())); } } catch (IOException e) { LOGGER.error("Got error during processing Put request", e); getResponse().setStatus(Status.SERVER_ERROR_INTERNAL); return new StringRepresentation( String.format("Failed to expand topic, with exception: %s", e)); } }
List<String> topicLists = _helixMirrorMakerManager.getTopicLists(); if (topicLists == null || topicLists.isEmpty()) { return new StringRepresentation("No topic is added in MirrorMaker Controller!"); } else { return new StringRepresentation(String .format("Current serving topics: %s", Arrays.toString(topicLists.toArray()))); return new StringRepresentation(responseJson.toJSONString()); } else { getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND); return new StringRepresentation(String .format("Failed to get ExternalView for topic: %s, it is not existed!", topicName)); LOGGER.error("Got error during processing Get request", e); getResponse().setStatus(Status.SERVER_ERROR_INTERNAL); return new StringRepresentation(String .format("Failed to get ExternalView for topic: %s, with exception: %s", topicName, e));
idealState.append(new StringRepresentation(resultList.toJSONString())); partitionAssignment.append(new StringRepresentation(resultList.toJSONString()));
@Get("txt") public Representation get() { setStatus(Status.SUCCESS_OK); return new StringRepresentation("Hi"); }
/** * Handle the HTTP GET method by returning a simple textual representation. */ @Override protected Representation get() throws ResourceException { System.out.println("The GET method of root resource was invoked."); return new StringRepresentation("This is the root resource"); }
/** * Constructor from a JSON string. * * @param jsonString * The JSON string. */ public JsonRepresentation(String jsonString) { super(MediaType.APPLICATION_JSON); setCharacterSet(CharacterSet.UTF_8); this.jsonRepresentation = new StringRepresentation(jsonString); }
@Override @Get public Representation get() { return new StringRepresentation("OK\n"); }
@Override @Get public Representation get() { return new StringRepresentation("OK"); }
/** * Constructor from a JSON string. * * @param jsonString * The JSON string. */ public JsonRepresentation(String jsonString) { super(MediaType.APPLICATION_JSON); setCharacterSet(CharacterSet.UTF_8); this.jsonRepresentation = new StringRepresentation(jsonString); }
protected Representation executeStatic(String query, String contextClassifierQualifiedName, String type) { if (type.equalsIgnoreCase("ocl")) { String result = UmlgOclExecutor.executeOclQueryAsJson(contextClassifierQualifiedName, query); return new JsonRepresentation(result); } else if (type.equalsIgnoreCase("groovy")) { String result = GroovyExecutor.INSTANCE.executeGroovyAsString(null, query); return new StringRepresentation(result); } else { throw new RuntimeException("Unknown query type " + type); } }
protected Representation execute(String query, Object contextId, String type) { if (type.equalsIgnoreCase("ocl")) { UmlgNode context = UMLG.get().getEntity(contextId); // UMLG.get().executeQueryToJson(UmlgQueryEnum.OCL, context.getId(), query); return new JsonRepresentation(UmlgOclExecutor.executeOclQueryAsJson(context, query)); } else if (type.equalsIgnoreCase("groovy")) { String result = GroovyExecutor.INSTANCE.executeGroovyAsString(contextId, query); return new StringRepresentation(result); } else { throw new RuntimeException("Unknown query type " + type); } }
@Override protected Representation representJson() { // Data String identity = ensureRequestAttribute( PARAM_IDENTITY, String.class, Status.CLIENT_ERROR_BAD_REQUEST ); // Context X509Context x509Ctx = newRootContext().x509Context( identity ); // Interaction X509 x509 = x509Ctx.x509(); // Representation return new StringRepresentation( valuesFactory.x509Detail( x509 ).toJSON(), MediaType.APPLICATION_JSON ); }
@Override protected Representation representJson() { // Data String identity = ensureRequestAttribute( PARAM_IDENTITY, String.class, Status.CLIENT_ERROR_BAD_REQUEST ); // Context EscrowedKeyPairContext ekpCtx = newRootContext().escrowedKeyPairContext( identity ); // Interaction EscrowedKeyPair ekp = ekpCtx.escrowedKeyPair(); // Representation return new StringRepresentation( restValuesFactory.escrowedKeyPair( ekp ).toJSON(), MediaType.APPLICATION_JSON ); }
@Override protected Representation representJson() { // Data String identity = ensureRequestAttribute( PARAM_IDENTITY, String.class, Status.CLIENT_ERROR_BAD_REQUEST ); // Context X509ProfileContext x509Ctx = newRootContext().x509ProfileContext( identity ); // Interaction X509Profile x509Profile = x509Ctx.x509Profile(); // Representation return new StringRepresentation( valuesFactory.x509Profile( x509Profile ).toJSON(), MediaType.APPLICATION_JSON ); }
@Get public Representation getIndexPageHtml(final Representation entity) throws ResourceException { this.checkAuthentication(BaseOasActions.WHOAMI_CHECK); Representation result = null; if(this.getRequest().getClientInfo().isAuthenticated()) { result = new StringRepresentation(this.getRequest().getClientInfo().getUser().getIdentifier()); } return result; }