001
014
015 package com.liferay.portal.util;
016
017 import com.liferay.portal.kernel.security.pacl.DoPrivileged;
018 import com.liferay.portal.kernel.util.CharPool;
019 import com.liferay.portal.kernel.util.StringBundler;
020 import com.liferay.portal.kernel.util.StringPool;
021
022 import java.util.Map;
023 import java.util.Set;
024 import java.util.concurrent.ConcurrentHashMap;
025
026
030 @DoPrivileged
031 public class CustomJspRegistryImpl implements CustomJspRegistry {
032
033 public CustomJspRegistryImpl() {
034 _servletContextNames = new ConcurrentHashMap<String, String>();
035 }
036
037 public String getCustomJspFileName(
038 String servletContextName, String fileName) {
039
040 int pos = fileName.lastIndexOf(CharPool.PERIOD);
041
042 if (pos == -1) {
043 return fileName.concat(StringPool.PERIOD).concat(
044 servletContextName);
045 }
046
047 StringBundler sb = new StringBundler(4);
048
049 sb.append(fileName.substring(0, pos));
050 sb.append(CharPool.PERIOD);
051 sb.append(servletContextName);
052 sb.append(fileName.substring(pos));
053
054 return sb.toString();
055 }
056
057 public String getDisplayName(String servletContextName) {
058 return _servletContextNames.get(servletContextName);
059 }
060
061 public Set<String> getServletContextNames() {
062 return _servletContextNames.keySet();
063 }
064
065 public void registerServletContextName(
066 String servletContextName, String displayName) {
067
068 _servletContextNames.put(servletContextName, displayName);
069 }
070
071 public void unregisterServletContextName(String servletContextName) {
072 _servletContextNames.remove(servletContextName);
073 }
074
075 private Map<String, String> _servletContextNames;
076
077 }