• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Resty类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getJSON

import us.monoid.web.Resty; //导入依赖的package包/类
/**
	 * @param url
	 * @return Returns the JSON 
	 */
	private String getJSON(String url){
		JSONResource res = null;
		JSONObject obj = null;
		Resty resty = new Resty();
		
		try {
			res = resty.json(url);
			obj = res.toObject();
			
		} catch (IOException | JSONException e) {
			// TODO: not my favorite way but does the trick
//			e.printStackTrace();
			return getJSON(url);
		}
		
		return obj.toString();
	}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:22,代码来源:AnalysisDrilldown.java


示例2: getLatestBuildResults

import us.monoid.web.Resty; //导入依赖的package包/类
public Result getLatestBuildResults() {
    Result result = new Result();
    try {
        Resty resty = new Resty();
        resty.authenticate(url, login, pass.toCharArray());
        XMLResource resource = resty.xml(url + "/app/rest/builds/buildType:" + buildType + ",lookupLimit:1");
        Boolean hasNext = true;
        String testOccurrences = url + resource.get("//testOccurrences/@href").item(0).getNodeValue();
        while (hasNext) {
            XMLResource results = resty.xml(testOccurrences);
            NodeList nodeList = results.get("//testOccurrences/@nextHref");
            hasNext = (nodeList.getLength() > 0 && (testOccurrences = url + nodeList.item(0).getNodeValue()) != null);
            nodeList = results.get("//testOccurrence");
            if (nodeList != null) {
                for (int i = 0; i < nodeList.getLength(); i++) {
                    NamedNodeMap attributes = nodeList.item(i).getAttributes();
                    result.addResult(attributes.getNamedItem("name").getNodeValue(), attributes.getNamedItem("status").getNodeValue());
                }
            }
        }
    } catch (Exception e) {/**/}
    return result;
}
 
开发者ID:atinfo,项目名称:at.info-knowledge-base,代码行数:24,代码来源:TeamCity.java


示例3: execute

import us.monoid.web.Resty; //导入依赖的package包/类
@Override
public HttpResponse execute(final String url) {
    HttpURLConnection httpConnection = null;
    try {
        final Resty resty = new Resty();
        if (isProxySet()) {
            resty.setProxy(proxyHost, proxyPort);
        }
        final TextResource textResource = resty.text(url);
        httpConnection = textResource.http();

        return toHttpResponse(textResource, httpConnection);

    } catch (IOException ioEx) {
        throw new HipChatNotificationPluginException("Error opening connection to HipChat URL: [" + ioEx.getMessage() + "].", ioEx);

    } finally {
        if (httpConnection != null) {
            httpConnection.disconnect();
        }
    }
}
 
开发者ID:hbakkum,项目名称:rundeck-hipchat-plugin,代码行数:23,代码来源:RestyHttpRequestExecutor.java


示例4: wgetResty

import us.monoid.web.Resty; //导入依赖的package包/类
/**
 * Same than above, but using resty. Way easier tbh.
 *
 * @param url The URL to get the object from.
 * @return The object as a parsed string.
 */
public static String wgetResty(String url) {
	try {
		return new Resty().identifyAsMozilla().text(url).toString();
	} catch (IOException e) {
		log.warn("Error Fetching Data from URL: " + url, e);
	}

	return null;
}
 
开发者ID:Mantaro,项目名称:MantaroRPG,代码行数:16,代码来源:Utils.java


示例5: getServer

import us.monoid.web.Resty; //导入依赖的package包/类
public static URI getServer(String regionName) {
    try {
        return URI.create("ws://" + new Resty().text(requestURL, form(data("region", regionName))).toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:pascoej,项目名称:ajario,代码行数:9,代码来源:ServerChooserUtil.java


示例6: getJSON

import us.monoid.web.Resty; //导入依赖的package包/类
/**
 * @param url
 * @return Returns the JSON as JSON Resource
 */
private JSONResource getJSON(String url) throws uQasarException{
	JSONResource res = null;
	Resty resty = new Resty();

	// Connection counter +1
	counter +=1;

	// Replaces spaces in URL with char %20
	url = url.replaceAll(" ", "%20");

	try {
		res = resty.json(url);

	} catch (IOException e) {

		// Check if the limit of trials has been reached
		if(counter<counterLimit){
			return getJSON(url);} else
				throw new uQasarException("Cubes Server is not availabe at this moument, error to connect with " +url);
	}

	// Reset the connection counter to 0
	counter = 0;

	return res;
}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:31,代码来源:CubesDataService.java


示例7: urlEncodeMap

import us.monoid.web.Resty; //导入依赖的package包/类
public String urlEncodeMap(Map<String,String> fields) {
    StringBuffer params = new StringBuffer();
    Iterator<String> keys = fields.keySet().iterator();
    while(keys.hasNext()) {
        String key = keys.next();
        String value = fields.get(key);
        if(params.length() > 0) {
            params.append("&");
        }
        params.append(key+"="+Resty.enc(value));
    }
    return params.toString();
}
 
开发者ID:Clarify,项目名称:clarify-java,代码行数:14,代码来源:ClarifyClient.java


示例8: login

import us.monoid.web.Resty; //导入依赖的package包/类
public void login() throws IOException, LoginException {
    Resty r = new Resty();
    JSONResource authTickets = r.json(baseURL + "access/ticket",
            form("username=" + username + "@" + realm + "&password=" + password));
    try {
        authTicket = authTickets.get("data.ticket").toString();
        csrfPreventionToken = authTickets.get("data.CSRFPreventionToken").toString();
        authTicketIssuedTimestamp = new Date();
    } catch (Exception e) {
        throw new LoginException("Failed reading JSON response");
    }
}
 
开发者ID:justnom,项目名称:proxmox-plugin,代码行数:13,代码来源:Connector.java


示例9: authedClient

import us.monoid.web.Resty; //导入依赖的package包/类
private Resty authedClient() throws IOException, LoginException {
    checkIfAuthTicketIsValid();
    Resty r = new Resty();
    r.withHeader("Cookie", "PVEAuthCookie=" + authTicket);
    r.withHeader("CSRFPreventionToken", csrfPreventionToken);
    return r;
}
 
开发者ID:justnom,项目名称:proxmox-plugin,代码行数:8,代码来源:Connector.java


示例10: rollbackQemuMachineSnapshot

import us.monoid.web.Resty; //导入依赖的package包/类
public String rollbackQemuMachineSnapshot(String node, Integer vmid, String snapshotName)
        throws IOException, LoginException, JSONException {
    Resty r = authedClient();
    String resource = "nodes/" + node + "/qemu/" + vmid.toString() + "/snapshot/" + snapshotName + "/rollback";
    JSONResource response = r.json(baseURL + resource, form(""));
    return response.toObject().getString("data");
}
 
开发者ID:justnom,项目名称:proxmox-plugin,代码行数:8,代码来源:Connector.java


示例11: testTearDown

import us.monoid.web.Resty; //导入依赖的package包/类
/**
 * Check the tear down.
 */
@Test
public void testTearDown() throws IOException {
	// insert mock to test object
	firespottingIT.popupPage = this.popupPage;

	// mock rest client
	firespottingIT.restClient = mock(Resty.class);

	// mock some objects for session key
	RemoteWebDriver remoteWebDriver = mock(RemoteWebDriver.class);
	SessionId sessionId = mock(SessionId.class);
	when(popupPage.getDriver()).thenReturn(remoteWebDriver);
	when(remoteWebDriver.getSessionId()).thenReturn(sessionId);
	when(sessionId.toString()).thenReturn("72345863");

	doReturn("sauceUsername").when(firespottingIT).getSystemVariable("SAUCE_USERNAME");
	doReturn("sauceKey").when(firespottingIT).getSystemVariable("SAUCE_ACCESS_KEY");
	doReturn("platform").when(firespottingIT).getSystemVariable("PLATFORM");
	doReturn("travisBuildNr").when(firespottingIT).getSystemVariable("TRAVIS_BUILD_NUMBER");

	// run test method
	firespottingIT.tearDown();

	// is the method called to tear down correctly?
	verify(popupPage, atLeastOnce()).tearDown();

	// verify rest client actions if environment variables are set
	// @TODO: add better verification! (no more anyStrings; check the values!)
	verify(firespottingIT.restClient, atLeastOnce()).authenticate(anyString(), anyString(), anyString().toCharArray());
	verify(firespottingIT.restClient, atLeastOnce()).withHeader("Content-Type", "application/json");
}
 
开发者ID:quitschibo,项目名称:chrome-extension-selenium-example,代码行数:35,代码来源:FirespottingITTest.java


示例12: getRawResponseSync

import us.monoid.web.Resty; //导入依赖的package包/类
public String getRawResponseSync(Query query) {
    try {
        if (mMockSlowResponse) {
            Thread.sleep(10000);
        }
        String start = String.format(LOCATION_ARG, query.lat0, query.lng0);
        String end = String.format(LOCATION_ARG, query.lat1, query.lng1);
        String args = String.format(ARGS, encode(start), encode(end));
        String url = BASE_URL + args;
        return new Resty().text(url).toString();
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:ManuelPeinado,项目名称:GoogleDirectionsClient,代码行数:16,代码来源:GoogleDirectionsClient.java


示例13: startQemuMachine

import us.monoid.web.Resty; //导入依赖的package包/类
public String startQemuMachine(String node, Integer vmid) throws IOException, LoginException, JSONException {
    Resty r = authedClient();
    String resource = "nodes/" + node + "/qemu/" + vmid.toString() + "/status/start";
    JSONResource response = r.json(baseURL + resource, form(""));
    return response.toObject().getString("data");
}
 
开发者ID:justnom,项目名称:proxmox-plugin,代码行数:7,代码来源:Connector.java


示例14: stopQemuMachine

import us.monoid.web.Resty; //导入依赖的package包/类
public String stopQemuMachine(String node, Integer vmid) throws IOException, LoginException, JSONException {
    Resty r = authedClient();
    String resource = "nodes/" + node + "/qemu/" + vmid.toString() + "/status/stop";
    JSONResource response = r.json(baseURL + resource, form(""));
    return response.toObject().getString("data");
}
 
开发者ID:justnom,项目名称:proxmox-plugin,代码行数:7,代码来源:Connector.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CompositeTokenGranter类代码示例发布时间:2022-05-22
下一篇:
Java UnknownFormatFlagsException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap