本文整理汇总了Java中com.google.api.server.spi.config.ApiMethod.HttpMethod.POST属性的典型用法代码示例。如果您正苦于以下问题:Java HttpMethod.POST属性的具体用法?Java HttpMethod.POST怎么用?Java HttpMethod.POST使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.api.server.spi.config.ApiMethod.HttpMethod
的用法示例。
在下文中一共展示了HttpMethod.POST属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSession
/**
* Creates a new session from {@link WaxNewSessionRequest}.
*
* @return {@link WaxNewSessionResponse} with the created session id
* @throws InternalServerErrorException if the session creation failed
* @throws BadRequestException if the requested session name is bad
*/
@ApiMethod(
name = "sessions.create",
path = "newsession",
httpMethod = HttpMethod.POST)
public WaxNewSessionResponse createSession(WaxNewSessionRequest request)
throws InternalServerErrorException, BadRequestException {
if (Strings.isNullOrEmpty(request.getSessionName())) {
throw new BadRequestException("Name must be non-empty");
}
String sessionId =
store.createSession(request.getSessionName(), request.getDurationInMillis());
if (sessionId != null) {
return new WaxNewSessionResponse(sessionId);
}
throw new InternalServerErrorException("Error while adding session");
}
示例2: registerGtfsTask
/**
* Register the gtfs creation task.
*
* @author Rodrigo Cabrera ([email protected])
* @param password a simple password to avoid excess of petitions
* @param trailIds the trail ids to be added to the GTFS
* @throws IOException
* @throws UnsupportedEncodingException
* @since 19 / feb / 2016
*/
@ApiMethod(name = "registerGtfsTask", path = "registerGtfsTask", httpMethod = HttpMethod.POST)
public void registerGtfsTask(@Named("password") String password, @Named("trailIds") String trailIds) throws TrailNotFoundException, UnsupportedEncodingException, IOException{
logger.debug("registering gtfs task");
FileInputStream inputStream = new FileInputStream(new File("WEB-INF/config.txt"));
String passConfig = CharStreams.toString(new InputStreamReader(inputStream, "UTF-8"));
if(password.equals(passConfig)){
HashMap<String, String> params = new HashMap<>();
params.put(GtfsGenerationTask.Params.trailIds.name(), trailIds);
new GtfsGenerationTask().enqueue(params);
}
logger.debug("registration finished");
}
示例3: registerGtfsFullTask
/**
* Register the gtfs creation task of all valid trails
*
* @author Rodrigo Cabrera ([email protected])
* @param password a simple password to avoid excess of petitions
* @throws IOException
* @throws UnsupportedEncodingException
* @since 26 / feb / 2016
*/
@ApiMethod(name = "registerGtfsFullTask", path = "registerGtfsFullTask", httpMethod = HttpMethod.POST)
public void registerGtfsFullTask(@Named("password") String password) throws TrailNotFoundException, UnsupportedEncodingException, IOException{
logger.debug("registering gtfs task");
FileInputStream inputStream = new FileInputStream(new File("WEB-INF/config.txt"));
String passConfig = CharStreams.toString(new InputStreamReader(inputStream, "UTF-8"));
if(password.equals(passConfig)){
ArrayList<Long> ids = new TrailsHandler().getAllValidGtfsTrailsIds();
HashMap<String, String> params = new HashMap<>();
String trailIds = Arrays.toString(ids.toArray()).replace("[", "").replace("]", "").replace(" ", "");
params.put(GtfsGenerationTask.Params.trailIds.name(), trailIds);
new GtfsGenerationTask().enqueue(params);
}
logger.debug("registration finished");
}
示例4: pollVote
@ApiMethod(
name = "meeting.pollVote",
path = "meeting/{id}/poll/vote",
httpMethod = HttpMethod.POST
)
public Meeting pollVote(@Named("id") String id, @Named("proposedStartDate") Long proposedStartDate, @Named("proposedEndDate") Long proposedEndDate, @Named("result") boolean result, com.google.appengine.api.users.User gUser) throws OAuthRequestException, MeetingPollPastException, EntityNotFoundException, UnauthorizedException {
userService.ensureEnabled(gUser);
Meeting meeting = meetingService.get(id);
if (meeting == null) throw new EntityNotFoundException(id);
if (meeting.isPast()) throw new MeetingPollPastException(id);
MeetingPollProposedDate proposedDate = new MeetingPollProposedDate();
proposedDate.setStartTimestamp(proposedStartDate);
proposedDate.setEndTimestamp(proposedEndDate);
MeetingPollVote vote = new MeetingPollVote();
vote.setUser(userService.getUser(gUser));
vote.setProposedDate(proposedDate);
vote.setResult(result);
meetingService.pollVote(meeting, vote);
return meeting;
}
示例5: removeMember
@ApiMethod(
name = "project.removeMember",
path = "project/{id}/removemember/{memberEmail}",
httpMethod = HttpMethod.POST
)
public User removeMember(@Named("id") String id, @Named("memberEmail") String memberEmail, com.google.appengine.api.users.User gUser) throws OAuthRequestException, UnauthorizedException {
userService.ensureEnabled(gUser);
User member = userService.getUser(memberEmail);
User user = userService.getUser(gUser);
Project entity = projectService.get(id);
projectService.removeMember(entity, member, user);
return member;
}
示例6: queryConferences
/**
* Queries against the datastore with the given filters and returns the result.
*
* Normally this kind of method is supposed to get invoked by a GET HTTP method,
* but we do it with POST, in order to receive conferenceQueryForm Object via the POST body.
*
* @param conferenceQueryForm A form object representing the query.
* @return A List of Conferences that match the query.
*/
@ApiMethod(
name = "queryConferences",
path = "queryConferences",
httpMethod = HttpMethod.POST
)
public List<Conference> queryConferences(ConferenceQueryForm conferenceQueryForm) {
Iterable<Conference> conferenceIterable = conferenceQueryForm.getQuery();
List<Conference> result = new ArrayList<>(0);
List<Key<Profile>> organizersKeyList = new ArrayList<>(0);
for (Conference conference : conferenceIterable) {
organizersKeyList.add(Key.create(Profile.class, conference.getOrganizerUserId()));
result.add(conference);
}
// To avoid separate datastore gets for each Conference, pre-fetch the Profiles.
ofy().load().keys(organizersKeyList);
return result;
}
示例7: getConferencesCreated
/**
* Returns a list of Conferences that the user created.
* In order to receive the websafeConferenceKey via the JSON params, uses a POST method.
*
* @param user An user who invokes this method, null when the user is not signed in.
* @return a list of Conferences that the user created.
* @throws UnauthorizedException when the user is not signed in.
*/
@ApiMethod(
name = "getConferencesCreated",
path = "getConferencesCreated",
httpMethod = HttpMethod.POST
)
public List<Conference> getConferencesCreated(final User user) throws UnauthorizedException {
// If not signed in, throw a 401 error.
if (user == null) {
throw new UnauthorizedException("Authorization required");
}
String userId = getUserId(user);
return ofy().load().type(Conference.class)
.ancestor(Key.create(Profile.class, userId))
.order("name").list();
}
示例8: createHIT
@ApiMethod(name = "createHIT", path = "createHIT/{surveyId}", httpMethod = HttpMethod.POST)
public StringResponse createHIT(@Named("surveyId") String surveyId,
@Nullable @Named("production") Boolean production, User user)
throws InternalServerErrorException, NotFoundException, UnauthorizedException {
Security.verifyAuthenticatedUser(user);
try {
Survey survey = surveyService.get(surveyId);
if(survey == null) {
throw new NotFoundException(String.format("Survey %s doesn't exist", surveyId));
}
HIT hit = createHITService.createHIT(production, survey);
return new StringResponse(String.format("created HIT with id: %s", hit.getHITId()));
} catch (MturkException e) {
logger.log(Level.SEVERE, "Error creating HIT", e);
throw new InternalServerErrorException(e.getMessage(), e);
}
}
示例9: auth
@ApiMethod(
name = "user.auth",
path = "user/auth",
httpMethod = HttpMethod.POST
)
public User auth(@Named("code") String code, com.google.appengine.api.users.User gUser) throws OAuthRequestException, IOException, UnauthorizedException {
if (gUser == null) throw new GUserNullUnauthorizedException("User not logged in");
GoogleCredential credential = GoogleServices.getCredentialFromOneTimeCode(gUser.getEmail(), code);
User user = UserService.getInstance().getUser(gUser.getEmail());
user.setCredential(credential);
UserService.getInstance().provisionProfile(user);
TaskService.getInstance().createCalendarEventsForUser(user);
userService.ensureEnabled(user);
return user;
}
示例10: getConferencesCreated
@ApiMethod(
name = "getConferencesCreated",
path = "getConferencesCreated",
httpMethod = HttpMethod.POST
)
public List<Conference> getConferencesCreated(final User user)
throws UnauthorizedException {
if (user == null) {
throw new UnauthorizedException("Authorization required");
}
Key<Profile> userKey = Key.create(Profile.class, user.getUserId());
Query<Conference> query = ofy().load().type(Conference.class).ancestor(userKey);
return query.list();
}
示例11: invisible0
@ApiMethod(
name = "api2.foos.invisible0",
path = "invisible0",
httpMethod = HttpMethod.POST
)
protected String invisible0() {
return null;
}
示例12: invisible1
@SuppressWarnings("unused")
@ApiMethod(
name = "api2.foos.invisible1",
path = "invisible1",
httpMethod = HttpMethod.POST
)
private String invisible1() {
return null;
}
示例13: insertFoo
@ApiMethod(
name = "foos.insert",
path = "foos",
httpMethod = HttpMethod.POST,
cacheControl = @ApiMethodCacheControl(
noCache = false,
maxAge = 3
)
)
public Foo insertFoo(Foo r) {
return null;
}
示例14: removeSession
/**
* Remove an existing session.
* <p>
* Clients that create sessions without a duration (will last forever) will need to call this
* method on their own to clean up the session.
*
* @return {@link WaxRemoveSessionResponse} with the deleted session id
* @throws InternalServerErrorException if the session deletion failed
*/
@ApiMethod(
name = "sessions.remove",
path = "removesession",
httpMethod = HttpMethod.POST)
public WaxRemoveSessionResponse removeSession(@Named("sessionId") String sessionId)
throws InternalServerErrorException {
try {
store.deleteSession(sessionId);
return new WaxRemoveSessionResponse(sessionId);
} catch (InvalidSessionException e) {
throw new InternalServerErrorException(e.getMessage());
}
}
示例15: getAllTrails
/**
* Gets a number of trails from the datastore, can be paginated using a cursor (send empty to start from the beginning)
*
* @author Rodrigo Cabrera ([email protected])
* @param parameter the cursor to know where to start from, and number of elements needed
* @return the number of trails from the cursor sent
* @since 16 / feb / 2016
*/
@ApiMethod(path = "getAllTrails", name = "getAllTrails", httpMethod = HttpMethod.POST)
public TrailListResponse getAllTrails(CursorParameter parameter){
logger.debug("Getting all trails for all user ");
TrailListResponse result = new TrailsHandler().getAllTrails(parameter);
logger.debug("All mapped trails ");
return result;
}