Search in sources :

Example 46 with UnexpectedServerException

use of com.pratilipi.common.exception.UnexpectedServerException in project pratilipi by Pratilipi.

the class AuthorListByReadCountApi method get.

@Get
public GetResponse get(GetRequest request) throws UnexpectedServerException {
    DataListCursorTuple<AuthorByReadCountData> dataListCursorTuple = AuthorDataUtil.getAuthorListByReadCount(request.getLanguage(), request.getResultCount(), request.getCursor());
    if (dataListCursorTuple == null) {
        Logger.getLogger(AuthorListByReadCountApi.class.getSimpleName()).log(Level.INFO, "DB returned null cursor tuple");
        throw new UnexpectedServerException();
    }
    Date date = AppPropertyUtil.getTopAuthorLoadDate();
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    Logger.getLogger(AuthorListByReadCountApi.class.getSimpleName()).log(Level.INFO, "Date : " + dateFormat.format(date));
    return new GetResponse(dataListCursorTuple.getDataList(), dateFormat.format(date), dataListCursorTuple.getCursor());
}
Also used : UnexpectedServerException(com.pratilipi.common.exception.UnexpectedServerException) AuthorByReadCountData(com.pratilipi.data.client.AuthorByReadCountData) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Get(com.pratilipi.api.annotation.Get)

Aggregations

UnexpectedServerException (com.pratilipi.common.exception.UnexpectedServerException)46 IOException (java.io.IOException)19 JsonObject (com.google.gson.JsonObject)12 InvalidArgumentException (com.pratilipi.common.exception.InvalidArgumentException)12 UnsupportedEncodingException (java.io.UnsupportedEncodingException)12 HashMap (java.util.HashMap)12 Gson (com.google.gson.Gson)10 DataAccessor (com.pratilipi.data.DataAccessor)10 InsufficientAccessException (com.pratilipi.common.exception.InsufficientAccessException)6 BlobEntry (com.pratilipi.data.type.BlobEntry)6 Date (java.util.Date)6 File (java.io.File)5 JsonElement (com.google.gson.JsonElement)4 Get (com.pratilipi.api.annotation.Get)4 Post (com.pratilipi.api.annotation.Post)4 GenericResponse (com.pratilipi.api.shared.GenericResponse)4 OutputStream (java.io.OutputStream)4 URL (java.net.URL)4 GcsFilename (com.google.appengine.tools.cloudstorage.GcsFilename)3 Page (com.pratilipi.data.type.Page)3