本文整理汇总了Java中com.google.api.server.spi.config.ApiMethod.HttpMethod.DELETE属性的典型用法代码示例。如果您正苦于以下问题:Java HttpMethod.DELETE属性的具体用法?Java HttpMethod.DELETE怎么用?Java HttpMethod.DELETE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.api.server.spi.config.ApiMethod.HttpMethod
的用法示例。
在下文中一共展示了HttpMethod.DELETE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteBlob
/**
* Deletes a blob.
*
* @param bucketName Google Cloud Storage bucket where the object was uploaded.
* @param objectPath path to the object in the bucket.
* @param user the user making the request.
* @throws com.google.api.server.spi.response.UnauthorizedException if the user is not authorized.
* @throws com.google.api.server.spi.response.BadRequestException if the bucketName or objectPath are not valid.
* @throws com.google.api.server.spi.response.InternalServerErrorException when the operation failed.
*/
@ApiMethod(httpMethod = HttpMethod.DELETE, path = "blobs/{bucketName}/{objectPath}")
public void deleteBlob(
@Named("bucketName") String bucketName, @Named("objectPath") String objectPath, User user)
throws UnauthorizedException, BadRequestException, InternalServerErrorException {
validateUser(user);
validateBucketAndObjectPath(bucketName, objectPath);
boolean blobExists = checkDeletePermissions(bucketName, objectPath, user);
if (!blobExists) {
// DELETE operation is idempotent. The object doesn't exist, so there is no more work to do.
return;
}
if (!deleteAllBlobInformation(bucketName, objectPath)) {
throw new InternalServerErrorException("Deleting blob failed. You can retry.");
}
}
示例2: removeFoo
@ApiMethod(
name = "foos.remove",
path = "foos/{id}",
httpMethod = HttpMethod.DELETE,
cacheControl = @ApiMethodCacheControl(
noCache = false,
maxAge = 5
)
)
public void removeFoo(@Named("id") String id) {
}
示例3: unregisterFromConference
/**
* Unregister from the specified Conference.
*
* @param user An user who invokes this method, null when the user is not signed in.
* @param websafeConferenceKey The String representation of the Conference Key to unregister
* from.
* @return Boolean true when success, otherwise false.
* @throws UnauthorizedException when the user is not signed in.
* @throws NotFoundException when there is no Conference with the given conferenceId.
*/
@ApiMethod(
name = "unregisterFromConference",
path = "conference/{websafeConferenceKey}/registration",
httpMethod = HttpMethod.DELETE
)
public WrappedBoolean unregisterFromConference(final User user,
@Named("websafeConferenceKey")
final String websafeConferenceKey)
throws UnauthorizedException, NotFoundException, ForbiddenException, ConflictException {
// If not signed in, throw a 401 error.
if (user == null) {
throw new UnauthorizedException("Authorization required");
}
final String userId = getUserId(user);
TxResult<Boolean> result = ofy().transact(new Work<TxResult<Boolean>>() {
@Override
public TxResult<Boolean> run() {
Key<Conference> conferenceKey = Key.create(websafeConferenceKey);
Conference conference = ofy().load().key(conferenceKey).now();
// 404 when there is no Conference with the given conferenceId.
if (conference == null) {
return new TxResult<>(new NotFoundException(
"No Conference found with key: " + websafeConferenceKey));
}
// Un-registering from the Conference.
Profile profile = getProfileFromUser(user, userId);
if (profile.getConferenceKeysToAttend().contains(websafeConferenceKey)) {
profile.unregisterFromConference(websafeConferenceKey);
conference.giveBackSeats(1);
ofy().save().entities(profile, conference).now();
return new TxResult<>(true);
} else {
return new TxResult<>(false);
}
}
});
// NotFoundException is actually thrown here.
return new WrappedBoolean(result.getResult());
}
示例4: remove
@ApiMethod(
name = "task.remove",
path = "task/{id}",
httpMethod = HttpMethod.DELETE
)
public void remove(@Named("id") String id, com.google.appengine.api.users.User gUser) throws OAuthRequestException, UnauthorizedException {
userService.ensureEnabled(gUser);
taskService.remove(id, userService.getUser(gUser));
}
示例5: remove
@ApiMethod(
name = "activity.remove",
path = "activity/{id}",
httpMethod = HttpMethod.DELETE
)
public void remove(@Named("id") String id, com.google.appengine.api.users.User gUser) throws OAuthRequestException, UnauthorizedException {
UserService.getInstance().ensureEnabled(gUser);
dao.remove(id);
}
示例6: remove
@ApiMethod(
name = "meeting.remove",
path = "meeting/{id}",
httpMethod = HttpMethod.DELETE
)
public void remove(@Named("id") String id, com.google.appengine.api.users.User gUser) throws OAuthRequestException, UnauthorizedException {
userService.ensureEnabled(gUser);
meetingService.remove(id, userService.getUser(gUser));
}
示例7: remove
@ApiMethod(
name = "project.remove",
path = "project/{id}",
httpMethod = HttpMethod.DELETE
)
public void remove(@Named("id") String id, com.google.appengine.api.users.User gUser) throws OAuthRequestException, UnauthorizedException {
userService.ensureEnabled(gUser);
projectService.remove(id);
}
示例8: remove
@ApiMethod(
name = "user.remove",
path = "user/{id}",
httpMethod = HttpMethod.DELETE
)
public void remove(@Named("id") String id, com.google.appengine.api.users.User gUser) throws OAuthRequestException, UnauthorizedException {
userService.ensureEnabled(gUser);
dao.remove(id);
}
示例9: deleteFoo
@ApiMethod(name = "foo.delete", description = "delete desc", path = "foos/{id}",
httpMethod = HttpMethod.DELETE)
public Foo deleteFoo(@Named("id") @Description("id desc") String id) {
return null;
}
示例10: delete
@ApiMethod(name = "delete", path = "item/{id}", httpMethod = HttpMethod.DELETE)
public void delete(@Named("id") String id) {}
示例11: unregisterFromConference
/**
* Unregister from the specified Conference.
*
* @param user An user who invokes this method, null when the user is not signed in.
* @param websafeConferenceKey The String representation of the Conference Key to unregister
* from.
* @return Boolean true when success, otherwise false.
* @throws UnauthorizedException when the user is not signed in.
* @throws NotFoundException when there is no Conference with the given conferenceId.
*/
@ApiMethod(
name = "unregisterFromConference",
path = "conference/{websafeConferenceKey}/registration",
httpMethod = HttpMethod.DELETE
)
public WrappedBoolean unregisterFromConference(final User user,
@Named("websafeConferenceKey")
final String websafeConferenceKey)
throws UnauthorizedException, NotFoundException, ForbiddenException, ConflictException {
// If not signed in, throw a 401 error.
if (user == null) {
throw new UnauthorizedException("Authorization required");
}
WrappedBoolean result = ofy().transact(new Work<WrappedBoolean>() {
@Override
public WrappedBoolean run() {
Key<Conference> conferenceKey = Key.create(websafeConferenceKey);
Conference conference = ofy().load().key(conferenceKey).now();
// 404 when there is no Conference with the given conferenceId.
if (conference == null) {
return new WrappedBoolean(false,
"No Conference found with key: " + websafeConferenceKey);
}
// Un-registering from the Conference.
Profile profile = getProfileFromUser(user);
if (profile.getConferenceKeysToAttend().contains(websafeConferenceKey)) {
profile.unregisterFromConference(websafeConferenceKey);
conference.giveBackSeats(1);
ofy().save().entities(profile, conference).now();
return new WrappedBoolean(true);
} else {
return new WrappedBoolean(false, "You are not registered for this conference");
}
}
});
// if result is false
if (!result.getResult()) {
if (result.getReason().contains("No Conference found with key")) {
throw new NotFoundException (result.getReason());
}
else {
throw new ForbiddenException(result.getReason());
}
}
// NotFoundException is actually thrown here.
return new WrappedBoolean(result.getResult());
}
示例12: delete
@ApiMethod(name = "delete", path = "survey/{id}", httpMethod = HttpMethod.DELETE)
public StringResponse delete(@Named("id") String id, User user) throws Exception {
Security.verifyAuthenticatedUser(user);
surveyService.delete(id);
return new StringResponse(String.format("Survey %s deleted successfully", id));
}
示例13: unregisterFromConference
/**
* Unregister from the specified Conference.
*
* @param user An user who invokes this method, null when the user is not signed in.
* @param websafeConferenceKey The String representation of the Conference Key to unregister
* from.
* @return Boolean true when success, otherwise false.
* @throws UnauthorizedException when the user is not signed in.
* @throws NotFoundException when there is no Conference with the given conferenceId.
*/
@ApiMethod(
name = "unregisterFromConference",
path = "conference/{websafeConferenceKey}/registration",
httpMethod = HttpMethod.DELETE
)
public WrappedBoolean unregisterFromConference(final User user,
@Named("websafeConferenceKey")
final String websafeConferenceKey)
throws UnauthorizedException, NotFoundException, ForbiddenException, ConflictException {
if (user == null) {
throw new UnauthorizedException("Authorization required");
}
WrappedBoolean result = ofy().transact(new Work<WrappedBoolean>() {
@Override
public WrappedBoolean run() {
Key<Conference> conferenceKey = Key.create(websafeConferenceKey);
Conference conference = ofy().load().key(conferenceKey).now();
if (conference == null) {
return new WrappedBoolean(false,
"No Conference found with key: " + websafeConferenceKey);
}
Profile profile = getProfileFromUser(user);
if (profile.getConferenceKeysToAttend().contains(websafeConferenceKey)) {
profile.unregisterFromConference(websafeConferenceKey);
conference.giveBackSeats(1);
ofy().save().entities(profile, conference).now();
return new WrappedBoolean(true);
} else {
return new WrappedBoolean(false, "You are not registered for this conference");
}
}
});
if (!result.getResult()) {
if (result.getReason().contains("No Conference found with key")) {
throw new NotFoundException (result.getReason());
}
else {
throw new ForbiddenException(result.getReason());
}
}
return new WrappedBoolean(result.getResult());
}
示例14: RemoveSessionFromWishlist
/**
* Remove the specified session from the user's wishlist.
*
* @param user An user who invokes this method, null when the user is not signed in.
* @param websafeSessionKey The String representation of the Session Key to remove
* from user's wishlist.
* @return Boolean true when success, otherwise false.
* @throws UnauthorizedException when the user is not signed in.
* @throws NotFoundException when there is no Session with the given sessionId.
*/
@ApiMethod(
name = "RemoveSessionFromWishlist",
path = "conference/session/{websafeSessionKey}/wishlist",
httpMethod = HttpMethod.DELETE
)
public WrappedBoolean RemoveSessionFromWishlist(final User user,
@Named("websafeSessionKey")
final String websafeSessionKey)
throws UnauthorizedException, NotFoundException, ForbiddenException, ConflictException {
if (user == null) {
throw new UnauthorizedException("Authorization required");
}
WrappedBoolean result = ofy().transact(new Work<WrappedBoolean>() {
@Override
public WrappedBoolean run() {
Key<Session> sessionKey = Key.create(websafeSessionKey);
Session session = ofy().load().key(sessionKey).now();
if (session == null) {
return new WrappedBoolean(false,
"No Session found with key: " + websafeSessionKey);
}
Profile profile = getProfileFromUser(user);
if (profile.getSessionKeysInWishlist().contains(websafeSessionKey)) {
profile.removeFromSessionKeysInWishlist(websafeSessionKey);
ofy().save().entity(profile).now();
return new WrappedBoolean(true);
} else {
return new WrappedBoolean(false, "You've not added this session in your wishlist");
}
}
});
if (!result.getResult()) {
if (result.getReason().contains("No Session found with key")) {
throw new NotFoundException (result.getReason());
}
else {
throw new ForbiddenException(result.getReason());
}
}
return new WrappedBoolean(result.getResult());
}
示例15: delete
/**
* Deletes the CloudEntity specified by its Id.
*
* @param kindName
* Name of the kind for the CloudEntity to delete.
* @param id
* Id of the CloudEntity to delete.
* @return {@link com.google.cloud.backend.beans.EntityDto} a dummy object (Endpoints requires to return any
* bean object).
* @throws com.google.api.server.spi.response.UnauthorizedException
* if the requesting {@link com.google.appengine.api.users.User} has no sufficient permission for
* the operation.
*/
@ApiMethod(path = "CloudEntities/{kind}/{id}", httpMethod = HttpMethod.DELETE)
public EntityDto delete(@Named("kind") String kindName, @Named("id") String id, User user)
throws UnauthorizedException {
SecurityChecker.getInstance().checkIfUserIsAvailable(user);
return CrudOperations.getInstance().delete(kindName, id, user);
}