use of com.willshex.blogwt.shared.api.blog.call.UpdatePropertiesRequest in project blogwt by billy1380.
the class BlogJsonServlet method processAction.
@Override
protected String processAction(String action, JsonObject request) {
String output = "null";
if ("GetProperties".equals(action)) {
GetPropertiesRequest input = new GetPropertiesRequest();
input.fromJson(request);
output = new GetPropertiesActionHandler().handle(input).toString();
} else if ("GetRatings".equals(action)) {
GetRatingsRequest input = new GetRatingsRequest();
input.fromJson(request);
output = new GetRatingsActionHandler().handle(input).toString();
} else if ("SubmitRating".equals(action)) {
SubmitRatingRequest input = new SubmitRatingRequest();
input.fromJson(request);
output = new SubmitRatingActionHandler().handle(input).toString();
} else if ("UpdateResource".equals(action)) {
UpdateResourceRequest input = new UpdateResourceRequest();
input.fromJson(request);
output = new UpdateResourceActionHandler().handle(input).toString();
} else if ("GetResource".equals(action)) {
GetResourceRequest input = new GetResourceRequest();
input.fromJson(request);
output = new GetResourceActionHandler().handle(input).toString();
} else if ("GetPosts".equals(action)) {
GetPostsRequest input = new GetPostsRequest();
input.fromJson(request);
output = new GetPostsActionHandler().handle(input).toString();
} else if ("GetArchiveEntries".equals(action)) {
GetArchiveEntriesRequest input = new GetArchiveEntriesRequest();
input.fromJson(request);
output = new GetArchiveEntriesActionHandler().handle(input).toString();
} else if ("DeleteResource".equals(action)) {
DeleteResourceRequest input = new DeleteResourceRequest();
input.fromJson(request);
output = new DeleteResourceActionHandler().handle(input).toString();
} else if ("GetResources".equals(action)) {
GetResourcesRequest input = new GetResourcesRequest();
input.fromJson(request);
output = new GetResourcesActionHandler().handle(input).toString();
} else if ("GetRelatedPosts".equals(action)) {
GetRelatedPostsRequest input = new GetRelatedPostsRequest();
input.fromJson(request);
output = new GetRelatedPostsActionHandler().handle(input).toString();
} else if ("UpdateProperties".equals(action)) {
UpdatePropertiesRequest input = new UpdatePropertiesRequest();
input.fromJson(request);
output = new UpdatePropertiesActionHandler().handle(input).toString();
} else if ("GetTags".equals(action)) {
GetTagsRequest input = new GetTagsRequest();
input.fromJson(request);
output = new GetTagsActionHandler().handle(input).toString();
} else if ("GetPost".equals(action)) {
GetPostRequest input = new GetPostRequest();
input.fromJson(request);
output = new GetPostActionHandler().handle(input).toString();
} else if ("DeletePost".equals(action)) {
DeletePostRequest input = new DeletePostRequest();
input.fromJson(request);
output = new DeletePostActionHandler().handle(input).toString();
} else if ("SetupBlog".equals(action)) {
SetupBlogRequest input = new SetupBlogRequest();
input.fromJson(request);
output = new SetupBlogActionHandler().handle(input).toString();
} else if ("CreatePost".equals(action)) {
CreatePostRequest input = new CreatePostRequest();
input.fromJson(request);
output = new CreatePostActionHandler().handle(input).toString();
} else if ("UpdatePost".equals(action)) {
UpdatePostRequest input = new UpdatePostRequest();
input.fromJson(request);
output = new UpdatePostActionHandler().handle(input).toString();
}
return output;
}
use of com.willshex.blogwt.shared.api.blog.call.UpdatePropertiesRequest in project blogwt by billy1380.
the class BlogService method updateProperties.
public Request updateProperties(UpdatePropertiesRequest input, AsyncSuccess<UpdatePropertiesRequest, UpdatePropertiesResponse> onSuccess, AsyncFailure<UpdatePropertiesRequest> onFailure) {
Request handle = null;
try {
handle = sendRequest(BlogMethodUpdateProperties, input, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
try {
UpdatePropertiesResponse outputParameter = new UpdatePropertiesResponse();
parseResponse(response, outputParameter);
if (onSuccess != null) {
onSuccess.call(input, outputParameter);
}
onCallSuccess(BlogService.this, BlogMethodUpdateProperties, input, outputParameter);
} catch (JSONException | HttpException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(BlogService.this, BlogMethodUpdateProperties, input, exception);
}
}
@Override
public void onError(Request request, Throwable exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(BlogService.this, BlogMethodUpdateProperties, input, exception);
}
});
onCallStart(BlogService.this, BlogMethodUpdateProperties, input, handle);
} catch (RequestException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(BlogService.this, BlogMethodUpdateProperties, input, exception);
}
return handle;
}
use of com.willshex.blogwt.shared.api.blog.call.UpdatePropertiesRequest in project blogwt by billy1380.
the class PropertyController method updateProperties.
public boolean updateProperties(Collection<Property> properties) {
List<Property> changed = null;
String existingPropertyValue;
boolean addToChanged;
for (Property property : properties) {
addToChanged = false;
existingPropertyValue = PropertyHelper.value(propertyLookup.get(property.name));
if (!PropertyHelper.isEmpty(property)) {
if (existingPropertyValue == null) {
addToChanged = true;
} else if (!property.value.equals(existingPropertyValue)) {
addToChanged = true;
}
}
if (addToChanged) {
if (changed == null) {
changed = new ArrayList<Property>();
}
changed.add(property);
}
}
boolean updating = changed != null;
if (updating) {
final UpdatePropertiesRequest input = SessionController.get().setSession(ApiHelper.setAccessCode(new UpdatePropertiesRequest()).properties(changed));
ApiHelper.createBlogClient().updateProperties(input, new AsyncCallback<UpdatePropertiesResponse>() {
@Override
public void onSuccess(UpdatePropertiesResponse output) {
if (output != null && output.status == StatusType.StatusTypeSuccess) {
GWT.log("Properties have been updated successfully... reload to see the effects.");
}
DefaultEventBus.get().fireEventFromSource(new UpdatePropertiesSuccess(input, output), PropertyController.this);
}
@Override
public void onFailure(Throwable caught) {
DefaultEventBus.get().fireEventFromSource(new UpdatePropertiesFailure(input, caught), PropertyController.this);
}
});
}
return updating;
}
Aggregations