Skip to content

Commit

Permalink
Bug #13234: using application cache instead session cache in order to…
Browse files Browse the repository at this point in the history
… get the document visualization working with anonymous session.
  • Loading branch information
SilverYoCha authored and mmoqui committed Nov 8, 2022
1 parent 37c0725 commit 8be84bb
Showing 1 changed file with 4 additions and 5 deletions.
Expand Up @@ -25,6 +25,7 @@

import org.jboss.resteasy.plugins.providers.html.View;
import org.silverpeas.core.annotation.WebService;
import org.silverpeas.core.cache.model.Cache;
import org.silverpeas.core.contribution.attachment.AttachmentException;
import org.silverpeas.core.contribution.attachment.AttachmentService;
import org.silverpeas.core.contribution.attachment.model.SimpleDocument;
Expand All @@ -51,7 +52,7 @@
import java.nio.file.Paths;

import static org.apache.commons.io.FilenameUtils.getBaseName;
import static org.silverpeas.core.cache.service.CacheServiceProvider.getSessionCacheService;
import static org.silverpeas.core.cache.service.CacheServiceProvider.getApplicationCacheService;
import static org.silverpeas.core.util.StringUtil.isDefined;
import static org.silverpeas.core.util.StringUtil.isNotDefined;

Expand Down Expand Up @@ -90,8 +91,7 @@ public View getPdfEmbedViewer(@QueryParam("documentId") final String documentId,
setCommonRequestViewerAttributes(document);

final String cacheKey = PDF_VIEWER_CACHE_PREFIX + documentId + "@" + language;
getSessionCacheService().getCache().put(cacheKey, true);

((Cache) getApplicationCacheService().getCache()).put(cacheKey, true, 10, 0);
return new View("/media/jsp/pdf/viewer.jsp");
} catch (final WebApplicationException ex) {
throw ex;
Expand All @@ -111,8 +111,7 @@ public Response getPdfContent(@QueryParam("documentId") final String documentId,
@QueryParam("language") final String language) {
try {
final String cacheKey = PDF_VIEWER_CACHE_PREFIX + documentId + "@" + language;
final boolean playerAccessed = getSessionCacheService().getCache().remove(cacheKey) != null;

final boolean playerAccessed = getApplicationCacheService().getCache().remove(cacheKey) != null;
if (!playerAccessed) {
return Response.seeOther(getUri().getAbsoluteWebResourcePathBuilder()
.path("pdf")
Expand Down

0 comments on commit 8be84bb

Please sign in to comment.