本文整理了Java中com.atlassian.sal.api.net.Request.execute
方法的一些代码示例,展示了Request.execute
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.execute
方法的具体详情如下:
包路径:com.atlassian.sal.api.net.Request
类名称:Request
方法名:execute
暂无
代码示例来源:origin: com.atlassian.applinks/applinks-plugin-core
public String execute()
throws ResponseException
{
return request.execute();
}
代码示例来源:origin: com.atlassian.refapp/platform-ctk-plugin
private void makeRequestExpectingUnauthorized(Request request) throws Exception {
request.execute(new ResponseHandler() {
public void handle(Response response) throws ResponseException {
assertEquals(HttpServletResponse.SC_UNAUTHORIZED, response.getStatusCode());
assertTrue(response.getResponseBodyAsString().contains("This resource requires WebSudo"));
}
});
}
代码示例来源:origin: com.atlassian.applinks/applinks-plugin-core
public void execute(final ResponseHandler responseHandler)
throws ResponseException
{
request.execute(responseHandler);
}
代码示例来源:origin: com.atlassian.applinks/applinks-common
public void execute(final ResponseHandler responseHandler)
throws ResponseException {
request.execute(responseHandler);
}
代码示例来源:origin: com.atlassian.applinks/applinks-common
public String execute()
throws ResponseException {
return request.execute();
}
代码示例来源:origin: com.atlassian.refapp/platform-ctk-plugin
/**
* Makes a non-OAuth request and expects a specific text.
*
* @param request request
* @param expectedText expected text
*/
public static void makeRequestExpectingText(Request request, final String expectedText) throws Exception {
request.execute(new ResponseHandler() {
public void handle(Response response) throws ResponseException {
assertEquals(HttpServletResponse.SC_OK, response.getStatusCode());
assertEquals(expectedText, response.getResponseBodyAsString());
}
});
}
代码示例来源:origin: com.atlassian.plugins.rest/atlassian-rest-module
@Override
public String execute()
throws ResponseException {
marshallEntity();
return delegateRequest.execute();
}
代码示例来源:origin: com.atlassian.refapp/platform-ctk-plugin
protected String get(URI uri) throws ResponseException {
Request request = createRequestWithBasicAuthentication(uri);
return request.execute();
}
代码示例来源:origin: com.atlassian.applinks/applinks-plugin
private Iterable<EntityReference> getEntities(final ApplicationLinkRequestFactory requestFactory)
throws CredentialsRequiredException, ResponseException {
final Request req = requestFactory.createRequest(Request.MethodType.GET,
RestUtil.REST_APPLINKS_URL + EntityResource.CONTEXT);
final List<EntityReference> entities = new ArrayList<EntityReference>();
req.execute(new ResponseHandler<Response>() {
public void handle(final Response response) throws ResponseException {
if (response.getStatusCode() == 200) {
Iterables.addAll(entities, response.getEntity(ReferenceEntityList.class).getEntities(typeAccessor));
} else {
throw new ResponseException(String.format("Failed to retrieve entity list, received %s response: %s",
response.getStatusCode(), response.getStatusText()));
}
}
});
return entities;
}
代码示例来源:origin: com.atlassian.refapp/platform-ctk-plugin
@Test
public void assert200() throws ResponseException {
URI uri = UriBuilder.fromUri(applicationProperties.getBaseUrl()).path("prettyurls").path("helloworld").build();
Request request = requestFactory.createRequest(Request.MethodType.GET, uri.toString());
request.execute(new ResponseHandler() {
@Override
public void handle(Response response) throws ResponseException {
assertEquals(200, response.getStatusCode());
}
});
}
代码示例来源:origin: com.atlassian.refapp/platform-ctk-plugin
@Test
public void assert404() throws ResponseException {
URI uri = UriBuilder.fromUri(applicationProperties.getBaseUrl()).path("prettyurls").path("path-that-does-not-exist").build();
Request request = requestFactory.createRequest(Request.MethodType.GET, uri.toString());
request.execute(new ResponseHandler() {
@Override
public void handle(Response response) throws ResponseException {
assertEquals(404, response.getStatusCode());
}
});
}
代码示例来源:origin: com.atlassian.applinks/applinks-common
/**
* Fetches consumer information from a remote applinked application, assuming it is running the OAuth plugin.
*
* @param applicationLink link to fetch the information from
* @return Consumer object representing the linked application
* @throws ResponseException if the fetch fails for any reason
*/
@Nonnull
public static Consumer fetchConsumerInformation(@Nonnull ApplicationLink applicationLink) throws ResponseException {
final Request<?, ?> request = Anonymous.createAnonymousRequest(applicationLink, Request.MethodType.GET,
Uris.uncheckedConcatenate(applicationLink.getRpcUrl(), CONSUMER_INFO_PATH).toString());
request.setHeader("Accept", "application/xml");
final ConsumerInformationResponseHandler handler = new ConsumerInformationResponseHandler();
request.execute(handler);
return handler.getConsumer();
}
代码示例来源:origin: com.atlassian.streams/streams-fisheye-plugin
public Iterable<ExternalActivityItem> getItems(ApplicationLink appLink, ExternalActivityItemSearchParams params) throws Exception
{
final String uri = remoteStreamsFeedUriBuilder.buildUri(appLink, params).toASCIIString();
try
{
final Request<?, ?> request = appLink.createAuthenticatedRequestFactory().createRequest(Request.MethodType.GET, uri);
request.setConnectionTimeout(CONNECTION_TIMEOUT);
request.setSoTimeout(SO_TIMEOUT);
return itemFactory.getItems(request.execute());
}
catch (Exception e)
{
log.warn("Cannot fetch remote feed from: " + uri);
throw e;
}
}
}
代码示例来源:origin: com.atlassian.studio/studio-theme-jira-plugin
public void execute(Map transientVars, Map args, PropertySet propertySet) throws WorkflowException
{
Issue issue = (Issue) transientVars.get("issue");
String projectKey = issue.getProjectObject().getKey();
ApplicationLink crucible = appLinksManager.getLinkedApplication(Application.CRUCIBLE.name(), projectKey);
Request<?> request = requestFactory.createRequest(Request.MethodType.POST,
crucible.getUrl() + CREATE_REVIEW_PATH + "?key=" + crucible.getRemoteKey() + "&issueKey=" + issue.getKey());
request.addTrustedTokenAuthentication();
try
{
request.execute();
}
catch (ResponseException re)
{
log.error("Error creating code review on Crucible", re);
}
}
}
代码示例来源:origin: com.atlassian.applinks/applinks-plugin
private boolean isRpcUrlValid(final URI url, final URI rpcUrl, final String username, final String password)
throws ResponseException {
// We send the rpcUrl parameter in a query parameter. For pre-3.4 versions of the REST resource, we also
// send it in the path.
// TODO If we know the server is using applinks 3.4, the rpcUrl path parameter can be empty
String pathUrl = getUrlFor(URIUtil.uncheckedConcatenate(url, RestUtil.REST_APPLINKS_URL), AuthenticationResource.class).rpcUrlIsReachable(internalHostApplication.getId().get(), rpcUrl, null).toString();
String urlWithQuery = pathUrl + "?url=" + URIUtil.utf8Encode(rpcUrl);
final Request request = requestFactory.createRequest(Request.MethodType.GET, urlWithQuery);
request.addBasicAuthentication(url.getHost(), username, password);
final Holder<Boolean> rpcUrlValid = new Holder<Boolean>(false);
request.execute(new ResponseHandler<Response>() {
public void handle(final Response restResponse) throws ResponseException {
if (restResponse.isSuccessful()) {
rpcUrlValid.set(true);
}
}
});
return rpcUrlValid.get();
}
}
代码示例来源:origin: com.atlassian.refapp/platform-ctk-plugin
@Test
public void testCanSendMultipartPutRequest() throws Exception {
Server server = new Server(0);
ServletHandler handler = new ServletHandler();
handler.addServletWithMapping(SetFilesServlet.class, "/*");
server.setHandler(handler);
try {
// start jetty.
server.start();
// now, make a request.
Request<?, ?> request = requestFactory.createRequest(Request.MethodType.PUT, "http://localhost:" + getActivePort(server));
request.setFiles(Collections.singletonList(new RequestFilePart(testFile, "testFile")));
request.execute(new ResponseHandler() {
public void handle(final Response response) throws ResponseException {
assertTrue(response.isSuccessful());
}
});
} finally {
server.stop();
}
}
代码示例来源:origin: com.atlassian.refapp/platform-ctk-plugin
@Test
public void testCanSendMultipartPostRequest() throws Exception {
Server server = new Server(0);
ServletHandler handler = new ServletHandler();
handler.addServletWithMapping(SetFilesServlet.class, "/*");
server.setHandler(handler);
try {
// start jetty.
server.start();
// now, make a request.
Request<?, ?> request = requestFactory.createRequest(Request.MethodType.POST, "http://localhost:" + getActivePort(server));
request.setFiles(Collections.singletonList(new RequestFilePart(testFile, "testFile")));
request.execute(new ResponseHandler() {
public void handle(final Response response) throws ResponseException {
assertTrue(response.isSuccessful());
}
});
} finally {
server.stop();
}
}
代码示例来源:origin: com.atlassian.studio/studio-theme-jira-plugin
@Override
protected String doExecute() throws Exception
{
if (!hasAdministratePermissionOnProject(key))
{
return SECURITY_BREACH;
}
ApplicationLink appLink = appLinksManager.getLinkedApplication(Application.CRUCIBLE.name(), key);
Request<?> request = requestFactory.createRequest(Request.MethodType.PUT, getRestResource(appLink));
request.addTrustedTokenAuthentication(themeProperties.getSystemAdministrator());
request.setRequestBody(XStreamUtils.toXML(projectConfig));
try
{
request.execute();
}
catch (ResponseException re)
{
addErrorMessage(re.getMessage());
log.error("Error putting crucible project config", re);
return INPUT;
}
return getRedirect("CrucibleProject!ListProjects.jspa?message=crucible.admin.info.updated");
}
代码示例来源:origin: com.atlassian.refapp/platform-ctk-plugin
@Test
public void testExecuteUnauthenticatedRequest() throws Exception {
Server server = new Server(0);
ServletHandler handler = new ServletHandler();
handler.addServletWithMapping(HelloServlet.class, "/*");
server.setHandler(handler);
try {
// start jetty.
server.start();
// now, make a request.
Request<?, ?> request = requestFactory.createRequest(Request.MethodType.GET, "http://localhost:" + getActivePort(server));
request.execute(new ResponseHandler() {
public void handle(final Response response) throws ResponseException {
passed = response.getResponseBodyAsString().contains(MESSAGE);
}
});
assertTrue("Should be able to get result from http", passed);
} finally {
server.stop();
}
}
代码示例来源:origin: com.atlassian.applinks/applinks-jira-plugin
public String doSynchronize()
{
final ApplicationLink localLink = appLinksManager.getLinkedApplication(app, getKey());
final String restUrl = localLink.getUrl() + "/plugins/servlet/applinks/projectlinks";
final Request<?> request = requestFactory.createRequest(Request.MethodType.POST,
restUrl + "?key=" + localLink.getRemoteKey() + "&application=JIRA");
final ApplicationLink remoteLink = new DefaultApplicationLink("jira", getKey(), null, null);
request.setRequestBody(XStreamUtils.toXML(remoteLink));
request.addTrustedTokenAuthentication();
try
{
request.execute();
}
catch (final ResponseException re)
{
return getRedirect("ViewProject.jspa?message=editprojectlinks.error.synchronize&pid=" + getPid());
}
return getRedirect("ViewProject.jspa?message=editprojectlinks.result.synchronized&pid=" + getPid());
}
内容来源于网络,如有侵权,请联系作者删除!