public AdminRestletResource() { _helixMirrorMakerManager = (HelixMirrorMakerManager) getApplication().getContext() .getAttributes().get(HelixMirrorMakerManager.class.toString()); }
public TopicManagementRestletResource() { getVariants().add(new Variant(MediaType.TEXT_PLAIN)); getVariants().add(new Variant(MediaType.APPLICATION_JSON)); setNegotiated(false); _helixMirrorMakerManager = (HelixMirrorMakerManager) getApplication().getContext() .getAttributes().get(HelixMirrorMakerManager.class.toString()); _autoTopicWhitelistingManager = (AutoTopicWhitelistingManager) getApplication().getContext() .getAttributes().get(AutoTopicWhitelistingManager.class.toString()); if (getApplication().getContext().getAttributes() .containsKey(KafkaBrokerTopicObserver.class.toString())) { _srcKafkaBrokerTopicObserver = (KafkaBrokerTopicObserver) getApplication().getContext() .getAttributes().get(KafkaBrokerTopicObserver.class.toString()); } else { _srcKafkaBrokerTopicObserver = null; } }
public ValidationRestletResource() { getVariants().add(new Variant(MediaType.TEXT_PLAIN)); getVariants().add(new Variant(MediaType.APPLICATION_JSON)); setNegotiated(false); _validationManager = (ValidationManager) getApplication().getContext() .getAttributes().get(ValidationManager.class.toString()); if (getApplication().getContext().getAttributes() .containsKey(SourceKafkaClusterValidationManager.class.toString())) { _srcKafkaValidationManager = (SourceKafkaClusterValidationManager) getApplication().getContext() .getAttributes().get(SourceKafkaClusterValidationManager.class.toString()); } else { _srcKafkaValidationManager = null; } }
applicationContext.getAttributes().put(ControllerConf.class.toString(), _config); applicationContext.getAttributes().put(HelixMirrorMakerManager.class.toString(), _helixMirrorMakerManager); applicationContext.getAttributes().put(ValidationManager.class.toString(), _validationManager); applicationContext.getAttributes().put(SourceKafkaClusterValidationManager.class.toString(), _srcKafkaValidationManager); applicationContext.getAttributes().put(KafkaBrokerTopicObserver.class.toString(), _kafkaBrokerTopicObserverMap.get(SRC_KAFKA_CLUSTER)); applicationContext.getAttributes().put(AutoTopicWhitelistingManager.class.toString(), _autoTopicWhitelistingManager);
/** * For file uploads we are using commons-fileupload integration with restlet.org. We are storing one FileItemFactory * instance in context. This method simply encapsulates gettting it from Resource context. * * @return */ protected FileItemFactory getFileItemFactory( Context context ) { return (FileItemFactory) context.getAttributes().get( NexusApplication.FILEITEM_FACTORY ); }
private boolean isLocalAcessOnly() { String lo = (String) getContext().getAttributes() .get(LOCAL_ACCESS_ONLY); return (lo != null) && (lo.length() > 0) && Boolean.parseBoolean(lo); }
private static boolean isLocalAcessOnly() { String lo = (String) getResourceContext().getAttributes() .get(LOCAL_ACCESS_ONLY); return (lo != null) && (lo.length() > 0) && Boolean.parseBoolean(lo); }
public AdminRestletResource() { _helixMirrorMakerManager = (HelixMirrorMakerManager) getApplication().getContext() .getAttributes().get(HelixMirrorMakerManager.class.toString()); }
@Override protected void doInit() throws ResourceException { super.doInit(); Context ctx = getContext(); ConcurrentMap<String, Object> attribs = ctx.getAttributes(); clients = (ClientManager) attribs.get(ClientManager.class.getName()); tokens = (TokenManager) attribs.get(TokenManager.class.getName()); getLogger().fine("Found client store = " + clients); }
/** * Returns the hostname verifier by looking up the "hostnameVerifier" * attribute of the client's context. * * @return The hostname verifier or null. */ public HostnameVerifier getHostnameVerifier() { return (HostnameVerifier) ((getContext() == null) ? null : getContext() .getAttributes().get("hostnameVerifier")); }
/** * Returns the hostname verifier by looking up the "hostnameVerifier" * attribute of the client's context. * * @return The hostname verifier or null. */ public HostnameVerifier getHostnameVerifier() { return (HostnameVerifier) ((getContext() == null) ? null : getContext() .getAttributes().get("hostnameVerifier")); }
/** * Unget current authorization session. */ protected void ungetAuthSession() { String sessionId = getCookies().getFirstValue(ClientCookieID); // cleanup cookie. if (sessionId != null && sessionId.length() > 0) { ConcurrentMap<String, Object> attribs = getContext() .getAttributes(); attribs.remove(sessionId); } }
/** * Unget current authorization session. */ protected static void ungetAuthSession() { String sessionId = getResourceCookies().getFirstValue(ClientCookieID); // cleanup cookie. if (sessionId != null && sessionId.length() > 0) { ConcurrentMap<String, Object> attribs = getResourceContext() .getAttributes(); attribs.remove(sessionId); } }
public TopicManagementRestletResource() { getVariants().add(new Variant(MediaType.TEXT_PLAIN)); getVariants().add(new Variant(MediaType.APPLICATION_JSON)); setNegotiated(false); _conf = (ManagerConf) getApplication().getContext().getAttributes().get(ManagerConf.class.toString()); _helixMirrorMakerManager = (ControllerHelixManager) getApplication().getContext() .getAttributes().get(ControllerHelixManager.class.toString()); SourceKafkaClusterValidationManager srcKafkaValidationManager = (SourceKafkaClusterValidationManager) getApplication() .getContext().getAttributes().get(SourceKafkaClusterValidationManager.class.toString()); _clusterToObserverMap = srcKafkaValidationManager.getClusterToObserverMap(); }
private void validateState(Request request, Form params) throws Exception { String sessionId = request.getCookies().getFirstValue("_state"); String state = (String) getContext().getAttributes().get(sessionId); if (state != null && state.equals(params.getFirstValue(STATE))) { return; } // CSRF detected throw new Exception("The state does not match."); }
private String setupState(Response response) { String sessionId = UUID.randomUUID().toString(); byte[] secret = new byte[20]; random.nextBytes(secret); String state = Base64.encode(secret, false); CookieSetting cs = new CookieSetting("_state", sessionId); response.getCookieSettings().add(cs); getContext().getAttributes().put(sessionId, state); return state; }
public AdminRestletResource() { getVariants().add(new Variant(MediaType.TEXT_PLAIN)); getVariants().add(new Variant(MediaType.APPLICATION_JSON)); setNegotiated(false); _helixMirrorMakerManager = (ControllerHelixManager) getApplication().getContext() .getAttributes().get(ControllerHelixManager.class.toString()); }
StringRepresentation getStateModelRepresentation(String clusterName, String modelName) throws JsonGenerationException, JsonMappingException, IOException { Builder keyBuilder = new PropertyKey.Builder(clusterName); ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT); String message = ClusterRepresentationUtil.getClusterPropertyAsString(zkClient, clusterName, keyBuilder.stateModelDef(modelName), MediaType.APPLICATION_JSON); StringRepresentation representation = new StringRepresentation(message, MediaType.APPLICATION_JSON); return representation; }
StringRepresentation getControllerStatusUpdateRepresentation(String zkServerAddress, String clusterName, String sessionId, String messageType, String messageId) throws JsonGenerationException, JsonMappingException, IOException { Builder keyBuilder = new PropertyKey.Builder(clusterName); ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT); String message = ClusterRepresentationUtil.getPropertyAsString(zkClient, clusterName, keyBuilder.controllerTaskStatus(messageType, messageId), MediaType.APPLICATION_JSON); StringRepresentation representation = new StringRepresentation(message, MediaType.APPLICATION_JSON); return representation; } }
Router router = new Router(); // Remove final from this. router.attachDefault(HttpListener.class); Component component = new Component(); Context ctx = component.getApplication().getContext().createChildContext(); // Remove final ctx.getAttributes().put("mysharedobj", new MySharedObj()); org.restlet.Application myApp = new org.restlet.Application(ctx) { @Override public org.restlet.Restlet createInboundRoot() { return router; }; };