SUCCESSFUL源码实例Demo

javax.ws.rs.core.Response.Status.Family#SUCCESSFUL源码实例Demo

下面列出了javax.ws.rs.core.Response.Status.Family#SUCCESSFUL 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: raml-java-client-generator   文件: SendFormData.java
public TestsendformdataResponse<Void> post(SendFormDataPOSTBody body) {
    WebTarget target = this._client.target(getBaseUri());
    final javax.ws.rs.client.Invocation.Builder invocationBuilder = target.request(javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE);
    MultivaluedMap multiValuedMap = new MultivaluedHashMap();
    if (body.getParam1()!= null) {
        multiValuedMap.add("param1", body.getParam1().toString());
    }
    if (body.getParam2()!= null) {
        multiValuedMap.add("param2", body.getParam2().toString());
    }
    Response response = invocationBuilder.post(Entity.entity(multiValuedMap, javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED_TYPE));
    if (response.getStatusInfo().getFamily()!= Family.SUCCESSFUL) {
        Response.StatusType statusInfo = response.getStatusInfo();
        throw new TestsendformdataException(statusInfo.getStatusCode(), statusInfo.getReasonPhrase(), response.getStringHeaders(), response);
    }
    TestsendformdataResponse<Void> apiResponse = new TestsendformdataResponse<Void>(null, response.getStringHeaders(), response);
    return apiResponse;
}
 
private String createResourceToken(String refreshToken, String tenantId, String resource) throws InteractiveLoginException {
    Form resourceTokenForm = createResourceTokenForm(refreshToken, resource);
    WebTarget webTarget = ClientBuilder.newClient().target(LOGIN_MICROSOFTONLINE);
    Builder request = webTarget.path(tenantId + "/oauth2/token").queryParam("api-version", "1.0").request();
    request.accept(MediaType.APPLICATION_JSON);
    try (Response response = request.post(Entity.entity(resourceTokenForm, MediaType.APPLICATION_FORM_URLENCODED_TYPE))) {
        if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) {
            throw new InteractiveLoginException("Obtain access token for " + resource + " failed "
                    + "with tenant ID: " + tenantId + ", status code " + response.getStatus()
                    + ", error message: " + response.readEntity(String.class));
        }
        String responseString = response.readEntity(String.class);
        try {
            return new ObjectMapper().readTree(responseString).get("access_token").asText();
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }
}
 
源代码3 项目: raml-java-client-generator   文件: Exec.java
public DataWeaveAPIResponse<Void> post(ExecPOSTBody body) {
    WebTarget target = this._client.target(getBaseUri());
    final javax.ws.rs.client.Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON_TYPE);
    FormDataMultiPart multiPart = new FormDataMultiPart();
    if (body.getFile()!= null) {
        multiPart.bodyPart(new FileDataBodyPart("file", body.getFile()));
    }
    if (body.getFrom()!= null) {
        multiPart.field("From", body.getFrom().toString());
    }
    Response response = invocationBuilder.post(Entity.entity(multiPart, multiPart.getMediaType()));
    if (response.getStatusInfo().getFamily()!= Family.SUCCESSFUL) {
        Response.StatusType statusInfo = response.getStatusInfo();
        throw new DataWeaveAPIException(statusInfo.getStatusCode(), statusInfo.getReasonPhrase(), response.getStringHeaders(), response);
    }
    DataWeaveAPIResponse<Void> apiResponse = new DataWeaveAPIResponse<Void>(null, response.getStringHeaders(), response);
    return apiResponse;
}
 
源代码4 项目: raml-java-client-generator   文件: FileName.java
/**
 * Creates or updates the given file
 * 
 */
public SimpleApiResponse<Void> put(Object body, FileNamePUTHeader headers) {
    WebTarget target = this._client.target(getBaseUri());
    final javax.ws.rs.client.Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON_TYPE);
    if (headers.getXBaseCommitId()!= null) {
        invocationBuilder.header("x-base-commit-id", headers.getXBaseCommitId());
    }
    if (headers.getXCommitMessage()!= null) {
        invocationBuilder.header("x-commit-message", headers.getXCommitMessage());
    }
    Response response = invocationBuilder.put(Entity.entity(body, "*/*"));
    if (response.getStatusInfo().getFamily()!= Family.SUCCESSFUL) {
        Response.StatusType statusInfo = response.getStatusInfo();
        throw new SimpleApiException(statusInfo.getStatusCode(), statusInfo.getReasonPhrase(), response.getStringHeaders(), response);
    }
    SimpleApiResponse<Void> apiResponse = new SimpleApiResponse<Void>(null, response.getStringHeaders(), response);
    return apiResponse;
}
 
源代码5 项目: roboconf-platform   文件: ManagementWsDelegate.java
/**
 * Creates an application from a template.
 * @param applicationName the application name
 * @param templateName the template's name
 * @param templateQualifier the template's qualifier
 * @return the created application
 * @throws ManagementWsException if a problem occurred with the applications management
 */
public Application createApplication( String applicationName, String templateName, String templateQualifier )
throws ManagementWsException {

	this.logger.finer( "Creating application " + applicationName + " from " + templateName + " - " + templateQualifier + "..." );
	ApplicationTemplate tpl = new ApplicationTemplate( templateName ).version( templateQualifier );
	Application app = new Application( applicationName, tpl );

	WebResource path = this.resource.path( UrlConstants.APPLICATIONS );
	ClientResponse response = this.wsClient.createBuilder( path )
			.type( MediaType.APPLICATION_JSON )
			.post( ClientResponse.class, app );

	if( Family.SUCCESSFUL != response.getStatusInfo().getFamily())
		throw new ManagementWsException( response.getStatusInfo().getStatusCode(), "" );

	Application result = response.getEntity( Application.class );
	return result;
}
 
源代码6 项目: raml-java-client-generator   文件: Login.java
public FooResponse<String> post() {
    WebTarget target = this._client.target(getBaseUri());
    final javax.ws.rs.client.Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON_TYPE);
    Response response = invocationBuilder.post(null);
    if (response.getStatusInfo().getFamily()!= Family.SUCCESSFUL) {
        Response.StatusType statusInfo = response.getStatusInfo();
        throw new FooException(statusInfo.getStatusCode(), statusInfo.getReasonPhrase(), response.getStringHeaders(), response);
    }
    FooResponse<String> apiResponse = new FooResponse<String>(((String) response.readEntity(Object.class)), response.getStringHeaders(), response);
    return apiResponse;
}
 
/**
 * Logs in with a user name and a password.
 * @param username a user name
 * @param password a password
 * @return a session ID, or null if login failed
 * @throws DebugWsException
 */
public String login( String username, String password ) throws DebugWsException {

	this.logger.finer( "Logging in as " + username );
	WebResource path = this.resource.path( UrlConstants.AUTHENTICATION ).path( "e" );
	ClientResponse response = path
					.header( "u", username )
					.header( "p", password )
					.post( ClientResponse.class );

	if( Family.SUCCESSFUL != response.getStatusInfo().getFamily()) {
		String value = response.getEntity( String.class );
		this.logger.finer( response.getStatusInfo() + ": " + value );
		throw new DebugWsException( response.getStatusInfo().getStatusCode(), value );
	}

	// Get the session ID from the cookie that should have been returned
	String sessionId = null;
	List<NewCookie> cookies = response.getCookies();
	if( cookies != null ) {
		for( NewCookie cookie : cookies ) {
			if( UrlConstants.SESSION_ID.equals( cookie.getName())) {
				sessionId = cookie.getValue();
				break;
			}
		}
	}

	// Set the session ID
	this.wsClient.setSessionId( sessionId );
	this.logger.finer( "Session ID: " + sessionId );

	return sessionId;
}
 
源代码8 项目: roboconf-platform   文件: ApplicationWsDelegate.java
private void handleResponse( ClientResponse response ) throws ApplicationWsException {

		if( Family.SUCCESSFUL != response.getStatusInfo().getFamily()) {
			String value = response.getEntity( String.class );
			this.logger.finer( response.getStatusInfo() + ": " + value );
			throw new ApplicationWsException( response.getStatusInfo().getStatusCode(), value );
		}
	}
 
源代码9 项目: raml-java-client-generator   文件: Id.java
public FooResponse<Void> get() {
    WebTarget target = this._client.target(getBaseUri());
    final javax.ws.rs.client.Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON_TYPE);
    Response response = invocationBuilder.get();
    if (response.getStatusInfo().getFamily()!= Family.SUCCESSFUL) {
        Response.StatusType statusInfo = response.getStatusInfo();
        throw new FooException(statusInfo.getStatusCode(), statusInfo.getReasonPhrase(), response.getStringHeaders(), response);
    }
    FooResponse<Void> apiResponse = new FooResponse<Void>(null, response.getStringHeaders(), response);
    return apiResponse;
}
 
源代码10 项目: cloudbreak   文件: SubscriptionChecker.java
public void checkSubscription(String subscriptionId, String accessToken) throws InteractiveLoginException {
    if (subscriptionId == null) {
        throw new InteractiveLoginException("Parameter subscriptionId is required and cannot be null.");
    }
    Client client = ClientBuilder.newClient();
    WebTarget resource = client.target(AZURE_MANAGEMENT);
    Builder request = resource.path("/subscriptions/" + subscriptionId)
            .queryParam("api-version", "2016-06-01")
            .request();
    request.accept(MediaType.APPLICATION_JSON);

    request.header("Authorization", "Bearer " + accessToken);
    try (Response response = request.get()) {
        if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) {
            AzureSubscription subscription = response.readEntity(AzureSubscription.class);
            if (!subscription.getState().equals(SubscriptionState.ENABLED)) {
                throw new InteractiveLoginException("Subscription is in incorrect state:" + "" + subscription.getState());
            }
            LOGGER.debug("Subscription definitions successfully retrieved:" + subscription.getDisplayName());
        } else {
            String errorResponse = response.readEntity(String.class);
            try {
                String errorMessage = new ObjectMapper().readTree(errorResponse).get("error").get("message").asText();
                LOGGER.info("Subscription retrieve error:" + errorMessage);
                throw new InteractiveLoginException("Error with the subscription id: " + subscriptionId + " message: " + errorMessage);
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }
    }
}
 
源代码11 项目: raml-java-client-generator   文件: Bar.java
/**
 * SomeDescriptionValue
 * 
 */
public recursive_type.model.Foo get() {
    WebTarget target = this._client.target(getBaseUri());
    final javax.ws.rs.client.Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON_TYPE);
    Response response = invocationBuilder.get();
    if (response.getStatusInfo().getFamily()!= Family.SUCCESSFUL) {
        Response.StatusType statusInfo = response.getStatusInfo();
        throw new LocationsException(statusInfo.getStatusCode(), statusInfo.getReasonPhrase(), response.getStringHeaders(), response);
    }
    return response.readEntity(recursive_type.model.Foo.class);
}
 
源代码12 项目: raml-java-client-generator   文件: Bar.java
public void post() {
    WebTarget target = this._client.target(getBaseUri());
    final javax.ws.rs.client.Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON_TYPE);
    Response response = invocationBuilder.post(null);
    if (response.getStatusInfo().getFamily()!= Family.SUCCESSFUL) {
        Response.StatusType statusInfo = response.getStatusInfo();
        throw new FooException(statusInfo.getStatusCode(), statusInfo.getReasonPhrase(), response.getStringHeaders(), response);
    }
}
 
源代码13 项目: roboconf-platform   文件: ManagementWsDelegate.java
/**
 * Shutdowns an application.
 * @param applicationName the application name
 * @throws ManagementWsException if a problem occurred with the applications management
 */
public void shutdownApplication( String applicationName ) throws ManagementWsException {
	this.logger.finer( "Removing application " + applicationName + "..." );

	WebResource path = this.resource
				.path( UrlConstants.APPLICATIONS )
				.path( applicationName )
				.path( "shutdown" );

	ClientResponse response = this.wsClient.createBuilder( path ).post( ClientResponse.class );
	String text = response.getEntity( String.class );
	this.logger.finer( text );
	if( Family.SUCCESSFUL != response.getStatusInfo().getFamily())
		throw new ManagementWsException( response.getStatusInfo().getStatusCode(), text );
}
 
源代码14 项目: raml-java-client-generator   文件: Test.java
public MyapiResponse<type_decl.model.MyType> get() {
    WebTarget target = this._client.target(getBaseUri());
    final javax.ws.rs.client.Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON_TYPE);
    Response response = invocationBuilder.get();
    if (response.getStatusInfo().getFamily()!= Family.SUCCESSFUL) {
        Response.StatusType statusInfo = response.getStatusInfo();
        throw new MyapiException(statusInfo.getStatusCode(), statusInfo.getReasonPhrase(), response.getStringHeaders(), response);
    }
    MyapiResponse<type_decl.model.MyType> apiResponse = new MyapiResponse<type_decl.model.MyType>(response.readEntity(type_decl.model.MyType.class), response.getStringHeaders(), response);
    return apiResponse;
}
 
源代码15 项目: raml-java-client-generator   文件: Rename.java
/**
 * Rename a project
 * 
 */
public DesignCenterProjectsServicewithsubresourceonsamelineResponse<Void> put(Object body) {
    WebTarget target = this._client.target(getBaseUri());
    final javax.ws.rs.client.Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON_TYPE);
    Response response = invocationBuilder.put(Entity.json(body));
    if (response.getStatusInfo().getFamily()!= Family.SUCCESSFUL) {
        Response.StatusType statusInfo = response.getStatusInfo();
        throw new DesignCenterProjectsServicewithsubresourceonsamelineException(statusInfo.getStatusCode(), statusInfo.getReasonPhrase(), response.getStringHeaders(), response);
    }
    DesignCenterProjectsServicewithsubresourceonsamelineResponse<Void> apiResponse = new DesignCenterProjectsServicewithsubresourceonsamelineResponse<Void>(null, response.getStringHeaders(), response);
    return apiResponse;
}
 
源代码16 项目: raml-java-client-generator   文件: Login.java
public FooResponse<String> post() {
    WebTarget target = this._client.target(getBaseUri());
    final javax.ws.rs.client.Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON_TYPE);
    Response response = invocationBuilder.post(null);
    if (response.getStatusInfo().getFamily()!= Family.SUCCESSFUL) {
        Response.StatusType statusInfo = response.getStatusInfo();
        throw new FooException(statusInfo.getStatusCode(), statusInfo.getReasonPhrase(), response.getStringHeaders(), response);
    }
    FooResponse<String> apiResponse = new FooResponse<String>(((String) response.readEntity(Object.class)), response.getStringHeaders(), response);
    return apiResponse;
}
 
源代码17 项目: raml-java-client-generator   文件: Login.java
public CoreServicesAPIReferenceResponse<Void> get() {
    WebTarget target = this._client.target(getBaseUri());
    final javax.ws.rs.client.Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON_TYPE);
    Response response = invocationBuilder.get();
    if (response.getStatusInfo().getFamily()!= Family.SUCCESSFUL) {
        Response.StatusType statusInfo = response.getStatusInfo();
        throw new CoreServicesAPIReferenceException(statusInfo.getStatusCode(), statusInfo.getReasonPhrase(), response.getStringHeaders(), response);
    }
    CoreServicesAPIReferenceResponse<Void> apiResponse = new CoreServicesAPIReferenceResponse<Void>(null, response.getStringHeaders(), response);
    return apiResponse;
}
 
源代码18 项目: raml-java-client-generator   文件: Login.java
public List<AuthorizationJson> post() {
        WebTarget target = this._client.target(getBaseUri());
        final javax.ws.rs.client.Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON_TYPE);
        Response response = invocationBuilder.post(null);
        if (response.getStatusInfo().getFamily()!= Family.SUCCESSFUL) {
            Response.StatusType statusInfo = response.getStatusInfo();
            throw new FooException(statusInfo.getStatusCode(), statusInfo.getReasonPhrase(), response.getStringHeaders(), response);
        }
        return response.readEntity((
new javax.ws.rs.core.GenericType<java.util.List<include_schema.resource.cs.login.model.AuthorizationJson>>() {}));
    }
 
源代码19 项目: raml-java-client-generator   文件: B.java
public FooResponse<same_path_multiple_times.resource.foo.b.model.BGETResponseBody> get() {
    WebTarget target = this._client.target(getBaseUri());
    final javax.ws.rs.client.Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON_TYPE);
    Response response = invocationBuilder.get();
    if (response.getStatusInfo().getFamily()!= Family.SUCCESSFUL) {
        Response.StatusType statusInfo = response.getStatusInfo();
        throw new FooException(statusInfo.getStatusCode(), statusInfo.getReasonPhrase(), response.getStringHeaders(), response);
    }
    FooResponse<same_path_multiple_times.resource.foo.b.model.BGETResponseBody> apiResponse = new FooResponse<same_path_multiple_times.resource.foo.b.model.BGETResponseBody>(response.readEntity(same_path_multiple_times.resource.foo.b.model.BGETResponseBody.class), response.getStringHeaders(), response);
    return apiResponse;
}
 
源代码20 项目: SNOMED-in-5-minutes   文件: SnomedClientRest.java
/**
 * Returns description matches for the specified parameters.
 *
 * @param query the query
 * @param limit the limit
 * @param searchMode the search mode
 * @param lang the lang
 * @param statusFilter the status filter
 * @param skipTo the skip to
 * @param returnLimit the return limit
 * @param normalize the normalize
 * @param semanticFilter the semantic filter
 * @return the matches for query
 * @throws Exception the exception
 */
public MatchResults findByQuery(String query, Long limit, String searchMode,
  String lang, String statusFilter, Long skipTo, Long returnLimit,
  Boolean normalize, String semanticFilter) throws Exception {
  Logger.getLogger(getClass()).debug(
      "Snomed Client - get description matches by query " + query);

  validateNotEmpty(query, "query");

  // Use defaults if null is passed
  final long localLimit = limit == null ? 50L : limit;
  final String localSearchMode =
      searchMode == null ? "partialMatching" : searchMode;
  final String localLang = lang == null ? "english" : lang;
  final String localStatusFilter =
      statusFilter == null ? "activeOnly" : statusFilter;
  final long localSkipTo = skipTo == null ? 0L : skipTo;
  final long localReturnLimit = returnLimit == null ? 100L : returnLimit;
  final boolean localNormalize = normalize == null ? true : normalize;
  final String localSemanticFilter =
      semanticFilter == null ? "" : "&semanticFilter=" + semanticFilter;

  final Client client = ClientBuilder.newClient();
  final WebTarget target =
      client.target(getUrl()
          + "/descriptions?query="
          + URLEncoder.encode(query == null ? "" : query, "UTF-8")
              .replaceAll("\\+", "%20") + "&limit=" + localLimit
          + "&searchMode=" + localSearchMode + "&lang=" + localLang
          + "&statusFilter=" + localStatusFilter + "&skipTo=" + localSkipTo
          + "&returnLimit=" + localReturnLimit + "&normalize="
          + localNormalize + localSemanticFilter);

  final Response response = target.request(MediaType.APPLICATION_JSON).get();
  final String resultString = response.readEntity(String.class);
  if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) {
    // n/a
  } else {
    throw new Exception(response.toString());
  }

  // converting to object
  return Utility.getGraphForJson(resultString, MatchResults.class);
}
 
源代码评论
动弹
沙发等你来抢
 同类方法