fr.paris.lutece.plugins.directory.utils
Class DirectoryUtils

java.lang.Object
  extended by fr.paris.lutece.plugins.directory.utils.DirectoryUtils

public final class DirectoryUtils
extends java.lang.Object

class DirectoryUtils


Field Summary
static java.lang.String CONSTANT_AND
           
static int CONSTANT_ID_NULL
           
static int CONSTANT_ID_ZERO
           
static java.lang.String CONSTANT_WHERE
           
static java.lang.String EMPTY_STRING
           
static java.lang.String TEMPLATE_FORM_DIRECTORY_RECORD
           
static java.lang.String TEMPLATE_FORM_SEARCH_DIRECTORY_RECORD
           
 
Method Summary
static void addHeaderResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String strFileName)
          write the http header in the response
static java.lang.String buildRequetteWithFilter(java.lang.String strSelect, java.util.List<java.lang.String> listStrFilter, java.lang.String strOrder)
          Builds a query with filters placed in parameters
static int convertStringToInt(java.lang.String strParameter)
          convert a string to int
static IEntry createEntryByType(javax.servlet.http.HttpServletRequest request, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          return an instance of IEntry function of type entry
static IEntry createEntryByType(int nIdType, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          return an instance of IEntry function of type entry
static Field findFieldByIdInTheList(int nIdField, java.util.List<Field> listField)
          return the field which key is specified in parameter
static Field findFieldByValueInTheList(java.lang.String strFieldValue, java.util.List<Field> listField)
          return the field which value is specified in parameter
static java.util.List<Field> getAuthorizedFieldsByRole(javax.servlet.http.HttpServletRequest request, java.util.List<Field> listField)
          Filter a list of field for a given user
static java.util.List<Field> getAuthorizedFieldsByWorkgroup(java.util.List<Field> listField, fr.paris.lutece.portal.business.user.AdminUser user)
          Filter a list of field for a given user
static java.sql.Timestamp getCurrentTimestamp()
          return current Timestamp
static void getDirectoryRecordData(javax.servlet.http.HttpServletRequest request, Record record, fr.paris.lutece.portal.service.plugin.Plugin plugin, java.util.Locale locale)
          Get the request data and if there is no error insert the data in the record specified in parameter. return null if there is no error or else return a DirectoryError object
static void getDirectoryRecordFieldData(Record record, javax.servlet.http.HttpServletRequest request, int nIdEntry, boolean bTestDirectoryError, java.util.List<RecordField> listRecordFieldResult, fr.paris.lutece.portal.service.plugin.Plugin plugin, java.util.Locale locale)
          perform in the record field list the record field associates with a entry specify in parameter. return null if there is no error in the response else return a DirectoryError Object
static File getFileData(java.lang.String strFileInputName, javax.servlet.http.HttpServletRequest request)
          Get the file contains in the request from the name of the input file
static java.util.List<IEntry> getFormEntries(int nIdDirectory, fr.paris.lutece.portal.service.plugin.Plugin plugin, fr.paris.lutece.portal.business.user.AdminUser user)
          return all entry associate to the directory
static java.util.List<IEntry> getFormEntriesByFilter(EntryFilter filter, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          return all entry associate to the directory
static int getIndexEntryInTheEntryList(int nIdEntry, java.util.List<IEntry> listEntry)
          return the index in the list of the entry whose key is specified in parameter
static int getIndexFieldInTheFieldList(int nIdField, java.util.List<Field> listField)
          return the index in the list of the field whose key is specified in parameter
static java.util.Map<java.lang.String,java.util.List<RecordField>> getMapIdEntryListRecordField(java.util.List<IEntry> lisEntry, int nIdRecord, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          get a Map which contains for each entry the list of recordField object associated
static java.util.HashMap<java.lang.String,java.util.List<RecordField>> getSearchRecordData(javax.servlet.http.HttpServletRequest request, int nIdDirectory, fr.paris.lutece.portal.service.plugin.Plugin plugin, java.util.Locale locale)
          Get the request data and return a Map which contains for each entry the list of recordField object associated
static java.util.Map<java.lang.String,java.util.List<RecordField>> getSpecificMapIdEntryListRecordField(java.util.List<IEntry> lisEntry, int nIdRecord, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          get a Map which contains for each entry the list of recordField object associated
static java.lang.Boolean isFieldInTheRecordFieldList(int nIdField, java.util.List<RecordField> listRecordField)
          return true if the field which key is specified in parameter is in the response list
static java.util.List<java.lang.Integer> retainAll(java.util.List<java.lang.Integer> list1, java.util.List<java.lang.Integer> list2)
          Removes from list all the elements that are not contained in the other list Faster than classic "List.retainAll" because each id is unique
static java.lang.String substituteSpecialCaractersForExport(java.lang.String strSource)
          replace special characters in the string passed as a parameter
static java.lang.String trim(java.lang.String strParameter)
          Returns a copy of the string , with leading and trailing whitespace omitted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONSTANT_WHERE

public static final java.lang.String CONSTANT_WHERE
See Also:
Constant Field Values

CONSTANT_AND

public static final java.lang.String CONSTANT_AND
See Also:
Constant Field Values

CONSTANT_ID_NULL

public static final int CONSTANT_ID_NULL
See Also:
Constant Field Values

CONSTANT_ID_ZERO

public static final int CONSTANT_ID_ZERO
See Also:
Constant Field Values

TEMPLATE_FORM_DIRECTORY_RECORD

public static final java.lang.String TEMPLATE_FORM_DIRECTORY_RECORD
See Also:
Constant Field Values

TEMPLATE_FORM_SEARCH_DIRECTORY_RECORD

public static final java.lang.String TEMPLATE_FORM_SEARCH_DIRECTORY_RECORD
See Also:
Constant Field Values

EMPTY_STRING

public static final java.lang.String EMPTY_STRING
See Also:
Constant Field Values
Method Detail

getCurrentTimestamp

public static java.sql.Timestamp getCurrentTimestamp()
return current Timestamp

Returns:
return current Timestamp

createEntryByType

public static IEntry createEntryByType(javax.servlet.http.HttpServletRequest request,
                                       fr.paris.lutece.portal.service.plugin.Plugin plugin)
return an instance of IEntry function of type entry

Parameters:
request - the request
plugin - the plugin
Returns:
an instance of IEntry function of type entry

createEntryByType

public static IEntry createEntryByType(int nIdType,
                                       fr.paris.lutece.portal.service.plugin.Plugin plugin)
return an instance of IEntry function of type entry

Parameters:
nIdType - the type id
plugin - the plugin
Returns:
an instance of IEntry function of type entry

getIndexEntryInTheEntryList

public static int getIndexEntryInTheEntryList(int nIdEntry,
                                              java.util.List<IEntry> listEntry)
return the index in the list of the entry whose key is specified in parameter

Parameters:
nIdEntry - the key of the entry
listEntry - the list of the entry
Returns:
the index in the list of the entry whose key is specified in parameter

getIndexFieldInTheFieldList

public static int getIndexFieldInTheFieldList(int nIdField,
                                              java.util.List<Field> listField)
return the index in the list of the field whose key is specified in parameter

Parameters:
nIdField - the key of the field
listField - the list of field
Returns:
the index in the list of the field whose key is specified in parameter

getFormEntries

public static java.util.List<IEntry> getFormEntries(int nIdDirectory,
                                                    fr.paris.lutece.portal.service.plugin.Plugin plugin,
                                                    fr.paris.lutece.portal.business.user.AdminUser user)
return all entry associate to the directory

Parameters:
nIdDirectory - the id of the directory
plugin - the plugin
user - the AdminUser
Returns:
list of entry

getFormEntriesByFilter

public static java.util.List<IEntry> getFormEntriesByFilter(EntryFilter filter,
                                                            fr.paris.lutece.portal.service.plugin.Plugin plugin)
return all entry associate to the directory

Parameters:
filter - entry filter
plugin - the plugin
user - the AdminUser
Returns:
list of entry

getMapIdEntryListRecordField

public static java.util.Map<java.lang.String,java.util.List<RecordField>> getMapIdEntryListRecordField(java.util.List<IEntry> lisEntry,
                                                                                                       int nIdRecord,
                                                                                                       fr.paris.lutece.portal.service.plugin.Plugin plugin)
get a Map which contains for each entry the list of recordField object associated

Parameters:
lisEntry - the list of entry associate to the record
nIdRecord - the id of the record
plugin - plugin
Returns:
a map

getSpecificMapIdEntryListRecordField

public static java.util.Map<java.lang.String,java.util.List<RecordField>> getSpecificMapIdEntryListRecordField(java.util.List<IEntry> lisEntry,
                                                                                                               int nIdRecord,
                                                                                                               fr.paris.lutece.portal.service.plugin.Plugin plugin)
get a Map which contains for each entry the list of recordField object associated

Parameters:
lisEntry - the list of entry associate to the record
nIdRecord - the id of the record
plugin - plugin
Returns:
a map

getDirectoryRecordData

public static void getDirectoryRecordData(javax.servlet.http.HttpServletRequest request,
                                          Record record,
                                          fr.paris.lutece.portal.service.plugin.Plugin plugin,
                                          java.util.Locale locale)
                                   throws DirectoryErrorException
Get the request data and if there is no error insert the data in the record specified in parameter. return null if there is no error or else return a DirectoryError object

Parameters:
request - the request
nIdDirectory - the id of the directory associate to the record
record - the record
plugin - the plugin
locale - the locale
Throws:
DirectoryErrorException

getSearchRecordData

public static java.util.HashMap<java.lang.String,java.util.List<RecordField>> getSearchRecordData(javax.servlet.http.HttpServletRequest request,
                                                                                                  int nIdDirectory,
                                                                                                  fr.paris.lutece.portal.service.plugin.Plugin plugin,
                                                                                                  java.util.Locale locale)
                                                                                           throws DirectoryErrorException
Get the request data and return a Map which contains for each entry the list of recordField object associated

Parameters:
request - the request
nIdDirectory - the id of the directory
plugin - the plugin
locale - the locale
Returns:
a map
Throws:
DirectoryErrorException

getDirectoryRecordFieldData

public static void getDirectoryRecordFieldData(Record record,
                                               javax.servlet.http.HttpServletRequest request,
                                               int nIdEntry,
                                               boolean bTestDirectoryError,
                                               java.util.List<RecordField> listRecordFieldResult,
                                               fr.paris.lutece.portal.service.plugin.Plugin plugin,
                                               java.util.Locale locale)
                                        throws DirectoryErrorException
perform in the record field list the record field associates with a entry specify in parameter. return null if there is no error in the response else return a DirectoryError Object

Parameters:
request - the request
nIdEntry - the key of the entry
bTestDirectoryError - true if we must test the validity of user input
listRecordFieldResult - the list of record field result
plugin - the plugin
locale - the locale
Throws:
DirectoryErrorException

findFieldByIdInTheList

public static Field findFieldByIdInTheList(int nIdField,
                                           java.util.List<Field> listField)
return the field which key is specified in parameter

Parameters:
nIdField - the id of the field who is search
listField - the list of field
Returns:
the field which key is specified in parameter

findFieldByValueInTheList

public static Field findFieldByValueInTheList(java.lang.String strFieldValue,
                                              java.util.List<Field> listField)
return the field which value is specified in parameter

Parameters:
strFieldValue - the value of the field who is search
listField - the list of field
Returns:
the field which key is specified in parameter

isFieldInTheRecordFieldList

public static java.lang.Boolean isFieldInTheRecordFieldList(int nIdField,
                                                            java.util.List<RecordField> listRecordField)
return true if the field which key is specified in parameter is in the response list

Parameters:
nIdField - the id of the field who is search
listRecordField - the list of object Response
Returns:
true if the field which key is specified in parameter is in the response list

addHeaderResponse

public static void addHeaderResponse(javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response,
                                     java.lang.String strFileName)
write the http header in the response

Parameters:
request - the httpServletRequest
response - the http response
strFileName - the name of the file who must insert in the response

convertStringToInt

public static int convertStringToInt(java.lang.String strParameter)
convert a string to int

Parameters:
strParameter - the string parameter to convert
Returns:
the conversion

trim

public static java.lang.String trim(java.lang.String strParameter)
Returns a copy of the string , with leading and trailing whitespace omitted.

Parameters:
strParameter - the string parameter to convert
Returns:
null if the strParameter is null other return with leading and trailing whitespace omitted.

getFileData

public static File getFileData(java.lang.String strFileInputName,
                               javax.servlet.http.HttpServletRequest request)
Get the file contains in the request from the name of the input file

Parameters:
strFileInputName - le name of the input file file
request - the request
Returns:
file the file contains in the request from the name of the input file

buildRequetteWithFilter

public static java.lang.String buildRequetteWithFilter(java.lang.String strSelect,
                                                       java.util.List<java.lang.String> listStrFilter,
                                                       java.lang.String strOrder)
Builds a query with filters placed in parameters

Parameters:
strSelect - the select of the query
listStrFilter - the list of filter to add in the query
strOrder - the order by of the query
Returns:
a query

substituteSpecialCaractersForExport

public static java.lang.String substituteSpecialCaractersForExport(java.lang.String strSource)
replace special characters in the string passed as a parameter

Parameters:
strSource - the string
Returns:
substitute special in the string passed as a parameter

getAuthorizedFieldsByWorkgroup

public static java.util.List<Field> getAuthorizedFieldsByWorkgroup(java.util.List<Field> listField,
                                                                   fr.paris.lutece.portal.business.user.AdminUser user)
Filter a list of field for a given user

Parameters:
listField - a list of field
user - an adminUser
Returns:
a field list

getAuthorizedFieldsByRole

public static java.util.List<Field> getAuthorizedFieldsByRole(javax.servlet.http.HttpServletRequest request,
                                                              java.util.List<Field> listField)
Filter a list of field for a given user

Parameters:
listField - a list of field
user - a luteceUser
Returns:
a field list

retainAll

public static java.util.List<java.lang.Integer> retainAll(java.util.List<java.lang.Integer> list1,
                                                          java.util.List<java.lang.Integer> list2)
Removes from list all the elements that are not contained in the other list Faster than classic "List.retainAll" because each id is unique

Parameters:
list1 - input list 1
list2 - input list 2
Returns:
the result list


Copyright © 2010 Mairie de Paris. All Rights Reserved.