本文整理汇总了Java中org.apache.http.client.methods.HttpRequestBase.setURI方法的典型用法代码示例。如果您正苦于以下问题:Java HttpRequestBase.setURI方法的具体用法?Java HttpRequestBase.setURI怎么用?Java HttpRequestBase.setURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.client.methods.HttpRequestBase
的用法示例。
在下文中一共展示了HttpRequestBase.setURI方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMemberInGroup
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
/**
* Gets a user's {@link Subscription} for the specified group and member IDs
*
* @return the user's {@link Subscription} for the specified group ID
* @throws URISyntaxException
* @throws IOException
* @throws GroupsIOApiException
*/
public Subscription getMemberInGroup(final Integer groupId, final Integer memberId)
throws URISyntaxException, IOException, GroupsIOApiException
{
if (apiClient.group().getPermissions(groupId).getViewMembers())
{
final URIBuilder uri = new URIBuilder().setPath(baseUrl + "getmember");
uri.setParameter("group_id", groupId.toString());
uri.setParameter("sub_id", memberId.toString());
final HttpRequestBase request = new HttpGet();
request.setURI(uri.build());
return callApi(request, Subscription.class);
}
else
{
final Error error = new Error();
error.setType(GroupsIOApiExceptionType.INADEQUATE_PERMISSIONS);
throw new GroupsIOApiException(error);
}
}
示例2: banMember
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
/**
* Ban a member if they aren't already banned
*
* @param groupId
* of the group they belong to
* @param subscriptionId
* of the subscription they have
* @return the user's {@link Subscription}
* @throws URISyntaxException
* @throws IOException
* @throws GroupsIOApiException
*/
public Subscription banMember(final Integer groupId, final Integer subscriptionId)
throws URISyntaxException, IOException, GroupsIOApiException
{
if (apiClient.group().getPermissions(groupId).getBanMembers()
&& getMemberInGroup(groupId, subscriptionId).getStatus().canBan())
{
final URIBuilder uri = new URIBuilder().setPath(baseUrl + "banmember");
uri.setParameter("group_id", groupId.toString());
uri.setParameter("sub_id", subscriptionId.toString());
final HttpRequestBase request = new HttpGet();
request.setURI(uri.build());
return callApi(request, Subscription.class);
}
else
{
final Error error = new Error();
error.setType(GroupsIOApiExceptionType.INADEQUATE_PERMISSIONS);
throw new GroupsIOApiException(error);
}
}
示例3: approveMember
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
/**
* Approve a member to a group
*
* @param groupId
* of the group they should belong to
* @param subscriptionId
* of the subscription they have
* @return the user's {@link Subscription}
* @throws URISyntaxException
* @throws IOException
* @throws GroupsIOApiException
*/
public Subscription approveMember(final Integer groupId, final Integer subscriptionId)
throws URISyntaxException, IOException, GroupsIOApiException
{
if (apiClient.group().getPermissions(groupId).getManagePendingMembers())
{
final URIBuilder uri = new URIBuilder().setPath(baseUrl + "approvemember");
uri.setParameter("group_id", groupId.toString());
uri.setParameter("sub_id", subscriptionId.toString());
final HttpRequestBase request = new HttpGet();
request.setURI(uri.build());
return callApi(request, Subscription.class);
}
else
{
final Error error = new Error();
error.setType(GroupsIOApiExceptionType.INADEQUATE_PERMISSIONS);
throw new GroupsIOApiException(error);
}
}
示例4: directAddMember
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
/**
* Add members directly to a group
*
* @param groupId
* of the group they should be added to
* @param emails
* a list of email address to add.
* @throws URISyntaxException
* @throws IOException
* @throws GroupsIOApiException
*/
public void directAddMember(final Integer groupId, List<String> emails)
throws URISyntaxException, IOException, GroupsIOApiException
{
if (apiClient.group().getPermissions(groupId).getInviteMembers())
{
final URIBuilder uri = new URIBuilder().setPath(baseUrl + "directadd");
uri.setParameter("group_id", groupId.toString());
uri.setParameter("emails", String.join("\n", emails));
final HttpRequestBase request = new HttpGet();
request.setURI(uri.build());
callApi(request, DirectAdd.class);
}
else
{
final Error error = new Error();
error.setType(GroupsIOApiExceptionType.INADEQUATE_PERMISSIONS);
throw new GroupsIOApiException(error);
}
}
示例5: removeMember
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
/**
* Remove a member from a group
*
* @param groupId
* of the group they belong to
* @param subscriptionId
* of the subscription they have
* @return the user's {@link Subscription}
* @throws URISyntaxException
* @throws IOException
* @throws GroupsIOApiException
*/
public Subscription removeMember(final Integer groupId, final Integer subscriptionId)
throws URISyntaxException, IOException, GroupsIOApiException
{
if (apiClient.group().getPermissions(groupId).getRemoveMembers())
{
final URIBuilder uri = new URIBuilder().setPath(baseUrl + "removemember");
uri.setParameter("group_id", groupId.toString());
uri.setParameter("sub_id", subscriptionId.toString());
final HttpRequestBase request = new HttpGet();
request.setURI(uri.build());
return callApi(request, Subscription.class);
}
else
{
final Error error = new Error();
error.setType(GroupsIOApiExceptionType.INADEQUATE_PERMISSIONS);
throw new GroupsIOApiException(error);
}
}
示例6: sendBounceProbe
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
/**
* Send a bounce probe to a user if they are bouncing
*
* @param groupId
* of the group they belong to
* @param subscriptionId
* of the subscription they have
* @return the user's {@link Subscription}
* @throws URISyntaxException
* @throws IOException
* @throws GroupsIOApiException
*/
public Subscription sendBounceProbe(final Integer groupId, final Integer subscriptionId)
throws URISyntaxException, IOException, GroupsIOApiException
{
if (apiClient.group().getPermissions(groupId).getManageMemberSubscriptionOptions()
&& getMemberInGroup(groupId, subscriptionId).getUserStatus().canSendBounceProbe())
{
final URIBuilder uri = new URIBuilder().setPath(baseUrl + "sendbounceprobe");
uri.setParameter("group_id", groupId.toString());
uri.setParameter("sub_id", subscriptionId.toString());
final HttpRequestBase request = new HttpGet();
request.setURI(uri.build());
return callApi(request, Subscription.class);
}
else
{
final Error error = new Error();
error.setType(GroupsIOApiExceptionType.INADEQUATE_PERMISSIONS);
throw new GroupsIOApiException(error);
}
}
示例7: sendConfirmationEmail
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
/**
* Send a confirmation email to a user if they are not yet confirmed
*
* @param groupId
* of the group they belong to
* @param subscriptionId
* of the subscription they have
* @return the user's {@link Subscription}
* @throws URISyntaxException
* @throws IOException
* @throws GroupsIOApiException
*/
public Subscription sendConfirmationEmail(final Integer groupId, final Integer subscriptionId)
throws URISyntaxException, IOException, GroupsIOApiException
{
if (apiClient.group().getPermissions(groupId).getManageMemberSubscriptionOptions()
&& getMemberInGroup(groupId, subscriptionId).getUserStatus().canSendConfirmationEmail())
{
final URIBuilder uri = new URIBuilder().setPath(baseUrl + "sendconfirmation");
uri.setParameter("group_id", groupId.toString());
uri.setParameter("sub_id", subscriptionId.toString());
final HttpRequestBase request = new HttpGet();
request.setURI(uri.build());
return callApi(request, Subscription.class);
}
else
{
final Error error = new Error();
error.setType(GroupsIOApiExceptionType.INADEQUATE_PERMISSIONS);
throw new GroupsIOApiException(error);
}
}
示例8: getGroup
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
/**
* Gets a {@link Group} for the specified group ID
*
* @return the {@link Group} for the specified group ID
* @throws URISyntaxException
* @throws IOException
* @throws GroupsIOApiException
*/
public Group getGroup(final Integer groupId) throws URISyntaxException, IOException, GroupsIOApiException
{
if (apiClient.group().getPermissions(groupId).getManageGroupSettings())
{
final URIBuilder uri = new URIBuilder().setPath(baseUrl + "getgroup");
uri.setParameter("group_id", groupId.toString());
final HttpRequestBase request = new HttpGet();
request.setURI(uri.build());
return callApi(request, Group.class);
}
else
{
final Error error = new Error();
error.setType(GroupsIOApiExceptionType.INADEQUATE_PERMISSIONS);
throw new GroupsIOApiException(error);
}
}
示例9: getSubgroups
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
/**
* Gets a list of groups for a given group ID
*
* @param groupId
* to fetch subgroups for
* @return {@link List}<{@link Group}> belonging to a parent group.
* @throws URISyntaxException
* @throws IOException
* @throws GroupsIOApiException
*/
public List<Group> getSubgroups(final Integer groupId) throws URISyntaxException, IOException, GroupsIOApiException
{
final URIBuilder uri = new URIBuilder().setPath(baseUrl + "getsubgroups");
uri.setParameter("group_id", groupId.toString());
uri.setParameter("limit", MAX_RESULTS);
final HttpRequestBase request = new HttpGet();
request.setURI(uri.build());
Page page = callApi(request, Page.class);
final List<Group> subgroups = Arrays.asList(OM.convertValue(page.getData(), Group[].class));
while (page.getHasMore())
{
uri.setParameter("page_token", page.getNextPageToken().toString());
request.setURI(uri.build());
page = callApi(request, Page.class);
subgroups.addAll(Arrays.asList(OM.convertValue(page.getData(), Group[].class)));
}
return subgroups;
}
示例10: getNewRequest
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
private HttpRequestBase getNewRequest(String reqMethod, String reqPayload)
throws URISyntaxException, UnsupportedEncodingException {
HttpRequestBase request;
if(reqMethod.equals(HttpConstants.REQ_METHOD_POST)) {
HttpPost postRequest = new HttpPost();
postRequest.setEntity(new StringEntity(reqPayload, ContentType.create(DataFormats.JSON.getMediaType(), Constants.UTF_8)));
request = postRequest;
} else {
throw new IllegalArgumentException(Errors.ARGS_HTTP_METHOD_UNSUPPORTED.getDescription());
}
request.setURI(new URI(String.format("%s://%s:%s/",
nodeConfig.getProperty(NodeProps.RPC_PROTOCOL.getKey()),
nodeConfig.getProperty(NodeProps.RPC_HOST.getKey()),
nodeConfig.getProperty(NodeProps.RPC_PORT.getKey()))));
String authScheme = nodeConfig.getProperty(NodeProps.HTTP_AUTH_SCHEME.getKey());
request.addHeader(resolveAuthHeader(authScheme));
LOG.debug("<< getNewRequest(..): returning a new HTTP '{}' request with target endpoint "
+ "'{}' and headers '{}'", reqMethod, request.getURI(), request.getAllHeaders());
return request;
}
示例11: getMembersInGroup
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
/**
* Gets a list of members (represented by {@link Subscription}) subscribed
* to a particular group.
*
* @param groupId
* - which group to get members from
* @return {@link List}<{@link Subscription}> representing the subscribed
* members
* @throws URISyntaxException
* @throws IOException
* @throws GroupsIOApiException
*/
public List<Subscription> getMembersInGroup(final Integer groupId) throws URISyntaxException, IOException, GroupsIOApiException
{
if (apiClient.group().getPermissions(groupId).getViewMembers())
{
final URIBuilder uri = new URIBuilder().setPath(baseUrl + "getmembers");
uri.setParameter("group_id", groupId.toString());
uri.setParameter("limit", MAX_RESULTS);
final HttpRequestBase request = new HttpGet();
request.setURI(uri.build());
Page page = callApi(request, Page.class);
final List<Subscription> subscriptions = Arrays.asList(OM.convertValue(page.getData(), Subscription[].class));
while (page.getHasMore())
{
uri.setParameter("page_token", page.getNextPageToken().toString());
request.setURI(uri.build());
page = callApi(request, Page.class);
subscriptions.addAll(Arrays.asList(OM.convertValue(page.getData(), Subscription[].class)));
}
return subscriptions;
}
else
{
final Error error = new Error();
error.setType(GroupsIOApiExceptionType.INADEQUATE_PERMISSIONS);
throw new GroupsIOApiException(error);
}
}
示例12: searchMembers
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
/**
* Gets a list of members (represented by {@link Subscription}) subscribed
* to a particular group.
*
* @param groupId
* - which group to get members from
* @param query
* - what to search for (will search over email or name)
* @return {@link List}<{@link Subscription}> representing the subscribed
* members
* @throws URISyntaxException
* @throws IOException
* @throws GroupsIOApiException
*/
public List<Subscription> searchMembers(final Integer groupId, final String query)
throws URISyntaxException, IOException, GroupsIOApiException
{
if (apiClient.group().getPermissions(groupId).getViewMembers())
{
final URIBuilder uri = new URIBuilder().setPath(baseUrl + "searchmembers");
uri.setParameter("group_id", groupId.toString());
uri.setParameter("q", query);
uri.setParameter("limit", MAX_RESULTS);
final HttpRequestBase request = new HttpGet();
request.setURI(uri.build());
Page page = callApi(request, Page.class);
final List<Subscription> subscriptions = Arrays.asList(OM.convertValue(page.getData(), Subscription[].class));
while (page.getHasMore())
{
uri.setParameter("page_token", page.getNextPageToken().toString());
request.setURI(uri.build());
page = callApi(request, Page.class);
subscriptions.addAll(Arrays.asList(OM.convertValue(page.getData(), Subscription[].class)));
}
return subscriptions;
}
else
{
final Error error = new Error();
error.setType(GroupsIOApiExceptionType.INADEQUATE_PERMISSIONS);
throw new GroupsIOApiException(error);
}
}
示例13: getPermissions
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
/**
* Gets a user's {@link Permissions} for the specified group ID
*
* @return the user's {@link Permissions} for the specified group ID
* @throws URISyntaxException
* @throws IOException
* @throws GroupsIOApiException
*/
public Permissions getPermissions(final Integer groupId) throws URISyntaxException, IOException, GroupsIOApiException
{
final URIBuilder uri = new URIBuilder().setPath(baseUrl + "getperms");
uri.setParameter("group_id", groupId.toString());
final HttpRequestBase request = new HttpGet();
request.setURI(uri.build());
return callApi(request, Permissions.class);
}
示例14: getUser
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
/**
* Get the user information associated with the currently-logged in user.
*
* @return {@link User} representing the current user
* @throws URISyntaxException
* @throws IOException
* @throws GroupsIOApiException
*/
public User getUser() throws URISyntaxException, IOException, GroupsIOApiException
{
final URIBuilder uri = new URIBuilder().setPath(baseUrl + "getuser");
final HttpRequestBase request = new HttpGet();
request.setURI(uri.build());
return callApi(request, User.class);
}
示例15: execute
import org.apache.http.client.methods.HttpRequestBase; //导入方法依赖的package包/类
@Override
public <T> T execute(final HttpRequestBase request, final ResponseHandler<T> responseHandler) throws IOException {
if(StringUtils.isNotBlank(request.getURI().getRawQuery())) {
request.setURI(URI.create(String.format("%s%s?%s", uri, request.getURI().getRawPath(), request.getURI().getRawQuery())));
}
else {
request.setURI(URI.create(String.format("%s%s", uri, request.getURI().getRawPath())));
}
return super.execute(request, responseHandler);
}