本文整理汇总了Java中com.google.api.server.spi.response.ConflictException类的典型用法代码示例。如果您正苦于以下问题:Java ConflictException类的具体用法?Java ConflictException怎么用?Java ConflictException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConflictException类属于com.google.api.server.spi.response包,在下文中一共展示了ConflictException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sayHi
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
/**
* A simple endpoint method that takes a name and says Hi back
*/
/* @ApiMethod(name = "sayHi")
public MyBean sayHi(@Named("name") String name) {
MyBean response = new MyBean();
response.setData("Hi, " + name);
return response;
}*/
@ApiMethod(name = "insertUser")
public Users insertUsers(Users users) throws ConflictException {
//If if is not null, then check if it exists. If yes, throw an Exception
//that it is already present
if (users.getId() != null) {
if (findRecord(users.getId()) != null) {
throw new ConflictException("User id already exists,please login");
}
}
ofy().save().entity(users).now();
return users;
}
开发者ID:LavanyaGanganna,项目名称:Capstoneproject1,代码行数:25,代码来源:MyEndpoint.java
示例2: testRegistrationFailure_NoSeatsAvailable
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
@Test(expected = ConflictException.class)
public void testRegistrationFailure_NoSeatsAvailable() throws Exception {
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
Date startDate = dateFormat.parse("03/25/2014");
Date endDate = dateFormat.parse("03/26/2014");
List<String> topics = new ArrayList<>();
topics.add("Google");
topics.add("Cloud");
topics.add("Platform");
// Create a conference as the remaining seats is zero.
ConferenceForm conferenceForm = new ConferenceForm(
NAME, DESCRIPTION, topics, CITY, startDate, endDate, 0);
Conference conference = conferenceApi.createConference(user, conferenceForm);
conferenceApi.registerForConference(
user, conference.getWebsafeKey()).getResult();
}
开发者ID:udacity,项目名称:ud859,代码行数:17,代码来源:ConferenceApiTest.java
示例3: testRegistrationFailure_AlreadyRegisteredForTheSameConference
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
@Test(expected = ConflictException.class)
public void testRegistrationFailure_AlreadyRegisteredForTheSameConference() throws Exception {
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
Date startDate = dateFormat.parse("03/25/2014");
Date endDate = dateFormat.parse("03/26/2014");
List<String> topics = new ArrayList<>();
topics.add("Google");
topics.add("Cloud");
topics.add("Platform");
ConferenceForm conferenceForm = new ConferenceForm(
NAME, DESCRIPTION, topics, CITY, startDate, endDate, CAP);
Conference conference = conferenceApi.createConference(user, conferenceForm);
// Registration
Boolean result = conferenceApi.registerForConference(
user, conference.getWebsafeKey()).getResult();
conference = conferenceApi.getConference(conference.getWebsafeKey());
Profile profile = ofy().load().key(Key.create(Profile.class, user.getUserId())).now();
assertTrue("The first registration should succeed.", result);
assertEquals(CAP - 1, conference.getSeatsAvailable());
assertTrue("Profile should have the conferenceId in conferenceIdsToAttend.",
profile.getConferenceKeysToAttend().contains(conference.getWebsafeKey()));
// The user has already registered for the conference. This should throw an ForbiddenException.
conferenceApi.registerForConference(
user, conference.getWebsafeKey()).getResult();
}
开发者ID:udacity,项目名称:ud859,代码行数:27,代码来源:ConferenceApiTest.java
示例4: declineInvitation
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
/**
* Declines an invitation.
*
* @param gameId the game id this invitation is for.
* @param invitationId the invitation id.
* @throws NotFoundException if there is no record for this gameId and invitationId.
* @throws ConflictException if the invitation state has changed and the invitation cannot be
* declined.
*/
public void declineInvitation(long gameId, long invitationId)
throws NotFoundException, ConflictException {
InvitationEntity invitation = get(gameId, invitationId);
if (invitation == null) {
throw new NotFoundException("Invitation record not found.");
}
if (!invitation.decline()) {
throw new ConflictException(
"Unable to decline the invitation because it has already been accepted "
+ "or is no longer valid.");
}
dataStore.put(invitation.getEntity());
cacheInvitationStatus(gameId, invitationId, InvitationEntity.Status.DECLINED);
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-griddler-sample-backend-java,代码行数:27,代码来源:InvitationService.java
示例5: cancelInvitation
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
/**
* Cancels an invitation.
*
* @param gameId the game id this invitation is for.
* @param invitationId the invitation id.
* @throws NotFoundException if there is no record for this gameId and invitationId.
* @throws ConflictException if the invitation state has changed and the invitation cannot be
* cancelled.
*/
public void cancelInvitation(long gameId, long invitationId)
throws NotFoundException, ConflictException {
InvitationEntity invitation = get(gameId, invitationId);
if (invitation == null) {
throw new NotFoundException("Invitation record not found.");
}
if (!invitation.cancel()) {
throw new ConflictException(
"Unable to decline the invitation because it has already been accepted.");
}
dataStore.put(invitation.getEntity());
cacheInvitationStatus(gameId, invitationId, InvitationEntity.Status.CANCELED);
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-griddler-sample-backend-java,代码行数:26,代码来源:InvitationService.java
示例6: checkUser
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
@ApiMethod(
name = "checkUser",
path = "checkUser",
httpMethod = ApiMethod.HttpMethod.POST)
public Users checkUser(@Named ("email") String email) throws ConflictException {
/* List<Users> lusers=ofy().load().type(Users.class).filter("email","[email protected]").list();
for(Users users:lusers){
ofy().delete().type(Users.class).id(users.getId()).now();
}*/
return ofy().load().type(Users.class).filter("email",email).first().now();
}
开发者ID:LavanyaGanganna,项目名称:Capstoneproject1,代码行数:14,代码来源:UsersEndpoint.java
示例7: TxResult
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
private TxResult(Throwable exception) {
if (exception instanceof NotFoundException ||
exception instanceof ForbiddenException ||
exception instanceof ConflictException) {
this.exception = exception;
} else {
throw new IllegalArgumentException("Exception not supported.");
}
}
开发者ID:udacity,项目名称:ud859,代码行数:10,代码来源:ConferenceApi.java
示例8: getResult
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
private ResultType getResult() throws NotFoundException, ForbiddenException, ConflictException {
if (exception instanceof NotFoundException) {
throw (NotFoundException) exception;
}
if (exception instanceof ForbiddenException) {
throw (ForbiddenException) exception;
}
if (exception instanceof ConflictException) {
throw (ConflictException) exception;
}
return result;
}
开发者ID:udacity,项目名称:ud859,代码行数:13,代码来源:ConferenceApi.java
示例9: unregisterFromConference
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
/**
* 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,代码行数:50,代码来源:ConferenceApi.java
示例10: acceptInvitation
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
/**
* Accepts an invitation.
*
* @param gameId the game id this invitation is for.
* @param invitationId the invitation id.
* @throws NotFoundException if there is no record for this gameId and invitationId.
* @throws ConflictException if the invitation state has changed and the invitation cannot be
* accepted.
*/
public void acceptInvitation(long gameId, long invitationId)
throws NotFoundException, ConflictException {
InvitationEntity invitation = get(gameId, invitationId);
if (invitation == null) {
throw new NotFoundException("Invitation record not found.");
}
if (!invitation.accept()) {
throw new ConflictException(
"Unable to accept the invitation because it has already been declined "
+ "or is no longer valid.");
}
Transaction transaction = dataStore.beginTransaction();
try {
GamePlayEntity inviteePlayer =
new GamePlayEntity(invitation.getInviteeKey(), invitation.getParentKey());
GamePlayEntity senderPlayer =
new GamePlayEntity(invitation.getSenderKey(), invitation.getParentKey());
dataStore.put(transaction, senderPlayer.getEntity());
dataStore.put(transaction, inviteePlayer.getEntity());
dataStore.put(transaction, invitation.getEntity());
transaction.commit();
cacheInvitationStatus(gameId, invitationId, InvitationEntity.Status.ACCEPTED);
} finally {
if (transaction.isActive()) {
transaction.rollback();
}
}
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-griddler-sample-backend-java,代码行数:45,代码来源:InvitationService.java
示例11: register
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
@ApiMethod(
httpMethod = "POST",
path = "register"
)
public void register(RegisterAttendee command) throws ConflictException, NotFoundException, BadRequestException {
processCommand(command);
}
开发者ID:dannormington,项目名称:appengine-cqrs,代码行数:8,代码来源:AttendeeApi.java
示例12: changeName
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
@ApiMethod(
httpMethod = "POST",
path = "changename"
)
public void changeName(ChangeAttendeeName command) throws ConflictException, NotFoundException, BadRequestException {
processCommand(command);
}
开发者ID:dannormington,项目名称:appengine-cqrs,代码行数:8,代码来源:AttendeeApi.java
示例13: changeEmail
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
@ApiMethod(
httpMethod = "POST",
path = "changeemail"
)
public void changeEmail(ChangeAttendeeEmail command) throws ConflictException, NotFoundException, BadRequestException {
processCommand(command);
}
开发者ID:dannormington,项目名称:appengine-cqrs,代码行数:8,代码来源:AttendeeApi.java
示例14: confirmChangeEmail
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
@ApiMethod(
httpMethod = "POST",
path = "confirmchangeemail"
)
public void confirmChangeEmail(ConfirmChangeEmail command) throws ConflictException, NotFoundException, BadRequestException {
processCommand(command);
}
开发者ID:dannormington,项目名称:appengine-cqrs,代码行数:8,代码来源:AttendeeApi.java
示例15: unregisterFromConference
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
/**
* 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,代码行数:60,代码来源:ConferenceApi.java
示例16: updateConference
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
/**
* Updates the existing Conference with the given conferenceId.
*
* @param user A user who invokes this method, null when the user is not signed in.
* @param conferenceForm A ConferenceForm object representing user's inputs.
* @param websafeConferenceKey The String representation of the Conference key.
* @return Updated Conference object.
* @throws UnauthorizedException when the user is not signed in.
* @throws NotFoundException when there is no Conference with the given conferenceId.
* @throws ForbiddenException when the user is not the owner of the Conference.
*/
@ApiMethod(
name = "updateConference",
path = "conference/{websafeConferenceKey}",
httpMethod = HttpMethod.PUT
)
public Conference updateConference(final User user, final ConferenceForm conferenceForm,
@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);
// Update the conference with the conferenceForm sent from the client.
// Need a transaction because we need to safely preserve the number of allocated seats.
TxResult<Conference> result = ofy().transact(new Work<TxResult<Conference>>() {
@Override
public TxResult<Conference> run() {
// If there is no Conference with the id, throw a 404 error.
Key<Conference> conferenceKey = Key.create(websafeConferenceKey);
Conference conference = ofy().load().key(conferenceKey).now();
if (conference == null) {
return new TxResult<>(
new NotFoundException("No Conference found with the key: "
+ websafeConferenceKey));
}
// If the user is not the owner, throw a 403 error.
Profile profile = ofy().load().key(Key.create(Profile.class, userId)).now();
if (profile == null ||
!conference.getOrganizerUserId().equals(userId)) {
return new TxResult<>(
new ForbiddenException("Only the owner can update the conference."));
}
conference.updateWithConferenceForm(conferenceForm);
ofy().save().entity(conference).now();
return new TxResult<>(conference);
}
});
// NotFoundException or ForbiddenException is actually thrown here.
return result.getResult();
}
开发者ID:udacity,项目名称:ud859,代码行数:54,代码来源:ConferenceApi.java
示例17: registerForConference
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
/**
* Registers to 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.
* @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 = "registerForConference",
path = "conference/{websafeConferenceKey}/registration",
httpMethod = HttpMethod.POST
)
public WrappedBoolean registerForConference(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));
}
// Registration happens here.
Profile profile = getProfileFromUser(user, userId);
if (profile.getConferenceKeysToAttend().contains(websafeConferenceKey)) {
return new TxResult<>(new ConflictException("You have already registered for this conference"));
} else if (conference.getSeatsAvailable() <= 0) {
return new TxResult<>(new ConflictException("There are no seats available."));
} else {
profile.addToConferenceKeysToAttend(websafeConferenceKey);
conference.bookSeats(1);
ofy().save().entities(profile, conference).now();
return new TxResult<>(true);
}
}
});
// NotFoundException is actually thrown here.
return new WrappedBoolean(result.getResult());
}
开发者ID:udacity,项目名称:ud859,代码行数:51,代码来源:ConferenceApi.java
示例18: registerForConference
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
/**
* Register to attend 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.
* @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 = "registerForConference",
path = "conference/{websafeConferenceKey}/registration",
httpMethod = HttpMethod.POST
)
public WrappedBoolean registerForConference(final User user,
@Named("websafeConferenceKey") final String websafeConferenceKey)
throws UnauthorizedException, NotFoundException,
ForbiddenException, ConflictException {
if (user == null) {
throw new UnauthorizedException("Authorization required");
}
// Start transaction
WrappedBoolean result = ofy().transact(new Work<WrappedBoolean>() {
@Override
public WrappedBoolean run() {
try {
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)) {
return new WrappedBoolean (false, "Already registered");
} else if (conference.getSeatsAvailable() <= 0) {
return new WrappedBoolean (false, "No seats available");
} else {
profile.addToConferenceKeysToAttend(websafeConferenceKey);
conference.bookSeats(1);
ofy().save().entities(profile, conference).now();
return new WrappedBoolean(true, "Registration successful");
}
}
catch (Exception e) {
return new WrappedBoolean(false, "Unknown exception");
}
}
});
if (!result.getResult()) {
if (result.getReason().contains("No Conference found with key")) {
throw new NotFoundException (result.getReason());
}
else if (result.getReason() == "Already registered") {
throw new ConflictException("You have already registered");
}
else if (result.getReason() == "No seats available") {
throw new ConflictException("There are no seats available");
}
else {
throw new ForbiddenException("Unknown exception");
}
}
return result;
}
开发者ID:DawoonC,项目名称:dw-scalable,代码行数:74,代码来源:ConferenceApi.java
示例19: unregisterFromConference
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
/**
* 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,代码行数:55,代码来源:ConferenceApi.java
示例20: addSessionToWishlist
import com.google.api.server.spi.response.ConflictException; //导入依赖的package包/类
/**
* Add the specified session to 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.
* @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 = "addSessionToWishlist",
path = "conference/session/{websafeSessionKey}/wishlist",
httpMethod = HttpMethod.POST
)
public WrappedBoolean addSessionToWishlist(final User user,
@Named("websafeSessionKey") final String websafeSessionKey)
throws UnauthorizedException, NotFoundException,
ForbiddenException, ConflictException {
if (user == null) {
throw new UnauthorizedException("Authorization required");
}
// Start transaction
WrappedBoolean result = ofy().transact(new Work<WrappedBoolean>() {
@Override
public WrappedBoolean run() {
try {
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)) {
return new WrappedBoolean (false, "Already in the wishlist");
} else {
profile.addToSessionKeysInWishlist(websafeSessionKey);
ofy().save().entity(profile).now();
return new WrappedBoolean(true, "Successfully added to your wishlist");
}
}
catch (Exception e) {
return new WrappedBoolean(false, "Unknown exception");
}
}
});
if (!result.getResult()) {
if (result.getReason().contains("No Session found with key")) {
throw new NotFoundException (result.getReason());
}
else if (result.getReason() == "Already in the wishlist") {
throw new ConflictException("You have already added to your wishlist");
}
else {
throw new ForbiddenException("Unknown exception");
}
}
return result;
}
开发者ID:DawoonC,项目名称:dw-scalable,代码行数:68,代码来源:ConferenceApi.java
注:本文中的com.google.api.server.spi.response.ConflictException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论