James Moger
2011-10-24 2a99c31201b7002e4dd827b226cf2112d17ca1e1
src/com/gitblit/utils/JsonUtils.java
@@ -47,6 +47,7 @@
import com.gitblit.GitBlitException.ForbiddenException;
import com.gitblit.GitBlitException.UnauthorizedException;
import com.gitblit.GitBlitException.UnknownRequestException;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
import com.google.gson.Gson;
@@ -157,6 +158,25 @@
      }
      return gson().fromJson(json, type);
   }
   /**
    * Reads a gson object from the specified url.
    *
    * @param url
    * @param clazz
    * @param username
    * @param password
    * @return the deserialized object
    * @throws {@link IOException}
    */
   public static <X> X retrieveJson(String url, Class<X> clazz, String username, char[] password)
         throws IOException {
      String json = retrieveJsonString(url, username, password);
      if (StringUtils.isEmpty(json)) {
         return null;
      }
      return gson().fromJson(json, clazz);
   }
   /**
    * Retrieves a JSON message.
@@ -258,6 +278,9 @@
         } else if (e.getMessage().indexOf("403") > -1) {
            // requested url is forbidden by the requesting user
            throw new ForbiddenException(url);
         } else if (e.getMessage().indexOf("501") > -1) {
            // requested url is not recognized by the server
            throw new UnknownRequestException(url);
         }
         throw e;
      }