]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - server/runtime/org.argeo.server.json/src/main/java/org/argeo/server/json/JsonServerMapper.java
Move to the root the bundles which will be part of v1.4 and v2.2
[lgpl/argeo-commons.git] / server / runtime / org.argeo.server.json / src / main / java / org / argeo / server / json / JsonServerMapper.java
index 36312ed59fe4f4e614875732d4bedeefdc49398d..a7c860c63f928c6e7a38d1fa1b24be8ce1236c9f 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.argeo.server.json;
 
 import java.io.IOException;
@@ -9,9 +24,8 @@ import java.util.Map;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.argeo.server.ArgeoServerException;
+import org.argeo.ArgeoException;
 import org.argeo.server.Deserializer;
-import org.argeo.server.ServerDeserializer;
 import org.codehaus.jackson.JsonProcessingException;
 import org.codehaus.jackson.map.DeserializationContext;
 import org.codehaus.jackson.map.DeserializationProblemHandler;
@@ -21,7 +35,7 @@ import org.codehaus.jackson.map.deser.StdDeserializerProvider;
 import org.springframework.beans.factory.InitializingBean;
 
 public class JsonServerMapper extends JsonServerSerializer implements
-               ServerDeserializer, Deserializer, InitializingBean {
+               Deserializer, InitializingBean {
        private final static Log log = LogFactory.getLog(JsonServerMapper.class);
 
        private Class<?> targetClass;
@@ -33,6 +47,8 @@ public class JsonServerMapper extends JsonServerSerializer implements
                CustomDeserializerFactory dsf = new CustomDeserializerFactory();
                for (Class clss : deserializers.keySet()) {
                        dsf.addSpecificMapping(clss, deserializers.get(clss));
+                       if (log.isDebugEnabled())
+                               log.debug("Add JSON mapping for " + clss);
                }
                StdDeserializerProvider sdp = new StdDeserializerProvider(dsf);
                getObjectMapper().setDeserializerProvider(sdp);
@@ -45,7 +61,8 @@ public class JsonServerMapper extends JsonServerSerializer implements
                                                        String propertyName) throws IOException,
                                                        JsonProcessingException {
                                                if (log.isTraceEnabled())
-                                                       log.debug("Ignore property " + propertyName);
+                                                       log.debug("Ignore property " + propertyName
+                                                                       + " in bean " + bean);
                                                ctxt.getParser().skipChildren();
                                                return true;
                                        }
@@ -62,7 +79,7 @@ public class JsonServerMapper extends JsonServerSerializer implements
 
                        return getObjectMapper().readValue(reader, targetClass);
                } catch (Exception e) {
-                       throw new ArgeoServerException("Cannot deserialize " + reader, e);
+                       throw new ArgeoException("Cannot deserialize " + reader, e);
                }
 
        }
@@ -77,7 +94,7 @@ public class JsonServerMapper extends JsonServerSerializer implements
 
                        return getObjectMapper().readValue(reader, clss);
                } catch (Exception e) {
-                       throw new ArgeoServerException("Cannot deserialize " + reader, e);
+                       throw new ArgeoException("Cannot deserialize " + reader, e);
                }
 
        }