Skip to content

Commit

Permalink
Use RestUtils instead of PropertyAccessorFactory directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
soleger committed Jul 24, 2015
1 parent 7765632 commit 2a3e7fa
Showing 1 changed file with 2 additions and 10 deletions.
Expand Up @@ -61,12 +61,11 @@
import org.opennms.core.criteria.CriteriaBuilder;
import org.opennms.core.criteria.Order;
import org.opennms.netmgt.dao.api.OnmsDao;
import org.opennms.web.api.RestUtils;
import org.opennms.web.rest.support.CriteriaBuilderSearchVisitor;
import org.opennms.web.rest.support.MultivaluedMapImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.PropertyAccessorFactory;
import org.springframework.transaction.annotation.Transactional;

import com.googlecode.concurentlocks.ReadWriteUpdateLock;
Expand Down Expand Up @@ -237,14 +236,7 @@ public Response updateProperties(@Context final UriInfo uriInfo, @PathParam("id"

LOG.debug("update: updating object {}", object);

final BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(object);
for(final String key : params.keySet()) {
if (wrapper.isWritableProperty(key)) {
final String stringValue = params.getFirst(key);
final Object value = wrapper.convertIfNecessary(stringValue, (Class<?>)wrapper.getPropertyType(key));
wrapper.setPropertyValue(key, value);
}
}
RestUtils.setBeanProperties(object, params);

LOG.debug("update: object {} updated", object);
getDao().saveOrUpdate(object);
Expand Down

0 comments on commit 2a3e7fa

Please sign in to comment.