Fórumok

Where to put a file to read from a hook/portlet?

thumbnail
Cameron McBride, módosítva 12 év-val korábban

Where to put a file to read from a hook/portlet?

Expert Bejegyzések: 269 Csatlakozás dátuma: 2011.02.08. Legújabb bejegyzések
I bet if I knew the right terminology here I could search for it. The hook I'm working with uses some 3rd party source that needs to read in a config file. I would like to keep this file bundled inside the hook instead of putting it in \some\random\directory.

Is there somewhere I can place the file inside the hook where it would be accessible? For example I tried putting it in WEB-INF\src\myfile.conf and then specifying no path to where the config file would be. That obviously didnt work.

For more detailed information I am working with the spnego source (http://spnego.sourceforge.net/) and in my hook I have some filter mapping:
<init-param>
	        <param-name>spnego.login.conf</param-name>
	        <param-value>C:\\liferay\\liferay-portal-6.1.0\\login.conf</param-value>
	    </init-param>


I want to put the config file inside my portlet instead of a hard coded path.
thumbnail
David H Nebinger, módosítva 12 év-val korábban

RE: Where to put a file to read from a hook/portlet?

Liferay Legend Bejegyzések: 14916 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
Classpath won't work? If you dropped it in the src directory, it should end up in the classes directory and then consumed as a classpath resource...
thumbnail
Brian Jamieson, módosítva 12 év-val korábban

RE: Where to put a file to read from a hook/portlet?

Junior Member Bejegyzések: 51 Csatlakozás dátuma: 2010.10.15. Legújabb bejegyzések
I took a different approach, and dropped files into the document/media portlet.
You can then use the URL in your code...

URL importURL = new URL(ParamUtil.getString(request, "importURL"));
InputStreamReader in = new InputStreamReader(importURL.openStream());
ICsvMapReader inFile = new CsvMapReader(in,CsvPreference.EXCEL_PREFERENCE);

etc
etc
thumbnail
Cameron McBride, módosítva 12 év-val korábban

RE: Where to put a file to read from a hook/portlet?

Expert Bejegyzések: 269 Csatlakozás dátuma: 2011.02.08. Legújabb bejegyzések
I have to have a path to put as a filter param value, you can see in the snippet I put up above. So I have to put something, c:\path\login.conf or .\login.conf, etc.
thumbnail
David H Nebinger, módosítva 12 év-val korábban

RE: Where to put a file to read from a hook/portlet?

Liferay Legend Bejegyzések: 14916 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
Well, reading up on the install for tomcat, you drop spnego jar in the lib directory and the krb5/login.conf files into the CATALINA_HOME directory (optionally in CATALINA_HOME/bin if you start tomcat from the command line). Then in web.xml you just use the short name, i.e. login.conf, and it does the rest.

Is that the difference? Are you trying to enable spnego only under the Liferay context and not tomcat as a whole?
thumbnail
Cameron McBride, módosítva 12 év-val korábban

RE: Where to put a file to read from a hook/portlet?

Expert Bejegyzések: 269 Csatlakozás dátuma: 2011.02.08. Legújabb bejegyzések
Yeah, I had given up trying to enable it at the Tomcat level and have created a 6.1 servlet filter that can be deployed. So it would be great to be able to deploy the two config files in the hook instead of manually placing them somewhere. I have tried putting the two config files in WEB-INF, where the web.xml is and giving no path to the two .conf files. I also had them in the "src" directory, which copies them to classes, so I tried classes\\login.conf but that was also a no go.

I have made some excellent progress on the servlet filter over all but I will update the other thread rather than veer off topic in this one.
thumbnail
David H Nebinger, módosítva 12 év-val korábban

RE: Where to put a file to read from a hook/portlet?

Liferay Legend Bejegyzések: 14916 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
I'm guessing that spnego uses the classpath to find the config files, since they have to be in bin if you use the startup.bat script. Have you tried putting them in the src folder and just specifying the config files w/o a path?
thumbnail
Cameron McBride, módosítva 12 év-val korábban

RE: Where to put a file to read from a hook/portlet?

Expert Bejegyzések: 269 Csatlakozás dátuma: 2011.02.08. Legújabb bejegyzések
Yeah the two things I have tried are no path and "classes\\file.conf". In both tests I had the config files in WEB-INF and in WEB-INF\src|classes".