Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge pull request #789 from zanata/logging-for-failures
Browse files Browse the repository at this point in the history
Add server logging for failure responses
  • Loading branch information
seanf committed Apr 30, 2015
2 parents 3f5db95 + be9e73b commit bb1bb59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Expand Up @@ -25,6 +25,7 @@
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
Expand Down Expand Up @@ -52,6 +53,7 @@
*/
@Name("editor.translationService")
@Path(TranslationResource.SERVICE_PATH)
@Slf4j
@Transactional
public class TranslationService implements TranslationResource {
@In
Expand Down Expand Up @@ -80,7 +82,10 @@ public Response get(String localeId, String ids) {
}
List<Long> idList = TransUnitUtils.filterAndConvertIdsToList(ids);
if (idList.size() > TransUnitUtils.MAX_SIZE) {
return Response.status(Response.Status.FORBIDDEN).build();
String msg = String.format("More than %d results.", TransUnitUtils.MAX_SIZE);
log.warn(msg);
return Response.status(Response.Status.FORBIDDEN).entity(msg)
.build();
}

HLocale locale = localeServiceImpl.getByLocaleId(localeId);
Expand Down
Expand Up @@ -41,6 +41,7 @@
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.StreamingOutput;

import lombok.extern.slf4j.Slf4j;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.zanata.adapter.FileFormatAdapter;
Expand Down Expand Up @@ -69,6 +70,7 @@

@Name("fileService")
@Path(FileResource.FILE_RESOURCE)
@Slf4j
public class FileService implements FileResource {
private static final String FILE_TYPE_OFFLINE_PO = "offlinepo";
private static final String FILE_TYPE_OFFLINE_PO_TEMPLATE = "offlinepot";
Expand Down Expand Up @@ -152,7 +154,7 @@ public Response downloadSourceFile(String projectSlug,
.getRawDocumentContentAsStream(document
.getRawDocument());
} catch (RawDocumentContentAccessException e) {
e.printStackTrace();
log.error(e.toString(), e);
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e)
.build();
}
Expand Down Expand Up @@ -260,6 +262,7 @@ public Response downloadTranslationFile(String projectSlug,
.getRawDocumentContentAsStream(hDocument
.getRawDocument());
} catch (RawDocumentContentAccessException e) {
log.error(e.toString(), e);
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e)
.build();
}
Expand Down

0 comments on commit bb1bb59

Please sign in to comment.