当前位置: 首页>>代码示例>>Java>>正文


Java UnirestException类代码示例

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


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

示例1: mediaBookSubmit

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
@PostMapping("/result_book")
public String mediaBookSubmit(@ModelAttribute Media media, Model model, HttpServletRequest request ) {
    //System.out.println(media.getISBN());
    LinkedList<BookInfo> a = null;
    String maxResult= media.getMaxResult();
    if (maxResult.equals("")) maxResult="10";
    if (media.getTitle().trim().equals("") && media.getISBN().trim().equals("")) return "media_book";
    else if (media.getTitle().equals("") && media.getISBN().length()!=13) return "media_book";
    try {
        a = APIOperations.bookGetInfo(media.getTitle().trim(), media.getISBN().trim(), maxResult, media.getOrderBy());
    } catch (UnirestException e) {
        e.printStackTrace();
        return String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR);

    }
    RabbitSend.sendMediaRequest(media.getTitle(),"Book",request);
    if (a.size()==0) return "no_result";
    model.addAttribute("mediaList", a);
    return "result_book";
}
 
开发者ID:LithiumSR,项目名称:media_information_service,代码行数:21,代码来源:MainController.java

示例2: getAsJSONArray

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
/**
 * @return The json array get by performing request.
 */
public JSONArray getAsJSONArray() {
    JSONArray json;
    try {
        HttpResponse<JsonNode> response = request.asJson();
        checkRateLimit(response);
        handleErrorCode(response);
        JsonNode node = response.getBody();

        if (!node.isArray()) {
            handleErrorResponse(node.getObject());
            throw new UnirestException("The request returns a JSON Object. Json: "+node.getObject().toString(4));
        } else {
            json = node.getArray();
        }
    } catch (UnirestException e) {
        throw new JSONException("Error Occurred while getting JSON Array: "+e.getLocalizedMessage());
    }
    return json;
}
 
开发者ID:AlienIdeology,项目名称:J-Cord,代码行数:23,代码来源:Requester.java

示例3: deleteTransform

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
public JSONObject deleteTransform(int transformID) {
    JSONObject transform = new JSONObject();

    try {
        transform =
                Unirest.delete(MessageFormat.format("http://{0}:{1}/deployment/{2}/model/{3}", host, port, deploymentID, transformID))
                        .header("accept", "application/json")
                        .header("Content-Type", "application/json")
                        .asJson()
                        .getBody().getObject();
    } catch (UnirestException e) {
        e.printStackTrace();
    }

    return transform;
}
 
开发者ID:SkymindIO,项目名称:SKIL_Examples,代码行数:17,代码来源:Transform.java

示例4: deleteModel

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
public JSONObject deleteModel(int modelID) {
    JSONObject model = new JSONObject();

    try {
        model =
                Unirest.delete(MessageFormat.format("http://{0}:{1}/deployment/{2}/model/{3}", host, port, deploymentID, modelID))
                        .header("accept", "application/json")
                        .header("Content-Type", "application/json")
                        .asJson()
                        .getBody().getObject();
    } catch (UnirestException e) {
        e.printStackTrace();
    }

    return model;
}
 
开发者ID:SkymindIO,项目名称:SKIL_Examples,代码行数:17,代码来源:Model.java

示例5: retrieveAllFiles

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
public static List<String> retrieveAllFiles(String auth, String folder) throws IOException, UnirestException {
    List<String> lis= new LinkedList<String>();
    HttpResponse<JsonNode> jsonResponse = Unirest.get("https://www.googleapis.com/drive/v2/files/root/children?q=title='"+folder+"'").header("Authorization","Bearer "+auth).asJson();
    JSONObject jsonObject= new JSONObject(jsonResponse.getBody());
    JSONArray array = jsonObject.getJSONArray("array");
    for(int i=0;i<array.length();i++){
        JSONArray jarray=array.getJSONObject(i).getJSONArray("items");
        int j=jarray.length();
        while(j>0){
            String id=jarray.getJSONObject(0).getString("id");
            auxRetrieveAllFiles(lis,auth,"https://www.googleapis.com/drive/v2/files?includeTeamDriveItems=false&pageSize=500&q='"+id+"'%20in%20parents"+"&key="+ MISConfig.getGoogle_api(),id);
            j--;
        }

    }
    return lis;
}
 
开发者ID:LithiumSR,项目名称:media_information_service,代码行数:18,代码来源:GDrvAPIOp.java

示例6: setTransformState

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
public JSONObject setTransformState(int transformID, String state) {
    JSONObject transform = new JSONObject();

    try {
        transform =
                Unirest.delete(MessageFormat.format("http://{0}:{1}/deployment/{2}/model/{3}/state", host, port, deploymentID, transformID))
                        .header("accept", "application/json")
                        .header("Content-Type", "application/json")
                        .body(new JSONObject()
                                .put("name", state)
                                .toString())
                        .asJson()
                        .getBody().getObject();
    } catch (UnirestException e) {
        e.printStackTrace();
    }

    return transform;
}
 
开发者ID:SkymindIO,项目名称:SKIL_Examples,代码行数:20,代码来源:Transform.java

示例7: getAuthToken

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
public String getAuthToken(String userId, String password) {
    String authToken = null;

    try {
        authToken =
                Unirest.post(MessageFormat.format("http://{0}:{1}/login", host, port))
                        .header("accept", "application/json")
                        .header("Content-Type", "application/json")
                        .body(new JSONObject() //Using this because the field functions couldn't get translated to an acceptable json
                                .put("userId", userId)
                                .put("password", password)
                                .toString())
                        .asJson()
                        .getBody().getObject().getString("token");
    } catch (UnirestException e) {
        e.printStackTrace();
    }

    return authToken;
}
 
开发者ID:SkymindIO,项目名称:SKIL_Examples,代码行数:21,代码来源:Authorization.java

示例8: getIdentifier

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
public String getIdentifier(String token) throws UnirestException, InvalidAccountException {
    HttpResponse<JsonNode> me = Unirest.get("https://oauth.reddit.com/api/v1/me")
            .header("Authorization", "bearer " + token)
            .header("User-Agent", "pxls.space")
            .asJson();
    JSONObject json = me.getBody().getObject();
    if (json.has("error")) {
        return null;
    } else {
        long accountAgeSeconds = (System.currentTimeMillis() / 1000 - json.getLong("created"));
        long minAgeSeconds = App.getConfig().getDuration("oauth.reddit.minAge", TimeUnit.SECONDS);
        if (accountAgeSeconds < minAgeSeconds){
            long days = minAgeSeconds / 86400;
            throw new InvalidAccountException("Account too young");
        } else if (!json.getBoolean("has_verified_email")) {
            throw new InvalidAccountException("Account must have a verified e-mail");
        }
        return json.getString("name");
    }
}
 
开发者ID:xSke,项目名称:Pxls,代码行数:21,代码来源:RedditAuthService.java

示例9: setModelState

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
public JSONObject setModelState(int modelID, String state) {
    JSONObject model = new JSONObject();

    try {
        model =
                Unirest.delete(MessageFormat.format("http://{0}:{1}/deployment/{2}/model/{3}/state", host, port, deploymentID, modelID))
                        .header("accept", "application/json")
                        .header("Content-Type", "application/json")
                        .body(new JSONObject()
                                .put("name", state)
                                .toString())
                        .asJson()
                        .getBody().getObject();
    } catch (UnirestException e) {
        e.printStackTrace();
    }

    return model;
}
 
开发者ID:SkymindIO,项目名称:SKIL_Examples,代码行数:20,代码来源:Model.java

示例10: deleteKNN

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
public JSONObject deleteKNN(int knnID) {
    JSONObject knn = new JSONObject();

    try {
        knn =
                Unirest.delete(MessageFormat.format("http://{0}:{1}/deployment/{2}/model/{3}", host, port, deploymentID, knnID))
                        .header("accept", "application/json")
                        .header("Content-Type", "application/json")
                        .asJson()
                        .getBody().getObject();
    } catch (UnirestException e) {
        e.printStackTrace();
    }

    return knn;
}
 
开发者ID:SkymindIO,项目名称:SKIL_Examples,代码行数:17,代码来源:KNN.java

示例11: getIdentifier

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
public String getIdentifier(String token) throws UnirestException, InvalidAccountException {
    HttpResponse<JsonNode> me = Unirest.get("https://api.vk.com/method/users.get?access_token=" + token)
            .header("User-Agent", "pxls.space")
            .asJson();
    JSONObject json = me.getBody().getObject();

    if (json.has("error")) {
        return null;
    } else {
        try {
            return Integer.toString(json.getJSONArray("response").getJSONObject(0).getInt("uid"));
        } catch (JSONException e) {
            return null;
        }
    }
}
 
开发者ID:xSke,项目名称:Pxls,代码行数:17,代码来源:VKAuthService.java

示例12: methodSetUp

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
@Before
public void methodSetUp() throws IOException, UnirestException {
    // one commit with four decisions is always available and we have the same decisions as eadls
    // in our code repo
    seRepoTestServer.createRepository();
    seRepoTestServer.createCommit(getBasicDecisionsAsSeItemsWithContent(), CommitMode.ADD_UPDATE);

    DecisionSourceMapping.clear();
    Path code = codeBase.getRoot().toPath();
    codeRepoMock = new CodeRepoMock(code);
    codeRepoMock.createClassesForEadls(getBasicDecisionsAsEadl());

    commander.parse(InitCommand.NAME, "-u", seRepoTestServer.LOCALHOST_SEREPO, "-p", TEST_REPO,
            "-s", code.toString());
    INIT_COMMAND.initialize();
}
 
开发者ID:adr,项目名称:eadlsync,代码行数:17,代码来源:CommandTest.java

示例13: auxRetrieveAllFiles

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
private static void auxRetrieveAllFiles(List<String> lis,String auth, String link, String parents) throws IOException, UnirestException {
    HttpResponse<JsonNode> jsonResponse = Unirest.get(link).header("Authorization","Bearer "+auth).asJson();
    JSONObject jsonObject = new JSONObject(jsonResponse.getBody());
    JSONArray array = jsonObject.getJSONArray("array");
    for (int j=0;j<array.length();j++){
        JSONArray jarray=array.getJSONObject(j).getJSONArray("items");
        for(int i = 0; i < jarray.length(); i++)
        {
            if(jarray.getJSONObject(i).has("mimeType") && !jarray.getJSONObject(i).get("mimeType").equals("application/vnd.google-apps.folder")){
                String name= jarray.getJSONObject(i).getString("title");
                lis.add(jarray.getJSONObject(i).getString("title"));
            }
            else {
                if(jarray.getJSONObject(i).has("id")){
                    auxRetrieveAllFiles(lis,auth,"https://www.googleapis.com/drive/v2/files?includeTeamDriveItems=false&pageSize=500&q='"+jarray.getJSONObject(i).get("id")+"'%20in%20parents"+"&key="+ MISConfig.getGoogle_api(),parents);
                }
            }
        }
        if(array.getJSONObject(j).has("nextLink")){
            String next=array.getJSONObject(j).getString("nextLink");
            auxRetrieveAllFiles(lis,auth,next,parents);
        }
    }


}
 
开发者ID:LithiumSR,项目名称:media_information_service,代码行数:27,代码来源:GDrvAPIOp.java

示例14: getAllDeployments

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
public JSONArray getAllDeployments() {
    JSONArray deployments = new JSONArray();

    try {
        deployments =
                Unirest.get(MessageFormat.format("http://{0}:{1}/deployments", host, port))
                        .header("accept", "application/json")
                        .header("Content-Type", "application/json")
                        .asJson()
                        .getBody().getArray();
    } catch (UnirestException e) {
        e.printStackTrace();
    }

    return deployments;
}
 
开发者ID:SkymindIO,项目名称:SKIL_Examples,代码行数:17,代码来源:Deployment.java

示例15: finish

import com.mashape.unirest.http.exceptions.UnirestException; //导入依赖的package包/类
@Override
public void finish() {
	String title = (String) super.getResponses().get(0);
	if(title.length() > 400) {
		super.sendMessage("Error: Title length cannot be greater than 400 characters");
		super.exit();
	}
	boolean multi = (boolean) super.getResponses().get(1);
	String[] options = super.getResponses().subList(2, super.getResponses().size())
			.toArray(new String[super.getResponses().size() - 2]);
	if(options.length < 2 || options.length > 30) {
		super.sendMessage("Error: You must have between 2 and 30 options (inclusive)");
		super.exit();
	}
	StrawpollObject poll = new StrawpollObject(title, multi, options);
	try {
		super.sendMessage("http://www.strawpoll.me/" + poll.createPoll());
	} catch (UnirestException e) {
		super.sendMessage("Sorry, something went wrong creating your Strawpoll - Might be over my limits!");
		e.printStackTrace();
	}
	super.exit();
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:24,代码来源:Strawpoll.java


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