use of com.willshex.blogwt.client.api.blog.event.UpdatePropertiesEventHandler.UpdatePropertiesFailure 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