X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Frserv%2FCachingFileAccess.java;h=cdda50db48eba07714994cd2a0299a7721a01c09;hb=82755753f41112e1cdd91b2994620ad074dfbf20;hp=37f3b0889ff5a4f5ff65693db7c70d1ec8ec718f;hpb=078325f8ef05a6216292f5331ef0805a5bdd9ef1;p=aaf%2Fauthz.git diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java index 37f3b088..cdda50db 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -55,15 +55,15 @@ import org.onap.aaf.misc.env.Store; import org.onap.aaf.misc.env.Trans; /* * CachingFileAccess - * + * * Author: Jonathan Gathman, Gathsys 2010 - * + * */ public class CachingFileAccess extends HttpCode { public static void setEnv(Store store, String[] args) { - for (int i=0;i extends HttpCode typeMap; private final NavigableMap content; private final Set attachOnly; - public final static String CFA_WEB_PATH = "aaf_cfa_web_path"; + public static final String CFA_WEB_PATH = "aaf_cfa_web_path"; // when to re-validate from file // Re validating means comparing the Timestamp on the disk, and seeing it has changed. Cache is not marked - // dirty unless file has changed, but it still makes File IO, which for some kinds of cached data, i.e. + // dirty unless file has changed, but it still makes File IO, which for some kinds of cached data, i.e. // deployed GUI elements is unnecessary, and wastes time. // This parameter exists to cover the cases where data can be more volatile, so the user can choose how often the // File IO will be accessed, based on probability of change. "0", of course, means, check every time. - private final static String CFA_CACHE_CHECK_INTERVAL = "aaf_cfa_cache_check_interval"; - private final static String CFA_MAX_SIZE = "aaf_cfa_max_size"; // Cache size limit - private final static String CFA_CLEAR_COMMAND = "aaf_cfa_clear_command"; + private static final String CFA_CACHE_CHECK_INTERVAL = "aaf_cfa_cache_check_interval"; + private static final String CFA_MAX_SIZE = "aaf_cfa_max_size"; // Cache size limit + private static final String CFA_CLEAR_COMMAND = "aaf_cfa_clear_command"; // Note: can be null without a problem, but included // to tie in with existing Logging. @@ -93,13 +93,15 @@ public class CachingFileAccess extends HttpCode extends HttpCode extends HttpCode2 && slash>=0 && key.substring(0,slash).equals(clear_command)) { + if(key.length()>2 && slash>=0 && key.substring(0,slash).equals(clearCommand)) { resp.setHeader("Content-Type",typeMap.get("txt")); if ("clear".equals(key.substring(slash+1))) { content.clear(); @@ -171,7 +179,7 @@ public class CachingFileAccess extends HttpCode extends HttpCode extends HttpCode extends HttpCode extends HttpCode extends HttpCode0; } - + if (mediaType==null) { // determine from file Ending int idx = key.lastIndexOf('.'); String subkey = key.substring(++idx); @@ -273,9 +281,9 @@ public class CachingFileAccess extends HttpCode extends HttpCode extends HttpCode extends HttpCode() { @Override @@ -393,7 +401,7 @@ public class CachingFileAccess extends HttpCode extends HttpCode extends HttpCode extends HttpCode extends HttpCode content; - + public Cleanup(NavigableMap content, int size) { maxSize = size; this.content = content; } - + private class Comp implements Comparable { public Map.Entry entry; - + public Comp(Map.Entry en) { entry = en; } - + @Override public int compareTo(Comp o) { return (int)(entry.getValue().access-o.entry.getValue().access); } - + } @SuppressWarnings("unchecked") @Override @@ -520,16 +528,10 @@ public class CachingFileAccess extends HttpCode entry = scont.get(i).entry; content.remove(entry.getKey()); - //System.out.println("removed Cache Item " + entry.getKey() + "/" + new Date(entry.getValue().access).toString()); } -// for (int i=end;i entry = scont.get(i).entry; -// //System.out.println("remaining Cache Item " + entry.getKey() + "/" + new Date(entry.getValue().access).toString()); -// } } } }