use of com.willshex.blogwt.shared.api.blog.call.UpdatePropertiesResponse 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;
}
use of com.willshex.blogwt.shared.api.blog.call.UpdatePropertiesResponse 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;
}
Aggregations