From: <jbo...@li...> - 2005-11-08 21:59:28
|
Author: unibrew Date: 2005-11-08 16:59:25 -0500 (Tue, 08 Nov 2005) New Revision: 1533 Modified: trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/FileAccessFilter.java Log: [JBLAB-263] Temporary commented all download counter code Modified: trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/FileAccessFilter.java =================================================================== --- trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/FileAccessFilter.java 2005-11-08 17:33:35 UTC (rev 1532) +++ trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/FileAccessFilter.java 2005-11-08 21:59:25 UTC (rev 1533) @@ -21,6 +21,7 @@ */ package org.jboss.forge.fileaccess; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -36,7 +37,11 @@ import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.Node; import org.jboss.shotoku.aop.Inject; +import org.jboss.forge.common.ForgeHelper; +import org.jboss.forge.common.projects.DownloadCountersDescriptor; +import org.jboss.forge.common.projects.DownloadCountersWatcher; + /** * A filter that enables to download files which are stored in a working copy of * a content repository. @@ -120,11 +125,26 @@ // Checking if we can allow access to this resource. checkResource(requestedRes); + /* IMPLEMENTATION OF DOWNLOAD COUNTER TEMPORARY COMMENTED if (requestedRes.indexOf(DOWNLOADS_ACCESS)!=-1) { - // Sending the request to the DownloadCounter to increment + String portalName = resolvePortalName(requestedRes); + DownloadCountersDescriptor downloadCounters = (DownloadCountersDescriptor) ForgeHelper + .getForgeManagement().getFromCache(portalName, + DownloadCountersDescriptor.class.getName()); + + if (downloadCounters == null) + downloadCounters = (DownloadCountersDescriptor) ForgeHelper.getForgeManagement() + .addNodeWatcher(portalName, + DownloadCountersDescriptor.class.getName(), + new DownloadCountersWatcher(contentManager)); + + + // Sending the request link to the DownloadCounter to increment // counter for this link if it's one of the tracked links. - //DownloadCounter.increment(requestedRes,contentManager); - } + + downloadCounters.increment(requestedRes); + + } */ Node requestedNode = contentManager.getNode(requestedRes); String mimeType = requestedNode.getMimeType(); @@ -159,6 +179,15 @@ } } + /** + * Method used to resolve portal name to which the download link aims. + * @param link + * @return + */ + private static String resolvePortalName (String link) { + return link.split(File.separator)[0]; + } + public void destroy() { } |