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


Java HttpMethod.DELETE属性代码示例

本文整理汇总了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.");
  }
}
 
开发者ID:googlesamples,项目名称:io2014-codelabs,代码行数:29,代码来源:BlobEndpoint.java

示例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) {
}
 
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:11,代码来源:Endpoint1.java

示例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());
}
 
开发者ID:udacity,项目名称:ud859,代码行数:49,代码来源:ConferenceApi.java

示例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));
}
 
开发者ID:andryfailli,项目名称:teampot,代码行数:10,代码来源:TaskEndpoint.java

示例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);
}
 
开发者ID:andryfailli,项目名称:teampot,代码行数:10,代码来源:ActivityEndpoint.java

示例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));
}
 
开发者ID:andryfailli,项目名称:teampot,代码行数:9,代码来源:MeetingEndpoint.java

示例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);
}
 
开发者ID:andryfailli,项目名称:teampot,代码行数:10,代码来源:ProjectEndpoint.java

示例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);
}
 
开发者ID:andryfailli,项目名称:teampot,代码行数:10,代码来源:UserEndpoint.java

示例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;
}
 
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:5,代码来源:FooEndpoint.java

示例10: delete

@ApiMethod(name = "delete", path = "item/{id}", httpMethod = HttpMethod.DELETE)
public void delete(@Named("id") String id) {}
 
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:2,代码来源:AnnotationApiConfigGeneratorTest.java

示例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());
}
 
开发者ID:udacity,项目名称:ud859,代码行数:59,代码来源:ConferenceApi.java

示例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));
}
 
开发者ID:ipeirotis,项目名称:mturk-surveys,代码行数:6,代码来源:SurveyEndpoint.java

示例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());
}
 
开发者ID:DawoonC,项目名称:dw-scalable,代码行数:54,代码来源:ConferenceApi.java

示例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());
}
 
开发者ID:DawoonC,项目名称:dw-scalable,代码行数:53,代码来源:ConferenceApi.java

示例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);
}
 
开发者ID:googlesamples,项目名称:io2014-codelabs,代码行数:20,代码来源:EndpointV1.java


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