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


Java Response类代码示例

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


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

示例1: shouldFireOnLoad_afterLastScriptLoaded

import com.google.gwt.http.client.Response; //导入依赖的package包/类
@Test
public void shouldFireOnLoad_afterLastScriptLoaded() {
    // given
    ScriptUrl[] scripts = new ScriptUrl[]{firstScript, secondScript};
    Request request = mock(Request.class);
    Response response = mock(Response.class);
    when(response.getText()).thenReturn(RESPONSE_TEXT);

    // when
    testObj.injectScripts(scripts, synchronousScriptsCallback);
    verify(requestWrapper).get(eq(FIRST_SCRIPT_URL), requestCallbackCaptor.capture());
    RequestCallback requestCallback = requestCallbackCaptor.getValue();
    requestCallback.onResponseReceived(request, response);

    // then
    verify(scriptInjectorWrapper).fromString(RESPONSE_TEXT);

    verify(requestWrapper).get(SECOND_SCRIPT_URL, requestCallback);
    requestCallback.onResponseReceived(request, response);
    verify(synchronousScriptsCallback).onLoad();
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:22,代码来源:SynchronousScriptsLoaderTest.java

示例2: getErrorCallback

import com.google.gwt.http.client.Response; //导入依赖的package包/类
protected RestErrorCallback getErrorCallback() {
	return new RestErrorCallback() {

		@Override
		public boolean error(Request request, Throwable throwable) {
			autoMessageBox.hide();
			String message = "";
			int defaultCodeError = Response.SC_NOT_MODIFIED;
			try {
				throw throwable;
			} catch (ResponseException e) {
				Response response = e.getResponse();					
				message = response.getStatusText(); 
				defaultCodeError = response.getStatusCode();
				
			} catch (Throwable t) {
				message = t.getMessage();
			}
			
			messageDialogBuilder.createError(UIMessages.INSTANCE.warning() + " " + defaultCodeError, message).show();
			
			return false;
		}
	};
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:26,代码来源:AbstractGitHubGetListRequest.java

示例3: getErrorCallback

import com.google.gwt.http.client.Response; //导入依赖的package包/类
private RestErrorCallback getErrorCallback() {
	return new RestErrorCallback() {

		@Override
		public boolean error(Request request, Throwable throwable) {
			autoMessageBox.hide();
			String message = "";
			int defaultCodeError = Response.SC_NOT_MODIFIED;
			try {
				throw throwable;
			} catch (ResponseException e) {
				Response response = e.getResponse();					
				message = response.getStatusText(); 
				defaultCodeError = response.getStatusCode();
				
			} catch (Throwable t) {
				message = t.getMessage();
			}
			
			messageDialogBuilder.createError(UIMessages.INSTANCE.warning() + " " + defaultCodeError, message).show();
			
			return false;
		}
	};
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:26,代码来源:GitHubGetRepositoryListRequest.java

示例4: export

import com.google.gwt.http.client.Response; //导入依赖的package包/类
@Override
public void export(FileParameter fileParameter) {
	autoMessageBox = new ProgressBarDialog(false,
			UIMessages.INSTANCE.processing());
	autoMessageBox.show();

	final String fileName = fileParameter.getFileName() + "."
			+ fileParameter.getExtension();
	gitHubParameter = (GitHubParameter) fileParameter;
	final String userName = gitHubParameter.getUserName();
	final String password = gitHubParameter.getPassword();
	final String repository = gitHubParameter.getRepository();
	final String path = gitHubParameter.getPath();
	final String message = gitHubParameter.getMessageCommit();
	final String authorizationHeaderValue = BasicAuthenticationProvider
			.getAuthorizationHeaderValue(userName, password);
	final GitHubCreateFileRequest content = new GitHubCreateFileRequest();
	content.setContent(Base64.encode(fileParameter.getContent()));
	content.setMessage(message);
	RestClient.setJacksonMarshallingActive(true);
	RestClient.create(GitHubFileService.class, URL_BASE,
			getRemoteCallback(), getErrorCallback(), Response.SC_CREATED)
			.createFile(userName, repository, path, fileName,
					authorizationHeaderValue, content);
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:26,代码来源:GitHubCreateFileExporter.java

示例5: onResponseReceived

import com.google.gwt.http.client.Response; //导入依赖的package包/类
@Override
public void onResponseReceived(Request request, Response response) {
    String text = response.getText();
    PopupPanel popup = new PopupPanel(true);
    popup.add(new HTML("<strong>Saved edits for:<p></p></strong>"+text+"<p></p>Click outside box to dismiss."));
    popup.setPopupPosition(200, Window.getClientHeight()/3);
    popup.show();
    CellFormatter formatter = datatable.getCellFormatter();
    for (Iterator dirtyIt = dirtyrows.keySet().iterator(); dirtyIt.hasNext();) {
        Integer widgetrow = (Integer) dirtyIt.next();
        for (int i = 0; i < headers.length; i++) {
            formatter.removeStyleName(widgetrow, i, "dirty");
        }
        
        CheckBox box = (CheckBox) datatable.getWidget(widgetrow, 0);
        box.setValue(false);
    }
    dirtyrows.clear();
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:20,代码来源:ColumnEditorWidget.java

示例6: onResponseReceived

import com.google.gwt.http.client.Response; //导入依赖的package包/类
@Override
public void onResponseReceived(Request request, Response response) {
    if (isSuccessStatusCode(response)) {
        if (null != callback) {
            R result;
            if (null != responseConverter && null != response.getText() && !response.getText().isEmpty()) {
                try {
                    result = responseConverter.read(response.getText());
                } catch (Exception e) {
                    onError(request, e);
                    return;
                }
            } else {
                result = null;
            }
            callback.onSuccess(response, result);
        }
    } else {
        if (null != callback) {
            callback.onError(response);
        } else {
            throw new RestException("An error occured. Status : " + response.getStatusCode());
        }
    }
}
 
开发者ID:nmorel,项目名称:gwt-jackson-rest,代码行数:26,代码来源:RestRequestCallback.java

示例7: jobsStateRevision

import com.google.gwt.http.client.Response; //导入依赖的package包/类
/**
 * Fetch jobs state revision. If revision is more recent, fetch jobs.
 */
public void jobsStateRevision() {
    SchedulerServiceAsync scheduler = Scheduler.getSchedulerService();
    scheduler.schedulerStateRevision(LoginModel.getInstance().getSessionId(), new AsyncCallback<Long>() {

        public void onFailure(Throwable caught) {
            if (!LoginModel.getInstance().isLoggedIn()) {
                // might have been disconnected in between
                return;
            }
            if (JSONUtils.getJsonErrorCode(caught) == Response.SC_UNAUTHORIZED) {
                parentController.getParentController().teardown("You have been disconnected from the server.");
            }
            LogModel.getInstance().logCriticalMessage("Failed to get Scheduler Revision: " +
                                                      JSONUtils.getJsonErrorMessage(caught));
        }

        public void onSuccess(Long result) {
            fetchJobs(false);
        }
    });
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:25,代码来源:JobsController.java

示例8: requestCsrfToken

import com.google.gwt.http.client.Response; //导入依赖的package包/类
private Promise<String> requestCsrfToken() {
  if (csrfToken != null) {
    return Promises.resolve(csrfToken);
  }
  return createGetRequest(appContext.getMasterApiEndpoint() + "/profile")
      .header(CSRF_TOKEN_HEADER_NAME, "Fetch")
      .send(
          new Unmarshallable<String>() {
            @Override
            public void unmarshal(Response response) throws UnmarshallerException {
              csrfToken = response.getHeader(CSRF_TOKEN_HEADER_NAME);
              if (csrfToken != null) {
                appContext.getProperties().put(CSRF_TOKEN_HEADER_NAME, csrfToken);
              }
            }

            @Override
            public String getPayload() {
              return csrfToken;
            }
          });
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:MachineAsyncRequestFactory.java

示例9: onResponseReceived

import com.google.gwt.http.client.Response; //导入依赖的package包/类
/**
 * @see
 *     com.google.gwt.http.client.RequestCallback#onResponseReceived(com.google.gwt.http.client.Request,
 *     com.google.gwt.http.client.Response)
 */
@Override
public final void onResponseReceived(Request request, Response response) {
  if (loader != null) {
    loader.hide();
  }

  // If there is no connection to the server then status equals 0 ( In Internet Explorer status is
  // 12029 )
  if (response.getStatusCode() == 0 || response.getStatusCode() == 12029) {
    onServerDisconnected();
    return;
  }

  if (response.getStatusCode() == HTTPStatus.UNAUTHORIZED) {
    onUnauthorized(response);
    return;
  }

  if (isSuccessful(response)) {
    handleSuccess(response);
  } else {
    handleFailure(response);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:AsyncRequestCallback.java

示例10: generateErrorMessage

import com.google.gwt.http.client.Response; //导入依赖的package包/类
private String generateErrorMessage(Response response) {
  StringBuilder message = new StringBuilder();
  String protocol = Window.Location.getProtocol();
  String host = Window.Location.getHost();
  String url = this.request.getRequestBuilder().getUrl();

  // deletes query params
  url = url.substring(0, url.indexOf('?'));

  message
      .append(response.getStatusCode())
      .append(" ")
      .append(response.getStatusText())
      .append(" ")
      .append(protocol)
      .append("//")
      .append(host)
      .append(url);

  return message.toString();
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:AsyncRequestCallback.java

示例11: isSuccessful

import com.google.gwt.http.client.Response; //导入依赖的package包/类
protected final boolean isSuccessful(Response response) {
  if (successCodes == null) {
    successCodes = DEFAULT_SUCCESS_CODES;
  }

  if ("Authentication-required".equals(response.getHeader(HTTPHeader.JAXRS_BODY_PROVIDED))) {
    return false;
  }

  for (int code : successCodes) {
    if (response.getStatusCode() == code) {
      return true;
    }
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:AsyncRequestCallback.java

示例12: doStop

import com.google.gwt.http.client.Response; //导入依赖的package包/类
public void doStop() {
 for (TabItem item : advanced.getItems()) {
	 final CIModel model = (CIModel)item.getData("model");

	 // Do a HTTP request..
	 RequestBuilder req = new RequestBuilder(RequestBuilder.GET, getStopURL(model));

	 try {
		 Info.display("Stop", "Send stop to " + model.getDisplayName());
		 req.sendRequest(null, new RequestCallback() {

			 public void onResponseReceived(Request request, Response response) {
				 Info.display("Stop", "COMPLETED. Stop sent to " + model.getDisplayName());
			 }

			 public void onError(Request arg0, Throwable arg1) {
				 Info.display("Stop", "FAILED. to stop " + model.getDisplayName());
			 }
		 });

	 } catch (RequestException e) {
		 Info.display("Stop", "ERROR. to stop " + model.getDisplayName());
	 } 
 }
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:26,代码来源:MDRStartWidget.java

示例13: load

import com.google.gwt.http.client.Response; //导入依赖的package包/类
public void load(String url, final String regionName) {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
    try {
        builder.sendRequest(null, new RequestCallback(){
            public void onResponseReceived(com.google.gwt.http.client.Request req, Response res) {
                updateHtml(res.getText(), regionName);
            }

            public void onError(com.google.gwt.http.client.Request request, Throwable exception) {
            }
        });
    } catch (RequestException e) {
        e.printStackTrace();
    }

}
 
开发者ID:lsst,项目名称:firefly,代码行数:17,代码来源:HtmlRegionLoader.java

示例14: isExpected

import com.google.gwt.http.client.Response; //导入依赖的package包/类
/** Is the Gerrit Code Review server likely to return this status? */
public static boolean isExpected(int statusCode) {
  switch (statusCode) {
    case SC_UNAVAILABLE:
    case Response.SC_BAD_REQUEST:
    case Response.SC_UNAUTHORIZED:
    case Response.SC_FORBIDDEN:
    case Response.SC_NOT_FOUND:
    case Response.SC_METHOD_NOT_ALLOWED:
    case Response.SC_CONFLICT:
    case Response.SC_PRECONDITION_FAILED:
    case 422: // Unprocessable Entity
    case 429: // Too Many Requests (RFC 6585)
      return true;

    default:
      // Assume any other code is not expected. These may be
      // local proxy server errors outside of our control.
      return false;
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:22,代码来源:RestApi.java

示例15: syncRequest

import com.google.gwt.http.client.Response; //导入依赖的package包/类
public XMLHttpRequest2 syncRequest(String aUrl, ResponseType aResponseType) throws Exception {
	final XMLHttpRequest2 req = syncRequest(aUrl, aResponseType, null, RequestBuilder.GET);
	if (req.getStatus() == Response.SC_OK)
		return req;
	else
		throw new Exception(req.getStatus() + " " + req.getStatusText());
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:8,代码来源:AppClient.java


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