[Java - Tomcat] Permessi di lettura.

esolitos

Nuovo Utente
3
0
CPU
IntelCore2 Duo (2.2GHz)
HDD
250GiB
RAM
Crucial DDR2 67MHz 4GB
GPU
GeForce 8800m GT
OS
MacOS
Salve,
dopo la domanda inutile dell'altro giorno ho un altro problema che non risco assolutamente a risolvere.

Uso una funzione ricorsiva per reperire tutti i files contenuti in una cartella e le sue sottocartelle, fin qui nessun problema infatti mi funziona tutto con eclipse ed il server fornito dal plugin di GWT, ma se provo a fare deploy sul server dell'università ( http://ltw1008.cs.unibo.it/ ) ho un problema di permessi, nonostante i files siano dentro lo spazio della webApp.
Secondo voi è un problema coi permessi reale o c'è un sistema per aggirarlo?
Inoltre ho provato ad usare un server in locale scaricandomi Apache Tomcat e facendo la deploy nella sua cartela /webapp/phantom/ ed in questo caso mi restituisce "jndi:/localhost/phantom/xml" dove phantom è il nome della webapp.


Ecco il codice che uso:
Codice:
public class DocListServer
		extends RemoteServiceServlet
				implements DocManager {

	private static final long serialVersionUID = -6025311575129578843L;

	/**
	 * URL assoluto del root folder della web-app
	 */
	public static URL absol_ROOT_Url;

	private static FileFilter filter;

	private static ArrayList<TeiDoc> docList;
	private static HashMap<String, String> docTextCache;


	public DocListServer(){
		super();

		initVars();

	}

	
	private void initVars(){
		filter = new FileFilter(".xml");
		docList = new ArrayList<TeiDoc>();
		docTextCache = new HashMap<String, String>();

	}

	public ArrayList<TeiDoc> getDocInfo() {

		return docList;
	}
	
	
	public Boolean scanDirMain() {
		
		if(docList.isEmpty()){
			try {
				absol_ROOT_Url = new URL(PhKonst.PROTOCOL_FILE);
				absol_ROOT_Url = getServletContext().getResource(PhKonst.PATH_ROOT);
				scanDir(new URL(absol_ROOT_Url.toString().concat(PhKonst.PATH_REL_XML_DOCS)));

			} catch (MalformedURLException mue) {
				mue.printStackTrace();
				return false;
			} catch (AccessControlException ace){
				System.out.println(Errors.PERMISSION_DENIED);
				return false;
			}
		}
		
		return true;
	}

	


	/**
	 * this method lists recursively a folder and saves the file list with the associated URI list
	 *  in the <i>files</i> field
	 *  
	 * @param path the directory URI to scan
	 * @throws MalformedURLException 
	 */
	private static void scanDir(URL path) throws MalformedURLException, AccessControlException{
		File[] content = new File[0];
		File dir = new File(path.getFile());
		
		if(dir.canRead() & (content = dir.listFiles(filter)) != null){
			for (File thisFile:content){
				//System.out.println("Content["+i+"] of path "+path+":\n\t"+content[i].toString()+"\n");	// DEBUG
				
				if(thisFile.isFile())
					docList.add( XMLDocManager.getInfo(thisFile.getAbsolutePath(), thisFile.getName()) );
				else
					scanDir(new URL(PhKonst.PROTOCOL_FILE + thisFile.getAbsolutePath()));
				
			}// END for file list

		} // EndIf content != null
		else
			System.out.println(Warning.EMPTY_PATH + path);
	}
}

FileFilter.java
Codice:
public class FileFilter implements FilenameFilter {
	protected String pattern;

	/**
	 * Sets the file extension's filter
	 * @param str the file extension
	 */
	public FileFilter(String str) {
		pattern = str.toLowerCase();
	}

	public boolean accept (File dir, String name) {
		//System.out.println("Dir> "+dir.toString()+"\nFile> "+name); //DEBUG
		return (name.toLowerCase().endsWith(pattern) |
				new File(dir+"/"+name).isDirectory());
	}
}


Grazie per l'aiuto.
 

Entra

oppure Accedi utilizzando
Discord Ufficiale Entra ora!