Java Code Examples for com.sun.jersey.api.json.JSONConfiguration

The following are top voted examples for showing how to use com.sun.jersey.api.json.JSONConfiguration. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: telegram-bot_misebot   File: Webhook.java   View source code 7 votes vote down vote up
public void startServer() throws TelegramApiException {
    SSLContextConfigurator sslContext = new SSLContextConfigurator();

    // set up security context
    sslContext.setKeyStoreFile(KEYSTORE_SERVER_FILE); // contains server keypair
    sslContext.setKeyStorePass(KEYSTORE_SERVER_PWD);

    ResourceConfig rc = new ResourceConfig();
    rc.register(restApi);
    rc.register(JacksonFeature.class);
    rc.property(JSONConfiguration.FEATURE_POJO_MAPPING, true);
    final HttpServer grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(
            getBaseURI(),
            rc,
            true,
            new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(false));
    try {
        grizzlyServer.start();
    } catch (IOException e) {
        throw new TelegramApiException("Error starting webhook server", e);
    }
}
 
Example 2
Project: endpoint-health   File: EndPointHealthServletModule.java   View source code 6 votes vote down vote up
@Override
protected void configureServlets() {
    filter("/services/*").through(PersistFilter.class);

    final Map<String, String> parameters = Maps.newHashMap();

    parameters.put(JSONConfiguration.FEATURE_POJO_MAPPING, "true");
    parameters.put("com.sun.jersey.config.property.packages", "spypunk.ephealth");
    parameters.put("com.sun.jersey.spi.container.ContainerResponseFilters",
        "com.sun.jersey.api.container.filter.GZIPContentEncodingFilter");

    serve("/services/*").with(GuiceContainer.class, parameters);

    bind(LockService.class).to(LockServiceImpl.class);
    bind(EndPointCheckerFactory.class).to(EndPointCheckerFactoryImpl.class);
    bind(EndPointCheckService.class).to(EndPointCheckServiceImpl.class);
    bind(EndPointCheckSchedulerService.class).to(EndPointCheckSchedulerServiceImpl.class);
    bind(EndPointService.class).to(EndPointServiceImpl.class);
    bind(EndPointResource.class).to(EndPointResourceImpl.class);
    bind(EndPointCheckResource.class).to(EndPointCheckResourceImpl.class);
}
 
Example 3
Project: fuck_zookeeper   File: JAXBContextResolver.java   View source code 6 votes vote down vote up
public JAXBContextResolver() throws Exception {
    Class[] typesArr =
        new Class[]{ZPath.class, ZStat.class, ZChildrenJSON.class};
    typesSet = new HashSet<Class>(Arrays.asList(typesArr));
    context = new JSONJAXBContext(
            JSONConfiguration.mapped()
                .arrays("children")
                .nonStrings("czxid")
                .nonStrings("mzxid")
                .nonStrings("ctime")
                .nonStrings("mtime")
                .nonStrings("version")
                .nonStrings("cversion")
                .nonStrings("aversion")
                .nonStrings("ephemeralOwner")
                .nonStrings("dataLength")
                .nonStrings("numChildren")
                .nonStrings("pzxid")
                .build(),
            typesArr);
}
 
Example 4
Project: https-github.com-apache-zookeeper   File: JAXBContextResolver.java   View source code 6 votes vote down vote up
public JAXBContextResolver() throws Exception {
    Class[] typesArr =
        new Class[]{ZPath.class, ZStat.class, ZChildrenJSON.class};
    typesSet = new HashSet<Class>(Arrays.asList(typesArr));
    context = new JSONJAXBContext(
            JSONConfiguration.mapped()
                .arrays("children")
                .nonStrings("czxid")
                .nonStrings("mzxid")
                .nonStrings("ctime")
                .nonStrings("mtime")
                .nonStrings("version")
                .nonStrings("cversion")
                .nonStrings("aversion")
                .nonStrings("ephemeralOwner")
                .nonStrings("dataLength")
                .nonStrings("numChildren")
                .nonStrings("pzxid")
                .build(),
            typesArr);
}
 
Example 5
Project: ZooKeeper   File: JAXBContextResolver.java   View source code 6 votes vote down vote up
public JAXBContextResolver() throws Exception {
    Class[] typesArr =
        new Class[]{ZPath.class, ZStat.class, ZChildrenJSON.class};
    typesSet = new HashSet<Class>(Arrays.asList(typesArr));
    context = new JSONJAXBContext(
            JSONConfiguration.mapped()
                .arrays("children")
                .nonStrings("czxid")
                .nonStrings("mzxid")
                .nonStrings("ctime")
                .nonStrings("mtime")
                .nonStrings("version")
                .nonStrings("cversion")
                .nonStrings("aversion")
                .nonStrings("ephemeralOwner")
                .nonStrings("dataLength")
                .nonStrings("numChildren")
                .nonStrings("pzxid")
                .build(),
            typesArr);
}
 
Example 6
Project: galaxy-PROV   File: GalaxyApiTest.java   View source code 6 votes vote down vote up
@Test
    public void galaxyRestConnect() throws URISyntaxException, MalformedURLException, IOException, JSONException {
        //http://galaxy.readthedocs.io/en/master/lib/galaxy.webapps.galaxy.api.html#module-galaxy.webapps.galaxy.api.histories

        ClientConfig config = new DefaultClientConfig();
        Client client = Client.create(config);
        config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
        WebResource service = client.resource(new URI(gURL));

//        MultivaluedMap<String, String> params = new MultivaluedMapImpl();
//        params.add("key", gKey);
        ClientResponse responseHist = service.path("/api/histories").queryParam("key", gApiKey).accept("application/json").type("application/json").get(ClientResponse.class);
        System.out.println("----------");
        String r = responseHist.getEntity(String.class);
        Util.jsonPP(r);
        System.out.println("----------");

//        /api/tools
        ClientResponse responseTools = service.path("/api/tools").queryParam("key", gApiKey).accept("application/json").type("application/json").get(ClientResponse.class);
        System.out.println("----------");
        r = responseTools.getEntity(String.class);
        Util.jsonPP(r);
    }
 
Example 7
Project: StreamProcessingInfrastructure   File: JAXBContextResolver.java   View source code 6 votes vote down vote up
public JAXBContextResolver() throws Exception {
    Class[] typesArr =
        new Class[]{ZPath.class, ZStat.class, ZChildrenJSON.class};
    typesSet = new HashSet<Class>(Arrays.asList(typesArr));
    context = new JSONJAXBContext(
            JSONConfiguration.mapped()
                .arrays("children")
                .nonStrings("czxid")
                .nonStrings("mzxid")
                .nonStrings("ctime")
                .nonStrings("mtime")
                .nonStrings("version")
                .nonStrings("cversion")
                .nonStrings("aversion")
                .nonStrings("ephemeralOwner")
                .nonStrings("dataLength")
                .nonStrings("numChildren")
                .nonStrings("pzxid")
                .build(),
            typesArr);
}
 
Example 8
Project: bigstreams   File: JAXBContextResolver.java   View source code 6 votes vote down vote up
public JAXBContextResolver() throws Exception {
    Class[] typesArr =
        new Class[]{ZPath.class, ZStat.class, ZChildrenJSON.class};
    typesSet = new HashSet<Class>(Arrays.asList(typesArr));
    context = new JSONJAXBContext(
            JSONConfiguration.mapped()
                .arrays("children")
                .nonStrings("czxid")
                .nonStrings("mzxid")
                .nonStrings("ctime")
                .nonStrings("mtime")
                .nonStrings("version")
                .nonStrings("cversion")
                .nonStrings("aversion")
                .nonStrings("ephemeralOwner")
                .nonStrings("dataLength")
                .nonStrings("numChildren")
                .nonStrings("pzxid")
                .build(),
            typesArr);
}
 
Example 9
Project: bigstreams   File: JAXBContextResolver.java   View source code 6 votes vote down vote up
public JAXBContextResolver() throws Exception {
    Class[] typesArr =
        new Class[]{ZPath.class, ZStat.class, ZChildrenJSON.class};
    typesSet = new HashSet<Class>(Arrays.asList(typesArr));
    context = new JSONJAXBContext(
            JSONConfiguration.mapped()
                .arrays("children")
                .nonStrings("czxid")
                .nonStrings("mzxid")
                .nonStrings("ctime")
                .nonStrings("mtime")
                .nonStrings("version")
                .nonStrings("cversion")
                .nonStrings("aversion")
                .nonStrings("ephemeralOwner")
                .nonStrings("dataLength")
                .nonStrings("numChildren")
                .nonStrings("pzxid")
                .build(),
            typesArr);
}
 
Example 10
Project: music   File: MusicHandle.java   View source code 6 votes vote down vote up
public  static Map<String,Object> readSpecificRow(String keyspaceName, String tableName,String keyName, String keyValue){
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	
	WebResource webResource = client
			.resource(HalUtil.getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/"+tableName+"/rows?"+keyName+"="+keyValue);

	ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
	
	Map<String,Object> output = response.getEntity(Map.class);
	
	Map<String, Object> rowMap=null;
	for (Map.Entry<String, Object> entry : output.entrySet()){
		rowMap = (Map<String, Object>)entry.getValue();
		break;
	}

	return rowMap;	
}
 
Example 11
Project: music   File: MusicHandle.java   View source code 6 votes vote down vote up
public static void dropTable(String keyspaceName, String tableName){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonTable jsonTb = new JsonTable();
	jsonTb.setConsistencyInfo(consistencyInfo);

	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);

	WebResource webResource = client
			.resource(HalUtil.getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/"+tableName);

	ClientResponse response = webResource.type("application/json")
			.delete(ClientResponse.class, jsonTb);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
}
 
Example 12
Project: music   File: MusicHandle.java   View source code 6 votes vote down vote up
public static void dropKeySpace(String keyspaceName){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonKeySpace jsonKp = new JsonKeySpace();
	jsonKp.setConsistencyInfo(consistencyInfo);

	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);

	WebResource webResource = client
			.resource(HalUtil.getMusicNodeURL()+"/keyspaces/"+keyspaceName);

	ClientResponse response = webResource.type("application/json")
			.delete(ClientResponse.class, jsonKp);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
}
 
Example 13
Project: music   File: VotingApp.java   View source code 6 votes vote down vote up
private  void deleteCandidateEntryEventually(String candidateName){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonDelete jDel = new JsonDelete();
	jDel.setConsistencyInfo(consistencyInfo);
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url = musicHandle.getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/votecount/rows?name="+candidateName;
	System.out.println(url);
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json")
			.type("application/json").delete(ClientResponse.class, jDel);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus()+"url:"+url);

}
 
Example 14
Project: music   File: VotingApp.java   View source code 6 votes vote down vote up
public  Map<String,Object> readVoteCountForCandidate(String candidateName){
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url = musicHandle.getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/votecount/rows?name="+candidateName;
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
	
	Map<String,Object> output = response.getEntity(Map.class);
	return output;	
}
 
Example 15
Project: music   File: VotingApp.java   View source code 6 votes vote down vote up
public  Map<String,Object> readAllVotes(){
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url = musicHandle.getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/votecount/rows";
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
	
	Map<String,Object> output = response.getEntity(Map.class);
	return output;	
}
 
Example 16
Project: music   File: VotingApp.java   View source code 6 votes vote down vote up
private void dropKeySpace(){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonKeySpace jsonKp = new JsonKeySpace();
	jsonKp.setConsistencyInfo(consistencyInfo);

	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);

	WebResource webResource = client
			.resource(musicHandle.getMusicNodeURL()+"/keyspaces/"+keyspaceName);

	ClientResponse response = webResource.type("application/json")
			.delete(ClientResponse.class, jsonKp);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
}
 
Example 17
Project: music   File: MusicRestClient.java   View source code 6 votes vote down vote up
public void createStringMapTable(String keyspaceName, String tableName,Map<String,String> fields){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonTable jtab = new JsonTable();
	jtab.setFields(fields);
	jtab.setConsistencyInfo(consistencyInfo);

	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url = getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/"+tableName;
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json")
			.type("application/json").post(ClientResponse.class, jtab);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());

}
 
Example 18
Project: music   File: MusicRestClient.java   View source code 6 votes vote down vote up
public  void createRow(String keyspaceName, String tableName,Map<String, Object> values){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonInsert jIns = new JsonInsert();
	jIns.setValues(values);
	jIns.setConsistencyInfo(consistencyInfo);
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);

	String url =getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/"+tableName+"/rows";
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json")
			.type("application/json").post(ClientResponse.class, jIns);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus()+"url:"+url+"values:"+values);


}
 
Example 19
Project: music   File: MusicRestClient.java   View source code 6 votes vote down vote up
private void basicUpdateRow(String keyspaceName, String tableName, String primaryKeyName, String primaryKeyValue, Map<String, Object> values, Map<String,String> consistencyInfo){
	JsonInsert jIns = new JsonInsert();
	jIns.setValues(values);
	jIns.setConsistencyInfo(consistencyInfo);
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url =getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/"+tableName+"/rows?"+primaryKeyName+"="+primaryKeyValue;
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json")
			.type("application/json").put(ClientResponse.class, jIns);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus()+"url:"+url+" values:"+values);

}
 
Example 20
Project: music   File: MusicRestClient.java   View source code 6 votes vote down vote up
public  void deleteEntry(String keyspaceName, String tableName, String primaryKeyName, String primaryKeyValue){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonDelete jDel = new JsonDelete();
	jDel.setConsistencyInfo(consistencyInfo);
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url =getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/"+tableName+"/rows?"+primaryKeyName+"="+primaryKeyValue;
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json")
			.type("application/json").delete(ClientResponse.class, jDel);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus()+"url:"+url);

}
 
Example 21
Project: music   File: MusicRestClient.java   View source code 6 votes vote down vote up
public  Map<String,Object> readRow(String keyspaceName, String tableName, String primaryKeyName, String primaryKeyValue){
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url =getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/"+tableName+"/rows?"+primaryKeyName+"="+primaryKeyValue;
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
	
	Map<String,Object> output = response.getEntity(Map.class);
	return output;	
}
 
Example 22
Project: music   File: MusicRestClient.java   View source code 6 votes vote down vote up
public  Map<String,Object> readAllRows(String keyspaceName, String tableName){
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url =getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/"+tableName+"/rows";		
	WebResource webResource = client.resource(url);

	ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
	
	Map<String,Object> output = response.getEntity(Map.class);
	return output;	
}
 
Example 23
Project: music   File: MusicRestClient.java   View source code 6 votes vote down vote up
public void dropKeySpace(String keyspaceName){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonKeySpace jsonKp = new JsonKeySpace();
	jsonKp.setConsistencyInfo(consistencyInfo);

	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);

	WebResource webResource = client
			.resource(getMusicNodeURL()+"/keyspaces/"+keyspaceName);

	ClientResponse response = webResource.type("application/json")
			.delete(ClientResponse.class, jsonKp);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
}
 
Example 24
Project: music   File: MicroBenchMarks.java   View source code 6 votes vote down vote up
public String musicGet(){
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	
	String url = musicurl+"/keyspaces/"+keyspaceName+"/tables/votecount/rows?name="+userForGets;
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
	
	Map<String,Object> output = response.getEntity(Map.class);
	return "musicGet:"+url;	
}
 
Example 25
Project: music   File: MicroBenchMarks.java   View source code 6 votes vote down vote up
public  String cassaGet(){
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	
	String url = musicurl+"/keyspaces/"+keyspaceName+"/tables/votecount/rows?name="+userForGets;
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
	
	Map<String,Object> output = response.getEntity(Map.class);
	return "cassaGet:"+url;	
}
 
Example 26
Project: music   File: MicroBenchMarks.java   View source code 6 votes vote down vote up
private void zkCreate(String candidateName){
	//http://135.197.226.98:8080/MUSIC/rest/formal/purezk/shankarzknode
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);

	WebResource webResource = client
			.resource(musicurl+"/purezk/"+candidateName);

	ClientResponse response = webResource.accept("application/json")
			.type("application/json").post(ClientResponse.class);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
}
 
Example 27
Project: music   File: TestMusicE2E.java   View source code 6 votes vote down vote up
private  void deleteCandidateEntryEventually(String candidateName){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonDelete jDel = new JsonDelete();
	jDel.setConsistencyInfo(consistencyInfo);
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url = musicHandle.getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/votecount/rows?name="+candidateName;
	System.out.println(url);
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json")
			.type("application/json").delete(ClientResponse.class, jDel);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus()+"url:"+url);

}
 
Example 28
Project: music   File: TestMusicE2E.java   View source code 6 votes vote down vote up
public  Map<String,Object> readVoteCountForCandidate(String candidateName){
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url = musicHandle.getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/votecount/rows?name="+candidateName;
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
	
	Map<String,Object> output = response.getEntity(Map.class);
	return output;	
}
 
Example 29
Project: music   File: TestMusicE2E.java   View source code 6 votes vote down vote up
public  Map<String,Object> readAllVotes(){
	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);
	String url = musicHandle.getMusicNodeURL()+"/keyspaces/"+keyspaceName+"/tables/votecount/rows";
	WebResource webResource = client
			.resource(url);

	ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
	
	Map<String,Object> output = response.getEntity(Map.class);
	return output;	
}
 
Example 30
Project: music   File: TestMusicE2E.java   View source code 6 votes vote down vote up
private void dropKeySpace(){
	Map<String,String> consistencyInfo= new HashMap<String, String>();
	consistencyInfo.put("type", "eventual");

	JsonKeySpace jsonKp = new JsonKeySpace();
	jsonKp.setConsistencyInfo(consistencyInfo);

	ClientConfig clientConfig = new DefaultClientConfig();

	clientConfig.getFeatures().put(
			JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

	Client client = Client.create(clientConfig);

	WebResource webResource = client
			.resource(musicHandle.getMusicNodeURL()+"/keyspaces/"+keyspaceName);

	ClientResponse response = webResource.type("application/json")
			.delete(ClientResponse.class, jsonKp);

	if (response.getStatus() < 200 || response.getStatus() > 299) 
		throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());
}
 
Example 31
Project: SecureKeeper   File: JAXBContextResolver.java   View source code 6 votes vote down vote up
public JAXBContextResolver() throws Exception {
    Class[] typesArr =
        new Class[]{ZPath.class, ZStat.class, ZChildrenJSON.class};
    typesSet = new HashSet<Class>(Arrays.asList(typesArr));
    context = new JSONJAXBContext(
            JSONConfiguration.mapped()
                .arrays("children")
                .nonStrings("czxid")
                .nonStrings("mzxid")
                .nonStrings("ctime")
                .nonStrings("mtime")
                .nonStrings("version")
                .nonStrings("cversion")
                .nonStrings("aversion")
                .nonStrings("ephemeralOwner")
                .nonStrings("dataLength")
                .nonStrings("numChildren")
                .nonStrings("pzxid")
                .build(),
            typesArr);
}
 
Example 32
Project: SecureKeeper   File: JAXBContextResolver.java   View source code 6 votes vote down vote up
public JAXBContextResolver() throws Exception {
    Class[] typesArr =
        new Class[]{ZPath.class, ZStat.class, ZChildrenJSON.class};
    typesSet = new HashSet<Class>(Arrays.asList(typesArr));
    context = new JSONJAXBContext(
            JSONConfiguration.mapped()
                .arrays("children")
                .nonStrings("czxid")
                .nonStrings("mzxid")
                .nonStrings("ctime")
                .nonStrings("mtime")
                .nonStrings("version")
                .nonStrings("cversion")
                .nonStrings("aversion")
                .nonStrings("ephemeralOwner")
                .nonStrings("dataLength")
                .nonStrings("numChildren")
                .nonStrings("pzxid")
                .build(),
            typesArr);
}
 
Example 33
Project: TinyTank   File: DataServer.java   View source code 6 votes vote down vote up
private ClientResponse getClientResponse(Object st, String path) {
    String masterServer = "http://tinytank.lefrantguillaume.com/api/server/";

    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    Client client = Client.create(clientConfig);
    client.addFilter(new HTTPBasicAuthFilter("T0N1jjOQIDmA4cJnmiT6zHvExjoSLRnbqEJ6h2zWKXLtJ9N8ygVHvkP7Sy4kqrv", "lMhIq0tVVwIvPKSBg8p8YbPg0zcvihBPJW6hsEGUiS6byKjoZcymXQs5urequUo"));
    WebResource webResource = client.resource(masterServer + path);
    System.out.println("sending to data server : " + st);
    ClientResponse response = webResource
            .accept("application/json")
            .type("application/json")
            .post(ClientResponse.class, st);
    if (response.getStatus() != 200) {
        throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
    }
    System.out.println("response from data server : " + response);
    return response;
}
 
Example 34
Project: StreamBench   File: JAXBContextResolver.java   View source code 6 votes vote down vote up
public JAXBContextResolver() throws Exception {
    Class[] typesArr =
        new Class[]{ZPath.class, ZStat.class, ZChildrenJSON.class};
    typesSet = new HashSet<Class>(Arrays.asList(typesArr));
    context = new JSONJAXBContext(
            JSONConfiguration.mapped()
                .arrays("children")
                .nonStrings("czxid")
                .nonStrings("mzxid")
                .nonStrings("ctime")
                .nonStrings("mtime")
                .nonStrings("version")
                .nonStrings("cversion")
                .nonStrings("aversion")
                .nonStrings("ephemeralOwner")
                .nonStrings("dataLength")
                .nonStrings("numChildren")
                .nonStrings("pzxid")
                .build(),
            typesArr);
}
 
Example 35
Project: eway-rapid-java   File: RapidClientImpl.java   View source code 6 votes vote down vote up
/**
 * Fetches and configures a Web Resource to connect to eWAY
 *
 * @return A WebResource
 */
private WebResource getEwayWebResource() {
    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    Client client = Client.create(clientConfig);
    client.addFilter(new HTTPBasicAuthFilter(APIKey, password));

    if (this.debug) {
        client.addFilter(new LoggingFilter(System.out));
    }

    // Set additional headers
    RapidClientFilter rapidFilter = new RapidClientFilter();
    rapidFilter.setVersion(apiVersion);
    client.addFilter(rapidFilter);

    WebResource resource = client.resource(webUrl);
    return resource;
}
 
Example 36
Project: hops   File: TestRMWebServicesReservation.java   View source code 6 votes vote down vote up
private ClientResponse submitAndVerifyReservation(String path, String media,
    String reservationJson) throws Exception {
  JSONJAXBContext jc =
      new JSONJAXBContext(JSONConfiguration.mapped()
          .build(), ReservationSubmissionRequestInfo.class);
  JSONUnmarshaller unmarshaller = jc.createJSONUnmarshaller();
  ReservationSubmissionRequestInfo rsci =
      unmarshaller.unmarshalFromJSON(new StringReader(reservationJson),
          ReservationSubmissionRequestInfo.class);

  Thread.sleep(1000);
  ClientResponse response =
      constructWebResource(path).entity(rsci, MediaType.APPLICATION_JSON)
          .accept(media).post(ClientResponse.class);

  if (!this.isAuthenticationEnabled()) {
    assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus());
  }

  return response;
}
 
Example 37
Project: request-api   File: RequestApi.java   View source code 6 votes vote down vote up
/**
 * Process url.
 *
 * @return the client response
 * @throws Exception the exception
 */
private ClientResponse processUrl() throws Exception {
	ClientConfig clientConfig = new DefaultClientConfig();
	clientConfig.getFeatures().put( JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE );

	Client client = Client.create( clientConfig );

	WebResource webResource = createWebResource( client );
	webResource.accept( MediaType.APPLICATION_JSON );
	webResource.type( MediaType.APPLICATION_JSON );
	try {
		ClientResponse response = webResource.get( ClientResponse.class );

		if ( response.getStatus() != 200 ) {
			setStatus( STATUS_URL_NOK );
			throw new RuntimeException( "Failed : HTTP error code : " + response.getStatus() );
		}
		return response;

	} catch ( ClientHandlerException e ) {
		setStatus( STATUS_URL_NOK );
		throw new Exception( e );
	}

}
 
Example 38
Project: fiware-cosmos-ambari   File: PersistServiceTest.java   View source code 6 votes vote down vote up
@Test
public void testPersist() throws UniformInterfaceException, JSONException,
  IOException {
  ClientConfig clientConfig = new DefaultClientConfig();
  clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
  client = Client.create(clientConfig);
  WebResource webResource = client.resource("http://localhost:9998/persist");
  
  webResource.post("{\"xyx\" : \"t\"}");
  LOG.info("Done posting to the server");
  String output = webResource.get(String.class);
  LOG.info("All key values " + output);
  Map<String, String> jsonOutput = StageUtils.fromJson(output, Map.class);
  String value = jsonOutput.get("xyx");
  Assert.assertEquals("t", value);
  webResource = client.resource("http://localhost:9998/persist/xyx");
  output = webResource.get(String.class);
  Assert.assertEquals("t", output);
  LOG.info("Value for xyx " + output);
}
 
Example 39
Project: appstart   File: AppServletModule.java   View source code 6 votes vote down vote up
@Override
protected void configureServlets() {
	
	// filters
	// Objectify filter
	filter("/*").through(ObjectifyFilter.class);

	// servlets
	serve("/home").with(HomeServlet.class);
	
	// Jersey restful servlet
    HashMap<String, String> params = new HashMap<String, String>();
       params.put(PackagesResourceConfig.PROPERTY_PACKAGES, "uk.co.inetria.appstart.frontend.rest");
       params.put(JSONConfiguration.FEATURE_POJO_MAPPING, "true");
       // speed up jersey startup under appengine
       params.put(ResourceConfig.FEATURE_DISABLE_WADL, "true");
       
       serve("/api/*").with(GuiceContainer.class, params);
	
	
}
 
Example 40
Project: LoadBalanced_zk   File: JAXBContextResolver.java   View source code 6 votes vote down vote up
public JAXBContextResolver() throws Exception {
    Class[] typesArr =
        new Class[]{ZPath.class, ZStat.class, ZChildrenJSON.class};
    typesSet = new HashSet<Class>(Arrays.asList(typesArr));
    context = new JSONJAXBContext(
            JSONConfiguration.mapped()
                .arrays("children")
                .nonStrings("czxid")
                .nonStrings("mzxid")
                .nonStrings("ctime")
                .nonStrings("mtime")
                .nonStrings("version")
                .nonStrings("cversion")
                .nonStrings("aversion")
                .nonStrings("ephemeralOwner")
                .nonStrings("dataLength")
                .nonStrings("numChildren")
                .nonStrings("pzxid")
                .build(),
            typesArr);
}