001
014
015 package com.liferay.portal.servlet.filters.aggregate;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.util.FileUtil;
020 import com.liferay.portal.kernel.util.Validator;
021
022 import java.io.File;
023 import java.io.IOException;
024
025
028 public class FileAggregateContext implements AggregateContext {
029
030 public FileAggregateContext(File file) {
031 _file = file.getParentFile();
032 }
033
034 public String getContent(String path) {
035 try {
036 File file = new File(_file, path);
037
038 return FileUtil.read(file);
039 }
040 catch (IOException ioe) {
041 _log.error(ioe, ioe);
042 }
043
044 return null;
045 }
046
047 public String getFullPath(String path) {
048 String absolutePath = _file.getAbsolutePath();
049
050 return absolutePath.concat(path);
051 }
052
053 public void popPath(String path) {
054 if (Validator.isNotNull(path)) {
055 _file = _file.getParentFile();
056 }
057 }
058
059 public void pushPath(String path) {
060 if (Validator.isNotNull(path)) {
061 _file = new File(_file, path);
062 }
063 }
064
065 private static Log _log = LogFactoryUtil.getLog(FileAggregateContext.class);
066
067 private File _file;
068
069 }