Class FileManager
- All Implemented Interfaces:
Constants,Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
FileManager è la classe che si occupa della gestione dei files
caricati dall'utente, della generazione di link per il download,
l'impostazione dei privilegi, secondo eventuali policy,
dell'aggiornamento e di quant'altro occorra alle funzioni di gestione allegati
della web-application Rol.
- Author:
- Giovanroberto Torre
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]Carica la lista con le estensioni vietatestatic final charTalking const for the preferred, standard separator between entity names and attribute names.Fields inherited from interface it.rol.Constants
AMPERSAND, APOSTROPHE, BEAN_DEFAULT_FLOAT, BEAN_DEFAULT_ID, BLANK_SPACE, COLON, COMMA, COMMAND_AUDIT, COMMAND_HOME, COMMAND_INDICATOR, COMMAND_MEASURE, COMMAND_PROCESS, COMMAND_REPORT, COMMAND_RISK, COMMAND_STRUCTURES, CP1, CP2, CP3, CSV, DASH, DATA_FORMAT, DATA_GENERAL_PATTERN, DATA_SQL_PATTERN, DEFAULT_ID, DELETE, DOT, ELEMENT_LEV_1, ELEMENT_LEV_2, ELEMENT_LEV_3, ELEMENT_LEV_4, ENGLISH_DOUBLE_QUOTE_CLOSE, ENGLISH_DOUBLE_QUOTE_OPEN, ENGLISH_SINGLE_QUOTE, EQ, ERR, GR, HTML, HYPHEN, I, I1, I2, I3, I4, IF_EXISTS_DONOT_CREATE_NEW, INTERVIEW, INTERVIEWS, JSON, JSP_EXT, LIVELLI_RISCHIO, LIVELLI_RISCHIO_AS_LIST, LOG_IND, MAIN_MENU, MDASH, MESSAGE, MIME_TYPE_HTML, MIME_TYPE_TEXT, ND, NDASH, NOTHING, P, P1, P2, P3, P4, P5, P6, P7, PARAM_SURVEY, PART_CONFIRM_QST, PART_CREDITS, PART_FACTORS, PART_GRAPHICS, PART_INDICATOR, PART_INPUT, PART_INSERT_ACT_STRUCTS, PART_INSERT_ACTIVITY, PART_INSERT_F_R_P, PART_INSERT_INDICATOR, PART_INSERT_INPUT, PART_INSERT_M_R_P, PART_INSERT_MEASURE, PART_INSERT_MEASUREMENT, PART_INSERT_MONITOR_DATA, PART_INSERT_OUTPUT, PART_INSERT_PROCESS, PART_INSERT_PROCESS_RISK, PART_INSERT_RISK, PART_INSERT_RISK_PROCESS, PART_INSERT_SUBJECT, PART_MACROPROCESS, PART_MEASURES, PART_MONITOR, PART_OUTPUT, PART_PI_NOTE, PART_PROCESS, PART_RESUME_QST, PART_RISKS, PART_SEARCH, PART_SELECT_MEASUREMENT, PART_SELECT_MONITOR_DATA, PART_SELECT_QSS, PART_SELECT_QST, PART_SELECT_STR, PART_UPDATE_ACTIVITY, PART_UPDATE_MEASURE, PART_USR, PER_CENT, PI, PIM, PIR, PRO_PFX, PROCESS, QM, QUOTE, REFERRAL, REPORT_MDM, REPORT_MDM_MES, RISKS, ROOT_QM, RTF, SEMICOLON, SEPARATOR, SLASH, STATI_STRUTTURA, STATI_STRUTTURA_AS_LIST, STR_PFX, STRUCTURES, SUB_MENU, THE_END_OF_TIME, TIME_SQL_PATTERN, TIPI_LISTE, TWELWE_HOUR_FORMAT, UNDERSCORE, UNIX_EPOCH, UPDATE, VOID_SQL_STRING, VOID_STRING, WEIGHT_GENERIC, WEIGHT_SPECIFIC, YEAR_SHIFT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcheckPrime(String toCheck) Returns a String replacing all the sequence of characters matching regex and replacement String.protected voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) La chiamata diretta della Servlet con il metodo GET produce il logout.protected voiddoPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Handles file upload.static LinkedList<String> Getter su variabile di classestatic StringgetContent(String path) Legge un file (di configurazione)static longgetFileSizeBytes(File file) Restituisce il peso in bytes di un file che accetta come argomento.static doublegetFileSizeKiloBytes(File file) Restituisce il peso in KiloBytes di un file che accetta come argomento.static doublegetFileSizeMegaBytes(File file) Restituisce il peso in MegaBytes di un file che accetta come argomento.voidinit(javax.servlet.ServletConfig config) Inizializza, staticamente, alcune variabili globali.Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, serviceMethods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
STD_SPACER
public static final char STD_SPACERTalking const for the preferred, standard separator between entity names and attribute names.- See Also:
-
FORBIDDEN_EXTENSIONS
Carica la lista con le estensioni vietate
-
-
Constructor Details
-
FileManager
public FileManager()
-
-
Method Details
-
init
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException Inizializza, staticamente, alcune variabili globali.
- Specified by:
initin interfacejavax.servlet.Servlet- Overrides:
initin classjavax.servlet.GenericServlet- Parameters:
config- la configurazione usata dal servlet container per passare informazioni alla servlet durante l'inizializzazione- Throws:
javax.servlet.ServletException- una eccezione che puo' essere sollevata quando la servlet incontra difficolta'
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, IOException La chiamata diretta della Servlet con il metodo GET produce il logout.
- Overrides:
doGetin classjavax.servlet.http.HttpServlet- Parameters:
req- la HttpServletRequest contenente la richiesta del clientres- la HttpServletResponse contenente la risposta del server- Throws:
javax.servlet.ServletException- eccezione che viene sollevata se si verifica un problema nell'inoltro (forward) della richiesta/rispostaIOException- eccezione che viene sollevata se si verifica un problema nell'inoltro (forward) della richiesta/risposta- See Also:
-
doPost
protected void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, IOException Handles file upload.
Utilizza un approccio di programmazione difensiva per garantire la correttezza dell'input.
- Overrides:
doPostin classjavax.servlet.http.HttpServlet- Parameters:
req- la HttpServletRequest contenente la richiesta del clientres- la HttpServletResponse contenente la risposta del server- Throws:
javax.servlet.ServletException- eccezione che viene sollevata se si verifica un problema nell'inoltro (forward) della richiesta/rispostaIOException- eccezione che viene sollevata se si verifica un problema nell'inoltro (forward) della richiesta/risposta
-
getAllowedUploadCommand
Getter su variabile di classe- Returns:
LinkedList<String>- Elenco delle Command abilitate a caricare files in upload
-
checkPrime
Returns a String replacing all the sequence of characters matching regex and replacement String.
- Parameters:
toCheck- the String to check- Returns:
String- the String replaced
-
getFileSizeBytes
Restituisce il peso in bytes di un file che accetta come argomento.
- Parameters:
file- File di cui bisogna restituire il peso in B- Returns:
long- il peso del file in B
-
getFileSizeKiloBytes
Restituisce il peso in KiloBytes di un file che accetta come argomento.
- Parameters:
file- File di cui bisogna restituire il peso in KB- Returns:
double- il peso del file in Kappa
-
getFileSizeMegaBytes
Restituisce il peso in MegaBytes di un file che accetta come argomento.
- Parameters:
file- File di cui bisogna restituire il peso in MB- Returns:
double- il peso del file in Mega
-
getContent
Legge un file (di configurazione)- Parameters:
path-- Returns:
- Throws:
NotFoundExceptionCommandException
-