use of javax.portlet.PortletContext in project uPortal by Jasig.
the class FilterConfigImplTest method testParams.
@Test
public void testParams() {
final List<InitParamType> initParams = new ArrayList<InitParamType>();
InitParamType p1 = new InitParamType();
p1.setParamName("param1");
p1.setParamValue("value1");
InitParamType p2 = new InitParamType();
p2.setParamName("param2");
p2.setParamValue("value2");
initParams.add(p1);
initParams.add(p2);
final String filterName = "filterWithParams";
PortletContext portletContext = EasyMock.createMock(PortletContext.class);
EasyMock.replay(portletContext);
FilterConfigImpl impl = new FilterConfigImpl(filterName, initParams, portletContext);
Assert.assertEquals(filterName, impl.getFilterName());
Assert.assertEquals("value1", impl.getInitParameter("param1"));
Assert.assertEquals("value2", impl.getInitParameter("param2"));
Assert.assertNotNull(impl.getPortletContext());
}
use of javax.portlet.PortletContext in project uPortal by Jasig.
the class AbstractDynamicSkinService method getSkinNames.
@Override
public /**
* Returns the set of skins to use. This implementation parses the skinList.xml file and returns the set of
* skin-key element values. If there is an error parsing the XML file, return an empty set.
*/
SortedSet<String> getSkinNames(PortletRequest request) {
// Context to access the filesystem
PortletContext ctx = request.getPortletSession().getPortletContext();
// Determine the full path to the skins directory
String skinsFilepath = ctx.getRealPath(this.localRelativeRootPath + "/skinList.xml");
// Create File object to access the filesystem
File skinList = new File(skinsFilepath);
TreeSet<String> skins = new TreeSet<>();
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(skinList);
doc.getDocumentElement().normalize();
NodeList nList = doc.getElementsByTagName("skin-key");
for (int temp = 0; temp < nList.getLength(); temp++) {
org.w3c.dom.Element element = (org.w3c.dom.Element) nList.item(temp);
String skinName = element.getTextContent();
log.debug("Found skin-key value {}", skinName);
skins.add(skinName);
}
} catch (SAXException | ParserConfigurationException | IOException e) {
log.error("Error processing skinsFilepath {}", skinsFilepath, e);
}
return skins;
}
use of javax.portlet.PortletContext in project uPortal by Jasig.
the class FilterConfigImplTest method testControl.
@Test
public void testControl() {
final List<InitParamType> initParams = new ArrayList<InitParamType>();
final String filterName = "controlFilter";
PortletContext portletContext = EasyMock.createMock(PortletContext.class);
EasyMock.replay(portletContext);
FilterConfigImpl impl = new FilterConfigImpl(filterName, initParams, portletContext);
Assert.assertEquals(filterName, impl.getFilterName());
Assert.assertNull(impl.getInitParameter("someparam"));
Assert.assertNull(impl.getInitParameter("someparam2"));
Assert.assertNotNull(impl.getPortletContext());
}
use of javax.portlet.PortletContext in project uPortal by Jasig.
the class AbstractDynamicSkinService method processLessFile.
/**
* Less compile the include file into a temporary css file. When done rename the temporary css file to the
* correct output filename. Since the less compilation phase takes several seconds, this insures the
* output css file is does not exist on the filesystem until it is complete.
*
* @param lessIncludeFilepath less include file that includes all dependencies
* @param outputFilepath name of the output css file
* @param lessCssJavascriptUrl lessCssJavascript compiler url
* @throws IOException
* @throws LessException
*/
private void processLessFile(DynamicSkinInstanceData data) throws IOException, LessException {
final PortletContext ctx = data.getPortletRequest().getPortletSession().getPortletContext();
final URL lessCssJavascriptUrl = ctx.getResource(this.lessCssJavascriptUrlPath);
final LessSource lessSource = new LessSource(new File(this.getSkinLessPath(data)));
if (log.isDebugEnabled()) {
final String result = lessSource.getNormalizedContent();
final File lessSourceOutput = new File(this.getSkinCssTempFileAbsolutePath(data) + "lesssource");
IOUtils.write(result, new FileOutputStream(lessSourceOutput));
log.debug("Full Less source from include file {0}, using lessCssJavascript at {1}" + ", is at {2}, output css will be written to {3}", this.getSkinLessPath(data), lessCssJavascriptUrl.toString(), lessSourceOutput, this.getSkinCssPath(data));
}
final LessCompiler compiler = new LessCompiler();
compiler.setLessJs(lessCssJavascriptUrl);
compiler.setCompress(true);
final File tempOutputFile = new File(this.getSkinCssTempFileAbsolutePath(data));
compiler.compile(lessSource, tempOutputFile);
this.moveCssFileToFinalLocation(data, tempOutputFile);
}
Aggregations