From 439e4c41b28775dafa540b8878b30152b0af3de7 Mon Sep 17 00:00:00 2001 From: Martinez Date: Mon, 8 Aug 2016 17:56:48 +0200 Subject: [PATCH 1/3] DIRECTORY-274: Add SynchronousUpload with AsynchronousUpload-plugin --- .../business/AbstractEntryTypeUpload.java | 303 +- .../DirectoryAsynchronousUploadHandler.java | 194 +- .../directory/utils/DirectoryUtils.java | 16 + .../plugins/directory/web/DirectoryApp.java | 28 +- .../directory/web/DirectoryJspBean.java | 5874 ++++++++--------- .../directory/create_directory_record.html | 3 +- .../html_code_form_entry_type_file.html | 71 +- .../html_code_form_entry_type_img.html | 76 +- .../directory/modify_directory_record.html | 7 +- .../directory/view_directory_record.html | 328 +- ...CreateDirectoryRecordWithInitialValues.jsp | 6 + .../directory/ModifyDirectoryRecord.jsp | 6 +- 12 files changed, 3356 insertions(+), 3556 deletions(-) create mode 100644 webapp/jsp/admin/plugins/directory/CreateDirectoryRecordWithInitialValues.jsp diff --git a/src/java/fr/paris/lutece/plugins/directory/business/AbstractEntryTypeUpload.java b/src/java/fr/paris/lutece/plugins/directory/business/AbstractEntryTypeUpload.java index ce65432..4d098ef 100644 --- a/src/java/fr/paris/lutece/plugins/directory/business/AbstractEntryTypeUpload.java +++ b/src/java/fr/paris/lutece/plugins/directory/business/AbstractEntryTypeUpload.java @@ -33,6 +33,7 @@ */ package fr.paris.lutece.plugins.directory.business; +import static fr.paris.lutece.plugins.directory.business.Entry.MARK_ENTRY; import fr.paris.lutece.plugins.directory.service.upload.DirectoryAsynchronousUploadHandler; import fr.paris.lutece.plugins.directory.utils.DirectoryErrorException; import fr.paris.lutece.plugins.directory.utils.DirectoryUtils; @@ -42,27 +43,31 @@ import fr.paris.lutece.portal.service.message.AdminMessage; import fr.paris.lutece.portal.service.message.AdminMessageService; import fr.paris.lutece.portal.service.regularexpression.RegularExpressionService; +import fr.paris.lutece.portal.service.template.AppTemplateService; import fr.paris.lutece.portal.service.util.AppPropertiesService; +import fr.paris.lutece.portal.web.upload.IAsynchronousUploadHandler; import fr.paris.lutece.util.filesystem.FileSystemUtil; +import fr.paris.lutece.util.html.HtmlTemplate; import org.apache.commons.fileupload.FileItem; import org.apache.commons.lang.StringUtils; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Locale; +import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; - /** * * AbstractEntryTypeUpload * */ -public abstract class AbstractEntryTypeUpload extends Entry -{ +public abstract class AbstractEntryTypeUpload extends Entry { + // PARAMETERS protected static final String PARAMETER_MAX_FILES = "max_files"; protected static final String PARAMETER_FILE_MAX_SIZE = "file_max_size"; @@ -81,151 +86,168 @@ public abstract class AbstractEntryTypeUpload extends Entry // FIELDS private static final String FIELD_MAX_FILES = "directory.create_entry.label_max_files"; private static final String FIELD_FILE_MAX_SIZE = "directory.create_entry.label_file_max_size"; + private static final String MARK_LIST_FILE = "list_fileuploaded"; + + public IAsynchronousUploadHandler getAsynchronousUploadHandler() { + return DirectoryAsynchronousUploadHandler.getHandler(); + } + + public String getHtmlFormEntry(Locale locale, List defaultValues, boolean isDisplayFront) { + if (getTemplateHtmlFormEntry(isDisplayFront) != null) { + List listFile = new ArrayList(); + if (defaultValues != null && !defaultValues.isEmpty()) { + for (RecordField r : defaultValues) { + if (r.getFile() != null) { + if (r.getFile().getMimeType() != null && !listFile.contains(r.getFile())) { + listFile.add(r.getFile()); + } + } + } + } + Map model = new HashMap(); + model.put(MARK_ENTRY, this); + model.put(MARK_LOCALE, locale); + model.put(MARK_DEFAULT_VALUES, defaultValues); + if (!listFile.isEmpty()) { + model.put(MARK_LIST_FILE, listFile); + } + + HtmlTemplate template = AppTemplateService.getTemplate(getTemplateHtmlFormEntry(isDisplayFront), locale, + model); + + return template.getHtml(); + } + + return null; + } /** * Set the fields + * * @param request the HTTP request * @param listFields the list of fields to set */ - protected abstract void setFields( HttpServletRequest request, List listFields ); + protected abstract void setFields(HttpServletRequest request, List listFields); /** * Check the record field data for a single file item + * * @param fileItem the file item * @param locale the locale * @throws DirectoryErrorException exception if there is an error */ - protected abstract void checkRecordFieldData( FileItem fileItem, Locale locale ) - throws DirectoryErrorException; + protected abstract void checkRecordFieldData(FileItem fileItem, Locale locale) + throws DirectoryErrorException; /** * {@inheritDoc} */ @Override - public void canUploadFiles( List listUploadedFileItems, List listFileItemsToUpload, - Locale locale ) throws DirectoryErrorException - { - /** 1) Check max files */ - Field fieldMaxFiles = DirectoryUtils.findFieldByTitleInTheList( CONSTANT_MAX_FILES, getFields( ) ); + public void canUploadFiles(List listUploadedFileItems, List listFileItemsToUpload, + Locale locale) throws DirectoryErrorException { + /** + * 1) Check max files + */ + Field fieldMaxFiles = DirectoryUtils.findFieldByTitleInTheList(CONSTANT_MAX_FILES, getFields()); // By default, max file is set at 1 int nMaxFiles = 1; - if ( ( fieldMaxFiles != null ) && StringUtils.isNotBlank( fieldMaxFiles.getValue( ) ) && - StringUtils.isNumeric( fieldMaxFiles.getValue( ) ) ) - { - nMaxFiles = DirectoryUtils.convertStringToInt( fieldMaxFiles.getValue( ) ); + if ((fieldMaxFiles != null) && StringUtils.isNotBlank(fieldMaxFiles.getValue()) + && StringUtils.isNumeric(fieldMaxFiles.getValue())) { + nMaxFiles = DirectoryUtils.convertStringToInt(fieldMaxFiles.getValue()); } - if ( ( listUploadedFileItems != null ) && ( listFileItemsToUpload != null ) ) - { - int nNbFiles = listUploadedFileItems.size( ) + listFileItemsToUpload.size( ); + if ((listUploadedFileItems != null) && (listFileItemsToUpload != null)) { + int nNbFiles = listUploadedFileItems.size() + listFileItemsToUpload.size(); - if ( nNbFiles > nMaxFiles ) - { - Object[] params = { nMaxFiles }; - String strMessage = I18nService.getLocalizedString( PROPERTY_MESSAGE_ERROR_UPLOADING_FILE_MAX_FILES, - params, locale ); - throw new DirectoryErrorException( this.getTitle( ), strMessage ); + if (nNbFiles > nMaxFiles) { + Object[] params = {nMaxFiles}; + String strMessage = I18nService.getLocalizedString(PROPERTY_MESSAGE_ERROR_UPLOADING_FILE_MAX_FILES, + params, locale); + throw new DirectoryErrorException(this.getTitle(), strMessage); } } - /** 2) Check files size */ - Field fieldFileMaxSize = DirectoryUtils.findFieldByTitleInTheList( CONSTANT_FILE_MAX_SIZE, getFields( ) ); + /** + * 2) Check files size + */ + Field fieldFileMaxSize = DirectoryUtils.findFieldByTitleInTheList(CONSTANT_FILE_MAX_SIZE, getFields()); int nMaxSize = DirectoryUtils.CONSTANT_ID_NULL; - if ( ( fieldFileMaxSize != null ) && StringUtils.isNotBlank( fieldFileMaxSize.getValue( ) ) && - StringUtils.isNumeric( fieldFileMaxSize.getValue( ) ) ) - { - nMaxSize = DirectoryUtils.convertStringToInt( fieldFileMaxSize.getValue( ) ); - } - else - { + if ((fieldFileMaxSize != null) && StringUtils.isNotBlank(fieldFileMaxSize.getValue()) + && StringUtils.isNumeric(fieldFileMaxSize.getValue())) { + nMaxSize = DirectoryUtils.convertStringToInt(fieldFileMaxSize.getValue()); + } else { // For version 2.0.13 and below, the max size was stored in the width of the field "option" for EntryTypeDownloadUrl - Field fieldOption = DirectoryUtils.findFieldByTitleInTheList( EntryTypeDownloadUrl.CONSTANT_OPTION, - getFields( ) ); + Field fieldOption = DirectoryUtils.findFieldByTitleInTheList(EntryTypeDownloadUrl.CONSTANT_OPTION, + getFields()); - if ( fieldOption != null ) - { - nMaxSize = fieldOption.getWidth( ); + if (fieldOption != null) { + nMaxSize = fieldOption.getWidth(); } } // If no max size defined in the db, then fetch if from the directory.properties file - if ( nMaxSize == DirectoryUtils.CONSTANT_ID_NULL ) - { - nMaxSize = AppPropertiesService.getPropertyInt( PROPERTY_UPLOAD_FILE_DEFAULT_MAX_SIZE, 5242880 ); + if (nMaxSize == DirectoryUtils.CONSTANT_ID_NULL) { + nMaxSize = AppPropertiesService.getPropertyInt(PROPERTY_UPLOAD_FILE_DEFAULT_MAX_SIZE, 5242880); } // If nMaxSize == -1, then no size limit - if ( ( nMaxSize != DirectoryUtils.CONSTANT_ID_NULL ) && ( listFileItemsToUpload != null ) && - !listFileItemsToUpload.isEmpty( ) ) - { - for ( FileItem fileItem : listFileItemsToUpload ) - { - if ( fileItem.getSize( ) > nMaxSize ) - { - Object[] params = { nMaxSize }; - String strMessage = I18nService.getLocalizedString( PROPERTY_MESSAGE_ERROR_UPLOADING_FILE_FILE_MAX_SIZE, - params, locale ); - throw new DirectoryErrorException( this.getTitle( ), strMessage ); + if ((nMaxSize != DirectoryUtils.CONSTANT_ID_NULL) && (listFileItemsToUpload != null) + && !listFileItemsToUpload.isEmpty()) { + for (FileItem fileItem : listFileItemsToUpload) { + if (fileItem.getSize() > nMaxSize) { + Object[] params = {nMaxSize}; + String strMessage = I18nService.getLocalizedString(PROPERTY_MESSAGE_ERROR_UPLOADING_FILE_FILE_MAX_SIZE, + params, locale); + throw new DirectoryErrorException(this.getTitle(), strMessage); } } } } // CHECKS - /** * Check the entry data + * * @param request the HTTP request * @param locale the locale * @return the error message url if there is an error, an empty string - * otherwise + * otherwise */ - protected String checkEntryData( HttpServletRequest request, Locale locale ) - { - String strTitle = request.getParameter( PARAMETER_TITLE ); - String strMaxFiles = request.getParameter( PARAMETER_MAX_FILES ); - String strFileMaxSize = request.getParameter( PARAMETER_FILE_MAX_SIZE ); + protected String checkEntryData(HttpServletRequest request, Locale locale) { + String strTitle = request.getParameter(PARAMETER_TITLE); + String strMaxFiles = request.getParameter(PARAMETER_MAX_FILES); + String strFileMaxSize = request.getParameter(PARAMETER_FILE_MAX_SIZE); String strFieldError = DirectoryUtils.EMPTY_STRING; - if ( StringUtils.isBlank( strTitle ) ) - { + if (StringUtils.isBlank(strTitle)) { strFieldError = FIELD_TITLE; - } - else if ( StringUtils.isBlank( strMaxFiles ) ) - { + } else if (StringUtils.isBlank(strMaxFiles)) { strFieldError = FIELD_MAX_FILES; - } - else if ( StringUtils.isBlank( strFileMaxSize ) ) - { + } else if (StringUtils.isBlank(strFileMaxSize)) { strFieldError = FIELD_FILE_MAX_SIZE; } - if ( !strFieldError.equals( DirectoryUtils.EMPTY_STRING ) ) - { - Object[] tabRequiredFields = { I18nService.getLocalizedString( strFieldError, locale ) }; + if (!strFieldError.equals(DirectoryUtils.EMPTY_STRING)) { + Object[] tabRequiredFields = {I18nService.getLocalizedString(strFieldError, locale)}; - return AdminMessageService.getMessageUrl( request, MESSAGE_MANDATORY_FIELD, tabRequiredFields, - AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_MANDATORY_FIELD, tabRequiredFields, + AdminMessage.TYPE_STOP); } - if ( !StringUtils.isNumeric( strMaxFiles ) ) - { + if (!StringUtils.isNumeric(strMaxFiles)) { strFieldError = FIELD_MAX_FILES; - } - else if ( !StringUtils.isNumeric( strFileMaxSize ) ) - { + } else if (!StringUtils.isNumeric(strFileMaxSize)) { strFieldError = FIELD_FILE_MAX_SIZE; } - if ( !strFieldError.equals( DirectoryUtils.EMPTY_STRING ) ) - { - Object[] tabRequiredFields = { I18nService.getLocalizedString( strFieldError, locale ) }; + if (!strFieldError.equals(DirectoryUtils.EMPTY_STRING)) { + Object[] tabRequiredFields = {I18nService.getLocalizedString(strFieldError, locale)}; - return AdminMessageService.getMessageUrl( request, MESSAGE_NUMERIC_FIELD, tabRequiredFields, - AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_NUMERIC_FIELD, tabRequiredFields, + AdminMessage.TYPE_STOP); } return StringUtils.EMPTY; @@ -233,129 +255,118 @@ else if ( !StringUtils.isNumeric( strFileMaxSize ) ) /** * Check the record field data + * * @param listFilesSource the file source to upload * @param locale the locale * @throws DirectoryErrorException exception if there is an error */ - protected void checkRecordFieldData( List listFilesSource, Locale locale ) - throws DirectoryErrorException - { - for ( FileItem fileSource : listFilesSource ) - { + protected void checkRecordFieldData(List listFilesSource, Locale locale) + throws DirectoryErrorException { + for (FileItem fileSource : listFilesSource) { // Check mandatory attribute - String strFilename = ( fileSource != null ) ? FileUploadService.getFileNameOnly( fileSource ) - : StringUtils.EMPTY; + String strFilename = (fileSource != null) ? FileUploadService.getFileNameOnly(fileSource) + : StringUtils.EMPTY; - if ( isMandatory( ) && StringUtils.isBlank( strFilename ) ) - { - throw new DirectoryErrorException( getTitle( ) ); + if (isMandatory() && StringUtils.isBlank(strFilename)) { + throw new DirectoryErrorException(getTitle()); } - String strMimeType = FileSystemUtil.getMIMEType( strFilename ); + String strMimeType = FileSystemUtil.getMIMEType(strFilename); // Check mime type with regular expressions - List listRegularExpression = this.getFields( ).get( 0 ).getRegularExpressionList( ); - - if ( StringUtils.isNotBlank( strFilename ) && ( listRegularExpression != null ) && - !listRegularExpression.isEmpty( ) && RegularExpressionService.getInstance( ).isAvailable( ) ) - { - for ( RegularExpression regularExpression : listRegularExpression ) - { - if ( !RegularExpressionService.getInstance( ).isMatches( strMimeType, regularExpression ) ) - { - throw new DirectoryErrorException( getTitle( ), regularExpression.getErrorMessage( ) ); + List listRegularExpression = this.getFields().get(0).getRegularExpressionList(); + + if (StringUtils.isNotBlank(strFilename) && (listRegularExpression != null) + && !listRegularExpression.isEmpty() && RegularExpressionService.getInstance().isAvailable()) { + for (RegularExpression regularExpression : listRegularExpression) { + if (!RegularExpressionService.getInstance().isMatches(strMimeType, regularExpression)) { + throw new DirectoryErrorException(getTitle(), regularExpression.getErrorMessage()); } } } // Specific Check from each entry types - checkRecordFieldData( fileSource, locale ); + checkRecordFieldData(fileSource, locale); } } // FINDERS - /** * Get the file source from the session + * * @param request the HttpServletRequest * @return the file item */ - protected List getFileSources( HttpServletRequest request ) - { - HttpSession session = request.getSession( false ); + protected List getFileSources(HttpServletRequest request) { + HttpSession session = request.getSession(false); - if ( session != null ) - { + if (session != null) { // check the file in session - it might no be deleted - return DirectoryAsynchronousUploadHandler.getHandler( ) - .getFileItems( Integer.toString( getIdEntry( ) ), - session.getId( ) ); + return DirectoryAsynchronousUploadHandler.getHandler() + .getFileItems(Integer.toString(getIdEntry()), + session.getId()); } return null; } // SET - /** * Set the list of fields + * * @param request the HTTP request */ - protected void setFields( HttpServletRequest request ) - { - List listFields = new ArrayList( ); - listFields.add( buildFieldMaxFiles( request ) ); - listFields.add( buildFieldFileMaxSize( request ) ); + protected void setFields(HttpServletRequest request) { + List listFields = new ArrayList(); + listFields.add(buildFieldMaxFiles(request)); + listFields.add(buildFieldFileMaxSize(request)); - setFields( request, listFields ); + setFields(request, listFields); - this.setFields( listFields ); + this.setFields(listFields); } // PRIVATE METHODS - /** * Build the field for max files + * * @param request the HTTP request * @return the field */ - private Field buildFieldMaxFiles( HttpServletRequest request ) - { - String strMaxFiles = request.getParameter( PARAMETER_MAX_FILES ); - int nMaxFiles = DirectoryUtils.convertStringToInt( strMaxFiles ); - Field fieldMaxFiles = DirectoryUtils.findFieldByTitleInTheList( CONSTANT_MAX_FILES, getFields( ) ); - - if ( fieldMaxFiles == null ) - { - fieldMaxFiles = new Field( ); + private Field buildFieldMaxFiles(HttpServletRequest request) { + String strMaxFiles = request.getParameter(PARAMETER_MAX_FILES); + int nMaxFiles = DirectoryUtils.convertStringToInt(strMaxFiles); + Field fieldMaxFiles = DirectoryUtils.findFieldByTitleInTheList(CONSTANT_MAX_FILES, getFields()); + + if (fieldMaxFiles == null) { + fieldMaxFiles = new Field(); } - fieldMaxFiles.setEntry( this ); - fieldMaxFiles.setTitle( CONSTANT_MAX_FILES ); - fieldMaxFiles.setValue( Integer.toString( nMaxFiles ) ); + fieldMaxFiles.setEntry(this); + fieldMaxFiles.setTitle(CONSTANT_MAX_FILES); + fieldMaxFiles.setValue(Integer.toString(nMaxFiles)); return fieldMaxFiles; } /** * Build the field for file max size + * * @param request the HTTP request * @return the field */ - private Field buildFieldFileMaxSize( HttpServletRequest request ) - { - String strFileMaxSize = request.getParameter( PARAMETER_FILE_MAX_SIZE ); - int nFileMaxSize = DirectoryUtils.convertStringToInt( strFileMaxSize ); - Field fieldMaxFiles = DirectoryUtils.findFieldByTitleInTheList( CONSTANT_FILE_MAX_SIZE, getFields( ) ); - - if ( fieldMaxFiles == null ) - { - fieldMaxFiles = new Field( ); + private Field buildFieldFileMaxSize(HttpServletRequest request) { + String strFileMaxSize = request.getParameter(PARAMETER_FILE_MAX_SIZE); + int nFileMaxSize = DirectoryUtils.convertStringToInt(strFileMaxSize); + Field fieldMaxFiles = DirectoryUtils.findFieldByTitleInTheList(CONSTANT_FILE_MAX_SIZE, getFields()); + + if (fieldMaxFiles == null) { + fieldMaxFiles = new Field(); } - fieldMaxFiles.setEntry( this ); - fieldMaxFiles.setTitle( CONSTANT_FILE_MAX_SIZE ); - fieldMaxFiles.setValue( Integer.toString( nFileMaxSize ) ); + fieldMaxFiles.setEntry(this); + fieldMaxFiles.setTitle(CONSTANT_FILE_MAX_SIZE); + fieldMaxFiles.setValue(Integer.toString(nFileMaxSize)); return fieldMaxFiles; } diff --git a/src/java/fr/paris/lutece/plugins/directory/service/upload/DirectoryAsynchronousUploadHandler.java b/src/java/fr/paris/lutece/plugins/directory/service/upload/DirectoryAsynchronousUploadHandler.java index 1181cb9..3684312 100644 --- a/src/java/fr/paris/lutece/plugins/directory/service/upload/DirectoryAsynchronousUploadHandler.java +++ b/src/java/fr/paris/lutece/plugins/directory/service/upload/DirectoryAsynchronousUploadHandler.java @@ -33,8 +33,10 @@ */ package fr.paris.lutece.plugins.directory.service.upload; +import fr.paris.lutece.plugins.asynchronousupload.service.AbstractAsynchronousUploadHandler; import fr.paris.lutece.plugins.blobstore.service.BlobStoreClientException; import fr.paris.lutece.plugins.blobstore.service.IBlobStoreClientService; +import fr.paris.lutece.plugins.directory.business.Entry; import fr.paris.lutece.plugins.directory.business.EntryHome; import fr.paris.lutece.plugins.directory.business.EntryTypeDownloadUrl; import fr.paris.lutece.plugins.directory.business.File; @@ -48,6 +50,7 @@ import fr.paris.lutece.plugins.directory.service.DirectoryPlugin; import fr.paris.lutece.plugins.directory.utils.DirectoryErrorException; import fr.paris.lutece.plugins.directory.utils.DirectoryUtils; +import static fr.paris.lutece.plugins.directory.utils.DirectoryUtils.getPlugin; import fr.paris.lutece.plugins.directory.utils.JSONUtils; import fr.paris.lutece.plugins.directory.utils.UrlUtils; import fr.paris.lutece.portal.service.fileupload.FileUploadService; @@ -81,6 +84,8 @@ import java.util.Locale; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -95,7 +100,7 @@ * The uploaded files are deleted by SubForm when filling fields. * */ -public class DirectoryAsynchronousUploadHandler implements IAsynchronousUploadHandler +public class DirectoryAsynchronousUploadHandler extends AbstractAsynchronousUploadHandler { /** contains uploaded file items */ /** @@ -104,22 +109,27 @@ public class DirectoryAsynchronousUploadHandler implements IAsynchronousUploadHa public static Map>> _mapAsynchronousUpload = new ConcurrentHashMap>>( ); private static final String BEAN_DIRECTORY_ASYNCHRONOUS_UPLOAD_HANDLER = "directory.asynchronousUploadHandler"; private static final String PREFIX_ENTRY_ID = "directory_"; - + + private static final String HANDLER_NAME = "DirectoryAsynchronousUploadHandler"; + // UPLOAD - private static final String UPLOAD_SUBMIT_PREFIX = "_directory_upload_submit_directory_"; - private static final String UPLOAD_DELETE_PREFIX = "_directory_upload_delete_directory_"; - private static final String UPLOAD_CHECKBOX_PREFIX = "_directory_upload_checkbox_directory_"; + private static final String UPLOAD_SUBMIT_PREFIX = "_upload_submit_directory_"; + private static final String UPLOAD_DELETE_PREFIX = "_upload_delete_directory_"; + private static final String UPLOAD_CHECKBOX_PREFIX = "_upload_checkbox_directory_"; // PARAMETERS private static final String PARAMETER_BLOB_KEY = "blob_key"; private static final String PARAMETER_BLOBSTORE = "blobstore"; private static final String PARAMETER_PLUGIN_NAME = "plugin_name"; - private static final String PARAMETER_FIELD_NAME = "field_name"; + private static final String PARAMETER_FIELD_NAME = "fieldname"; private static final String PARAMETER_JSESSION_ID = "jsessionid"; // PROPERTIES private static final String PROPERTY_MESSAGE_ERROR_UPLOADING_FILE_SESSION_LOST = "directory.message.error.uploading_file.session_lost"; private IBlobStoreClientService _blobStoreClientService; + + //Error messages + private static final String ERROR_MESSAGE_UNKNOWN_ERROR = "directory.message.unknownError"; /** * Private constructor @@ -152,7 +162,8 @@ public void setBlobStoreClientService( IBlobStoreClientService blobStoreClientSe @Override public boolean isInvoked( HttpServletRequest request ) { - return DirectoryPlugin.PLUGIN_NAME.equals( request.getParameter( PARAMETER_PLUGIN_NAME ) ); + return true; + //return DirectoryPlugin.PLUGIN_NAME.equals( request.getParameter( PARAMETER_PLUGIN_NAME ) ); } /** @@ -164,58 +175,7 @@ public boolean isBlobStoreClientServiceAvailable( ) return _blobStoreClientService != null; } - /** - * {@inheritDoc} - * @category CALLED_BY_JS (directoryupload.js) - */ - @Override - public void process( HttpServletRequest request, HttpServletResponse response, JSONObject mainObject, - List listFileItemsToUpload ) - { - // prevent 0 or multiple uploads for the same field - if ( ( listFileItemsToUpload == null ) || listFileItemsToUpload.isEmpty( ) ) - { - throw new AppException( "No file uploaded" ); - } - - String strIdSession = request.getParameter( PARAMETER_JSESSION_ID ); - - if ( StringUtils.isNotBlank( strIdSession ) ) - { - String strFieldName = request.getParameter( PARAMETER_FIELD_NAME ); - - if ( StringUtils.isBlank( strFieldName ) ) - { - throw new AppException( "id entry is not provided for the current file upload" ); - } - - initMap( strIdSession, strFieldName ); - - // find session-related files in the map - Map> mapFileItemsSession = _mapAsynchronousUpload.get( strIdSession ); - - List fileItemsSession = mapFileItemsSession.get( strFieldName ); - - if ( canUploadFiles( strFieldName, fileItemsSession, listFileItemsToUpload, mainObject, - request.getLocale( ) ) ) - { - fileItemsSession.addAll( listFileItemsToUpload ); - - JSONObject jsonListFileItems = JSONUtils.getUploadedFileJSON( fileItemsSession ); - mainObject.accumulateAll( jsonListFileItems ); - // add entry id to json - JSONUtils.buildJsonSuccess( strFieldName, mainObject ); - } - } - else - { - AppLogService.error( DirectoryAsynchronousUploadHandler.class.getName( ) + " : Session does not exists" ); - - String strMessage = I18nService.getLocalizedString( PROPERTY_MESSAGE_ERROR_UPLOADING_FILE_SESSION_LOST, - request.getLocale( ) ); - JSONUtils.buildJsonError( mainObject, strMessage ); - } - } + /** * Do upload a file in the blobstore webapp @@ -484,7 +444,7 @@ public String getUploadAction( HttpServletRequest request ) { String paramName = enumParamNames.nextElement( ); - if ( paramName.startsWith( UPLOAD_SUBMIT_PREFIX ) || paramName.startsWith( UPLOAD_DELETE_PREFIX ) ) + if ( paramName.startsWith( DirectoryAsynchronousUploadHandler.getHandler().getHandlerName()+UPLOAD_SUBMIT_PREFIX ) || paramName.startsWith( DirectoryAsynchronousUploadHandler.getHandler().getHandlerName()+UPLOAD_DELETE_PREFIX ) ) { return paramName; } @@ -789,6 +749,118 @@ private void canUploadFiles( String strFieldName, List listUploadedFil } } + @Override + public String canUploadFiles(HttpServletRequest request, String strFieldName, List listFileItemsToUpload, Locale locale) { + if( StringUtils.isNotBlank( strFieldName )&&( strFieldName.length( ) > PREFIX_ENTRY_ID.length( ) ) ) + { + String strIdEntry = strFieldName.substring( PREFIX_ENTRY_ID.length( ) ); + int nIdEntry = DirectoryUtils.convertStringToInt( strIdEntry ); + IEntry entry = EntryHome.findByPrimaryKey( nIdEntry, DirectoryUtils.getPlugin( ) ); + + List listUploadedFileItems = getListUploadedFiles( strFieldName, request.getSession( ) ); + + if ( entry != null ) + { + try + { + entry.canUploadFiles( listUploadedFileItems, listFileItemsToUpload, locale ); + } + catch ( DirectoryErrorException ex ) + { + Logger.getLogger(DirectoryAsynchronousUploadHandler.class.getName()).log(Level.SEVERE, null, ex); + } + return null; + } + } + return I18nService.getLocalizedString( ERROR_MESSAGE_UNKNOWN_ERROR, locale ); + } + + @Override + public List getListUploadedFiles(String strFieldName, HttpSession session) { + if ( StringUtils.isBlank( strFieldName ) ) + { + throw new AppException( "id field name is not provided for the current file upload" ); + } + + initMap( session.getId( ), strFieldName ); + + // find session-related files in the map + Map> mapFileItemsSession = _mapAsynchronousUpload.get( session.getId( ) ); + + return mapFileItemsSession.get( strFieldName ); + } + + @Override + public void removeFileItem(String strFieldName, HttpSession session, int nIndex) { + // Remove the file (this will also delete the file physically) + List uploadedFiles = getListUploadedFiles( strFieldName, session ); + + if ( ( uploadedFiles != null ) && !uploadedFiles.isEmpty( ) && ( uploadedFiles.size( ) > nIndex ) ) + { + // Remove the object from the Hashmap + FileItem fileItem = uploadedFiles.remove( nIndex ); + fileItem.delete( ); + } + } + + @Override + public void addFileItemToUploadedFilesList(FileItem fileItem, String strFieldName, HttpServletRequest request) { + // This is the name that will be displayed in the form. We keep + // the original name, but clean it to make it cross-platform. + String strFileName = UploadUtil.cleanFileName( fileItem.getName( ).trim( ) ); + + initMap( request.getSession( ).getId( ), buildFieldName( strFieldName ) ); + + // Check if this file has not already been uploaded + List uploadedFiles = getListUploadedFiles( strFieldName, request.getSession( ) ); + + if ( uploadedFiles != null ) + { + boolean bNew = true; + + if ( !uploadedFiles.isEmpty( ) ) + { + Iterator iterUploadedFiles = uploadedFiles.iterator( ); + + while ( bNew && iterUploadedFiles.hasNext( ) ) + { + FileItem uploadedFile = iterUploadedFiles.next( ); + String strUploadedFileName = UploadUtil.cleanFileName( uploadedFile.getName( ).trim( ) ); + // If we find a file with the same name and the same + // length, we consider that the current file has + // already been uploaded + bNew = !( StringUtils.equals( strUploadedFileName, strFileName ) && + ( uploadedFile.getSize( ) == fileItem.getSize( ) ) ); + } + } + + if ( bNew ) + { + uploadedFiles.add( fileItem ); + } + } + } + + @Override + public String getHandlerName() { + return HANDLER_NAME; + } + + /** + * Get the id of the entry associated with a given field name + * @param strFieldName The name of the field + * @return The id of the entry + */ + protected String getEntryIdFromFieldName( String strFieldName ) + { + if ( StringUtils.isEmpty( strFieldName ) || ( strFieldName.length( ) < PREFIX_ENTRY_ID.length( ) ) ) + { + return null; + } + + return strFieldName.substring( PREFIX_ENTRY_ID.length( ) ); + } + /** * * DirectoryFileItem : builds fileItem from json response. @@ -946,4 +1018,4 @@ public void write( java.io.File file ) throws Exception // nothing } } -} +} \ No newline at end of file diff --git a/src/java/fr/paris/lutece/plugins/directory/utils/DirectoryUtils.java b/src/java/fr/paris/lutece/plugins/directory/utils/DirectoryUtils.java index 18a28c4..24bc0e7 100644 --- a/src/java/fr/paris/lutece/plugins/directory/utils/DirectoryUtils.java +++ b/src/java/fr/paris/lutece/plugins/directory/utils/DirectoryUtils.java @@ -148,6 +148,8 @@ public final class DirectoryUtils // JSP public static final String JSP_MANAGE_DIRECTORY_RECORD = "jsp/admin/plugins/directory/ManageDirectoryRecord.jsp"; + private static final String JSP_CREATE_DIRECTORY_RECORD = "jsp/admin/plugins/directory/CreateDirectoryRecord.jsp"; + private static final String JSP_MODIFY_DIRECTORY_RECORD = "jsp/admin/plugins/directory/ModifyDirectoryRecord.jsp"; // SESSION public static final String SESSION_DIRECTORY_LIST_SUBMITTED_RECORD_FIELDS = "directory_list_submitted_record_fields"; @@ -163,6 +165,7 @@ public final class DirectoryUtils private static final String CONSTANTE_CHARACTER_RETURN = "\r"; private static final String REGEX_ID = "^[\\d]+$"; + /** * DirectoryUtils * @@ -1323,6 +1326,19 @@ public static String getJspManageDirectoryRecord( HttpServletRequest request, in return urlItem.getUrl( ); } + + /** + * return url of the jsp create directory record + * @param request the HTTP request + * @param nIdDirectory the directory id + * @return url of jsp create directory record + */ + public static String getJspModifyDirectoryRecord(HttpServletRequest request, int nIdDirectory, int nIdDirectoryRecord) { + UrlItem urlItem = new UrlItem( AppPathService.getBaseUrl( request ) + JSP_MODIFY_DIRECTORY_RECORD ); + urlItem.addParameter( PARAMETER_ID_DIRECTORY, nIdDirectory ); + urlItem.addParameter( PARAMETER_ID_DIRECTORY_RECORD, nIdDirectoryRecord); + return urlItem.getUrl(); + } /** * Convert a map of ( String, String ) into a {@link ReferenceList} diff --git a/src/java/fr/paris/lutece/plugins/directory/web/DirectoryApp.java b/src/java/fr/paris/lutece/plugins/directory/web/DirectoryApp.java index 499edfb..9c4bd50 100644 --- a/src/java/fr/paris/lutece/plugins/directory/web/DirectoryApp.java +++ b/src/java/fr/paris/lutece/plugins/directory/web/DirectoryApp.java @@ -155,6 +155,8 @@ public class DirectoryApp implements XPageApplication private static final String MARK_DIRECTORY = "directory"; private static final String MARK_STR_FORM_SEARCH = "str_form_search"; private static final String MARK_STR_RESULT_LIST = "str_result_list"; + private static final String MARK_RESULT_RECORD_FIELD_LIST = "result_record_field_list"; + private static final String MARK_WEBAPP_URL = "webapp_url"; private static final String MARK_STR_RESULT_RECORD = "str_result_record"; private static final String MARK_LOCALE = "locale"; private static final String MARK_PAGINATOR = "paginator"; @@ -342,6 +344,16 @@ else if ( listIdDirectory == null ) String strDirectoryRecord = getHtmlResultRecord( directory, record, request.getLocale( ), plugin, session ); + + List lIdRecordList = new ArrayList(); + + lIdRecordList.add(record.getIdRecord()); + + if( lIdRecordList.size() > 0 ) + { + List lRecordField = RecordFieldHome.getRecordFieldListByRecordIdList(lIdRecordList, plugin); + model.put( MARK_RESULT_RECORD_FIELD_LIST, lRecordField ); + } model.put( MARK_STR_RESULT_RECORD, strDirectoryRecord ); } else @@ -494,11 +506,24 @@ else if ( listIdDirectory == null ) model.put( MARK_PAGINATOR, paginator ); List lRecord = recordService.loadListByListId( paginator.getPageItems( ), plugin ); - + if ( lRecord.size( ) > 0 ) { String strResultList = getHtmlResultList( directory, lRecord, request.getLocale( ), plugin ); + + List lIdRecordList = new ArrayList(); + for( Record elementlRecord : lRecord ) + { + lIdRecordList.add(elementlRecord.getIdRecord()); + } + if( lIdRecordList.size() > 0 ) + { + List lRecordField = RecordFieldHome.getRecordFieldListByRecordIdList(lIdRecordList, plugin); + model.put( MARK_RESULT_RECORD_FIELD_LIST, lRecordField ); + } + //getRecordFieldListByRecordIdList( List lIdRecordList, Plugin plugin ) + model.put( MARK_STR_RESULT_LIST, strResultList ); } } @@ -538,6 +563,7 @@ else if ( listIdDirectory == null ) List entriesGeolocationList = EntryHome.getEntryList( filterGeolocation, plugin ); model.put( MARK_ENTRY_LIST_GEOLOCATION, entriesGeolocationList ); + model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) ); HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_XPAGE_FRAME_DIRECTORY, request.getLocale( ), model ); diff --git a/src/java/fr/paris/lutece/plugins/directory/web/DirectoryJspBean.java b/src/java/fr/paris/lutece/plugins/directory/web/DirectoryJspBean.java index 58df908..ce30faa 100644 --- a/src/java/fr/paris/lutece/plugins/directory/web/DirectoryJspBean.java +++ b/src/java/fr/paris/lutece/plugins/directory/web/DirectoryJspBean.java @@ -34,7 +34,6 @@ package fr.paris.lutece.plugins.directory.web; import au.com.bytecode.opencsv.CSVReader; - import fr.paris.lutece.plugins.directory.business.Category; import fr.paris.lutece.plugins.directory.business.Directory; import fr.paris.lutece.plugins.directory.business.DirectoryAction; @@ -48,6 +47,7 @@ import fr.paris.lutece.plugins.directory.business.EntryFilter; import fr.paris.lutece.plugins.directory.business.EntryHome; import fr.paris.lutece.plugins.directory.business.EntryRemovalListenerService; +import fr.paris.lutece.plugins.directory.business.EntryTypeDownloadUrl; import fr.paris.lutece.plugins.directory.business.EntryTypeHome; import fr.paris.lutece.plugins.directory.business.Field; import fr.paris.lutece.plugins.directory.business.FieldHome; @@ -119,10 +119,11 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -133,13 +134,12 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; - /** * This class provides the user interface to manage form features ( manage, * create, modify, remove) */ -public class DirectoryJspBean extends PluginAdminPageJspBean -{ +public class DirectoryJspBean extends PluginAdminPageJspBean { + /** * Generated serial version UID */ @@ -260,6 +260,8 @@ public class DirectoryJspBean extends PluginAdminPageJspBean private static final String MARK_ID_DIRECTORY = "idDirectory"; private static final String MARK_ID_STATE = "idState"; private static final String MARK_WEBAPP_URL = "webapp_url"; + private static final String MARK_EXTENT_CURRENT = "extent_current_val"; + private static final String MARK_VISIBLE_LAYER = "visible_layer_val"; private static final String MARK_LOCALE = "locale"; private static final String MARK_PAGINATOR = "paginator"; private static final String MARK_USER_WORKGROUP_REF_LIST = "user_workgroup_list"; @@ -320,6 +322,15 @@ public class DirectoryJspBean extends PluginAdminPageJspBean private static final String MARK_DATE_MODIFICATION_END_SEARCH = "date_modification_end_search"; private static final String MARK_MAP_CHILD = "mapChild"; + /** + * mark for gru + */ + private static final String MARK_POSITION_GRU_FIRST_NAME = "pfn"; + private static final String MARK_POSITION_GRU_LAST_NAME = "pln"; + private static final String MARK_POSITION_GRU_GUID = "pguid"; + private static final String MARK_POSITION_GRU_CID = "pcid"; + private static final String MARK_POSITION_GRU_EMAIL = "pem"; + //private static final String MARK_URL_ACTION = "url_action"; private static final String MARK_STR_ERROR = "str_error"; private static final String MARK_NUMBER_LINES_IMPORTED = "number_lines_imported"; @@ -436,7 +447,16 @@ public class DirectoryJspBean extends PluginAdminPageJspBean private static final String PARAMETER_SELECTED_RECORD = "selected_record"; private static final String PARAMETER_ANCHOR_LIST = "list"; private static final String PARAMETER_IS_SEARCH_OPERATOR_OR = "is_search_operator_or"; + /** + * parames for gru + */ + private static final String PARAMETER_GRU_FIRST_NAME = "fn"; + private static final String PARAMETER_GRU_LAST_NAME = "ln"; + private static final String PARAMETER_GRU_GUID = "guid"; + private static final String PARAMETER_GRU_CID = "cid"; + private static final String PARAMETER_GRU_EMAIL = "em"; + // fn=abdou&cid=302714&ln=fall&guid=680a9e86-ffdc-45e6-a3c6-e3020b487624&ph=0858812641&em=fallphenix1987@gmail.com //private static final String PARAMETER_NUMBER_LINES_IMPORTED = "number_lines_imported"; //private static final String PARAMETER_NUMBER_LINES_ERROR = "number_lines_error"; private static final String PARAMETER_FILE_IMPORT = "file_import"; @@ -455,6 +475,9 @@ public class DirectoryJspBean extends PluginAdminPageJspBean private static final String CONSTANT_MIME_TYPE_CSV = "application/csv"; private static final String CONSTANT_MIME_TYPE_TEXT_CSV = "text/csv"; private static final String CONSTANT_MIME_TYPE_OCTETSTREAM = "application/octet-stream"; + private static final String CONSTANT_PREFIX_FIELD = "directory_"; + private static final String CONSTANT_ENTRY_TYPE_FILE = "EntryTypeFile"; + private static final String CONSTANT_ENTRY_TYPE_IMG = "EntryTypeImg"; private static final String MYLUTECE_PLUGIN = "mylutece"; // Import @@ -464,2889 +487,2723 @@ public class DirectoryJspBean extends PluginAdminPageJspBean private String DEFAULT_TYPE_IMAGE = "10"; //session fields - private DirectoryAdminSearchFields _searchFields = new DirectoryAdminSearchFields( ); - private DirectoryActionResult _directoryActionResult = new DirectoryActionResult( ); - private IRecordService _recordService = SpringContextService.getBean( RecordService.BEAN_SERVICE ); + private DirectoryAdminSearchFields _searchFields = new DirectoryAdminSearchFields(); + private DirectoryActionResult _directoryActionResult = new DirectoryActionResult(); + private IRecordService _recordService = SpringContextService.getBean(RecordService.BEAN_SERVICE); + private DirectoryAsynchronousUploadHandler _directoryAsynchronousUploadHandler = DirectoryAsynchronousUploadHandler.getHandler(); + private List _listUploadFieldName; + private List _listBoolean; /*-------------------------------MANAGEMENT DIRECTORY-----------------------------*/ - /** * Gets the DirectoryAdminSearchFields + * * @return searchFields */ - public DirectoryAdminSearchFields getSearchFields( ) - { + public DirectoryAdminSearchFields getSearchFields() { return _searchFields; } /** * Return management directory ( list of directory ) + * * @param request The Http request * @return Html directory */ - public String getManageDirectory( HttpServletRequest request ) - { + public String getManageDirectory(HttpServletRequest request) { // here is search/manage processing List listActionsForDirectoryEnable; List listActionsForDirectoryDisable; List listActions; - String strWorkGroup = request.getParameter( PARAMETER_WORKGROUP ); - String strActive = request.getParameter( PARAMETER_ACTIVE ); - _searchFields.setCurrentPageIndexDirectory( Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, - _searchFields.getCurrentPageIndexDirectory( ) ) ); - _searchFields.setItemsPerPageDirectory( Paginator.getItemsPerPage( request, Paginator.PARAMETER_ITEMS_PER_PAGE, - _searchFields.getItemsPerPageDirectory( ), _searchFields.getDefaultItemsPerPage( ) ) ); + String strWorkGroup = request.getParameter(PARAMETER_WORKGROUP); + String strActive = request.getParameter(PARAMETER_ACTIVE); + _searchFields.setCurrentPageIndexDirectory(Paginator.getPageIndex(request, Paginator.PARAMETER_PAGE_INDEX, + _searchFields.getCurrentPageIndexDirectory())); + _searchFields.setItemsPerPageDirectory(Paginator.getItemsPerPage(request, Paginator.PARAMETER_ITEMS_PER_PAGE, + _searchFields.getItemsPerPageDirectory(), _searchFields.getDefaultItemsPerPage())); - if ( ( strActive != null ) && !strActive.equals( DirectoryUtils.EMPTY_STRING ) ) - { - _searchFields.setIdActive( DirectoryUtils.convertStringToInt( strActive ) ); + if ((strActive != null) && !strActive.equals(DirectoryUtils.EMPTY_STRING)) { + _searchFields.setIdActive(DirectoryUtils.convertStringToInt(strActive)); } - if ( ( strWorkGroup != null ) && !strWorkGroup.equals( DirectoryUtils.EMPTY_STRING ) ) - { - _searchFields.setWorkGroup( strWorkGroup ); + if ((strWorkGroup != null) && !strWorkGroup.equals(DirectoryUtils.EMPTY_STRING)) { + _searchFields.setWorkGroup(strWorkGroup); } //build Filter - DirectoryFilter filter = new DirectoryFilter( ); - filter.setIsDisabled( _searchFields.getIdActive( ) ); - filter.setWorkGroup( _searchFields.getWorkGroup( ) ); - filter.setOrder( request.getParameter( MARK_SORT_ORDER ) ); - - List listDirectory = DirectoryHome.getDirectoryList( filter, getPlugin( ) ); - listDirectory = (List) AdminWorkgroupService.getAuthorizedCollection( listDirectory, getUser( ) ); - - Map model = new HashMap( ); - LocalizedPaginator paginator = new LocalizedPaginator( listDirectory, - _searchFields.getItemsPerPageDirectory( ), getJspManageDirectory( request ), PARAMETER_PAGE_INDEX, - _searchFields.getCurrentPageIndexDirectory( ), getLocale( ) ); - - listActionsForDirectoryEnable = DirectoryActionHome.selectActionsByFormState( Directory.STATE_ENABLE, - getPlugin( ), getLocale( ) ); - listActionsForDirectoryDisable = DirectoryActionHome.selectActionsByFormState( Directory.STATE_DISABLE, - getPlugin( ), getLocale( ) ); - - for ( Directory directory : paginator.getPageItems( ) ) - { - if ( directory.isEnabled( ) ) - { + DirectoryFilter filter = new DirectoryFilter(); + filter.setIsDisabled(_searchFields.getIdActive()); + filter.setWorkGroup(_searchFields.getWorkGroup()); + filter.setOrder(request.getParameter(MARK_SORT_ORDER)); + + List listDirectory = DirectoryHome.getDirectoryList(filter, getPlugin()); + listDirectory = (List) AdminWorkgroupService.getAuthorizedCollection(listDirectory, getUser()); + + Map model = new HashMap(); + LocalizedPaginator paginator = new LocalizedPaginator(listDirectory, + _searchFields.getItemsPerPageDirectory(), getJspManageDirectory(request), PARAMETER_PAGE_INDEX, + _searchFields.getCurrentPageIndexDirectory(), getLocale()); + + listActionsForDirectoryEnable = DirectoryActionHome.selectActionsByFormState(Directory.STATE_ENABLE, + getPlugin(), getLocale()); + listActionsForDirectoryDisable = DirectoryActionHome.selectActionsByFormState(Directory.STATE_DISABLE, + getPlugin(), getLocale()); + + for (Directory directory : paginator.getPageItems()) { + if (directory.isEnabled()) { listActions = listActionsForDirectoryEnable; - } - else - { + } else { listActions = listActionsForDirectoryDisable; } - listActions = (List) RBACService.getAuthorizedActionsCollection( listActions, directory, - getUser( ) ); - directory.setActions( listActions ); + listActions = (List) RBACService.getAuthorizedActionsCollection(listActions, directory, + getUser()); + directory.setActions(listActions); } - boolean bPermissionAdvancedParameter = RBACService.isAuthorized( Directory.RESOURCE_TYPE, + boolean bPermissionAdvancedParameter = RBACService.isAuthorized(Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, DirectoryResourceIdService.PERMISSION_MANAGE_ADVANCED_PARAMETERS, - getUser( ) ); + getUser()); - model.put( MARK_PAGINATOR, paginator ); - model.put( MARK_NB_ITEMS_PER_PAGE, Integer.toString( _searchFields.getItemsPerPageDirectory( ) ) ); - model.put( MARK_USER_WORKGROUP_REF_LIST, AdminWorkgroupService.getUserWorkgroups( getUser( ), getLocale( ) ) ); - model.put( MARK_USER_WORKGROUP_SELECTED, _searchFields.getWorkGroup( ) ); - model.put( MARK_ACTIVE_REF_LIST, getRefListActive( getLocale( ) ) ); - model.put( MARK_ACTIVE_SELECTED, _searchFields.getIdActive( ) ); - model.put( MARK_DIRECTORY_LIST, paginator.getPageItems( ) ); - model.put( MARK_PERMISSION_CREATE_DIRECTORY, - RBACService.isAuthorized( Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, - DirectoryResourceIdService.PERMISSION_CREATE, getUser( ) ) ); - model.put( MARK_PERMISSION_MANAGE_ADVANCED_PARAMETERS, bPermissionAdvancedParameter ); + model.put(MARK_PAGINATOR, paginator); + model.put(MARK_NB_ITEMS_PER_PAGE, Integer.toString(_searchFields.getItemsPerPageDirectory())); + model.put(MARK_USER_WORKGROUP_REF_LIST, AdminWorkgroupService.getUserWorkgroups(getUser(), getLocale())); + model.put(MARK_USER_WORKGROUP_SELECTED, _searchFields.getWorkGroup()); + model.put(MARK_ACTIVE_REF_LIST, getRefListActive(getLocale())); + model.put(MARK_ACTIVE_SELECTED, _searchFields.getIdActive()); + model.put(MARK_DIRECTORY_LIST, paginator.getPageItems()); + model.put(MARK_PERMISSION_CREATE_DIRECTORY, + RBACService.isAuthorized(Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, + DirectoryResourceIdService.PERMISSION_CREATE, getUser())); + model.put(MARK_PERMISSION_MANAGE_ADVANCED_PARAMETERS, bPermissionAdvancedParameter); - setPageTitleProperty( PROPERTY_MANAGE_DIRECTORY_PAGE_TITLE ); + setPageTitleProperty(PROPERTY_MANAGE_DIRECTORY_PAGE_TITLE); - HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_MANAGE_DIRECTORY, getLocale( ), model ); + HtmlTemplate templateList = AppTemplateService.getTemplate(TEMPLATE_MANAGE_DIRECTORY, getLocale(), model); - return getAdminPage( templateList.getHtml( ) ); + return getAdminPage(templateList.getHtml()); } /** * Get the request data and if there is no error insert the data in the - * directory specified in parameter. - * return null if there is no error or else return the error page url + * directory specified in parameter. return null if there is no error or + * else return the error page url + * * @param request the request * @param directory directory * @param locale the locale * @return null if there is no error or else return the error page url */ - private String getDirectoryData( HttpServletRequest request, Directory directory, Locale locale ) - { - String strTitle = request.getParameter( PARAMETER_TITLE ); - String strFrontOfficeTitle = request.getParameter( PARAMETER_FRONT_OFFICE_TITLE ); - String strDescription = request.getParameter( PARAMETER_DESCRIPTION ); - String strUnavailabilityMessage = request.getParameter( PARAMETER_UNAVAILABILITY_MESSAGE ); - String strWorkgroup = request.getParameter( PARAMETER_WORKGROUP ); - String strRoleKey = request.getParameter( PARAMETER_ROLE_KEY ); - - String strIdFormSearchTemplate = request.getParameter( PARAMETER_ID_FORM_SEARCH_TEMPLATE ); - String strIdResultListTemplate = request.getParameter( PARAMETER_ID_RESULT_LIST_TEMPLATE ); - String strIdResultRecordTemplate = request.getParameter( PARAMETER_ID_RESULT_RECORD_TEMPLATE ); - String strNumberRecordPerPage = request.getParameter( PARAMETER_NUMBER_RECORD_PER_PAGE ); - String strWorkflow = request.getParameter( PARAMETER_WORKFLOW ); - String strWorkflowState = request.getParameter( PARAMETER_WORKFLOW_STATE ); - String strDisplaySearchStateWorkflow = request.getParameter( PARAMETER_WORKFLOW_STATE_SEARCH ); - - String strIdSortEntry = request.getParameter( PARAMETER_ID_SORT_ENTRY ); - String strAscSort = request.getParameter( PARAMETER_ASC_SORT ); - String strIdSortEntryFront = request.getParameter( PARAMETER_ID_SORT_ENTRY_FRONT ); - String strAscSortFront = request.getParameter( PARAMETER_ASC_SORT_FRONT ); - String strRecordActivated = request.getParameter( PARAMETER_ACTIVATE_DIRECTORY_RECORD ); - String strIsIndexed = request.getParameter( PARAMETER_IS_INDEXED ); - String strSearchOperatorOr = request.getParameter( PARAMETER_IS_SEARCH_OPERATOR_OR ); + private String getDirectoryData(HttpServletRequest request, Directory directory, Locale locale) { + String strTitle = request.getParameter(PARAMETER_TITLE); + String strFrontOfficeTitle = request.getParameter(PARAMETER_FRONT_OFFICE_TITLE); + String strDescription = request.getParameter(PARAMETER_DESCRIPTION); + String strUnavailabilityMessage = request.getParameter(PARAMETER_UNAVAILABILITY_MESSAGE); + String strWorkgroup = request.getParameter(PARAMETER_WORKGROUP); + String strRoleKey = request.getParameter(PARAMETER_ROLE_KEY); + + String strIdFormSearchTemplate = request.getParameter(PARAMETER_ID_FORM_SEARCH_TEMPLATE); + String strIdResultListTemplate = request.getParameter(PARAMETER_ID_RESULT_LIST_TEMPLATE); + String strIdResultRecordTemplate = request.getParameter(PARAMETER_ID_RESULT_RECORD_TEMPLATE); + String strNumberRecordPerPage = request.getParameter(PARAMETER_NUMBER_RECORD_PER_PAGE); + String strWorkflow = request.getParameter(PARAMETER_WORKFLOW); + String strWorkflowState = request.getParameter(PARAMETER_WORKFLOW_STATE); + String strDisplaySearchStateWorkflow = request.getParameter(PARAMETER_WORKFLOW_STATE_SEARCH); + + String strIdSortEntry = request.getParameter(PARAMETER_ID_SORT_ENTRY); + String strAscSort = request.getParameter(PARAMETER_ASC_SORT); + String strIdSortEntryFront = request.getParameter(PARAMETER_ID_SORT_ENTRY_FRONT); + String strAscSortFront = request.getParameter(PARAMETER_ASC_SORT_FRONT); + String strRecordActivated = request.getParameter(PARAMETER_ACTIVATE_DIRECTORY_RECORD); + String strIsIndexed = request.getParameter(PARAMETER_IS_INDEXED); + String strSearchOperatorOr = request.getParameter(PARAMETER_IS_SEARCH_OPERATOR_OR); //creation date field - String strShowDateInResultList = request.getParameter( PARAMETER_DATE_SHOWN_IN_RESULT_LIST ); - String strShowDateInResultRecord = request.getParameter( PARAMETER_DATE_SHOWN_IN_RESULT_RECORD ); - String strShowDateInHistory = request.getParameter( PARAMETER_DATE_SHOWN_IN_HISTORY ); - String strShowDateInSearch = request.getParameter( PARAMETER_DATE_SHOWN_IN_SEARCH ); - String strShowDateInAdvancedSearch = request.getParameter( PARAMETER_DATE_SHOWN_IN_ADVANCED_SEARCH ); - String strShowDateInMultiSearch = request.getParameter( PARAMETER_DATE_SHOWN_IN_MULTI_SEARCH ); - String strShowDateInExport = request.getParameter( PARAMETER_DATE_SHOWN_IN_EXPORT ); + String strShowDateInResultList = request.getParameter(PARAMETER_DATE_SHOWN_IN_RESULT_LIST); + String strShowDateInResultRecord = request.getParameter(PARAMETER_DATE_SHOWN_IN_RESULT_RECORD); + String strShowDateInHistory = request.getParameter(PARAMETER_DATE_SHOWN_IN_HISTORY); + String strShowDateInSearch = request.getParameter(PARAMETER_DATE_SHOWN_IN_SEARCH); + String strShowDateInAdvancedSearch = request.getParameter(PARAMETER_DATE_SHOWN_IN_ADVANCED_SEARCH); + String strShowDateInMultiSearch = request.getParameter(PARAMETER_DATE_SHOWN_IN_MULTI_SEARCH); + String strShowDateInExport = request.getParameter(PARAMETER_DATE_SHOWN_IN_EXPORT); //creation date field - String strShowDateModificationInResultList = request.getParameter( PARAMETER_DATE_MODIFICATION_SHOWN_IN_RESULT_LIST ); - String strShowDateModificationInResultRecord = request.getParameter( PARAMETER_DATE_MODIFICATION_SHOWN_IN_RESULT_RECORD ); - String strShowDateModificationInHistory = request.getParameter( PARAMETER_DATE_MODIFICATION_SHOWN_IN_HISTORY ); - String strShowDateModificationInSearch = request.getParameter( PARAMETER_DATE_MODIFICATION_SHOWN_IN_SEARCH ); - String strShowDateModificationInAdvancedSearch = request.getParameter( PARAMETER_DATE_MODIFICATION_SHOWN_IN_ADVANCED_SEARCH ); - String strShowDateModificationInMultiSearch = request.getParameter( PARAMETER_DATE_MODIFICATION_SHOWN_IN_MULTI_SEARCH ); - String strShowDateModificationInExport = request.getParameter( PARAMETER_DATE_MODIFICATION_SHOWN_IN_EXPORT ); - - int nIdResultListTemplate = DirectoryUtils.convertStringToInt( strIdResultListTemplate ); - int nIdResultRecordTemplate = DirectoryUtils.convertStringToInt( strIdResultRecordTemplate ); - int nIdFormSearchTemplate = DirectoryUtils.convertStringToInt( strIdFormSearchTemplate ); - int nNumberRecordPerPage = DirectoryUtils.convertStringToInt( strNumberRecordPerPage ); - int nIdWorkflow = DirectoryUtils.convertStringToInt( strWorkflow ); - int nIdWorkflowState = DirectoryUtils.convertStringToInt( strWorkflowState ); + String strShowDateModificationInResultList = request.getParameter(PARAMETER_DATE_MODIFICATION_SHOWN_IN_RESULT_LIST); + String strShowDateModificationInResultRecord = request.getParameter(PARAMETER_DATE_MODIFICATION_SHOWN_IN_RESULT_RECORD); + String strShowDateModificationInHistory = request.getParameter(PARAMETER_DATE_MODIFICATION_SHOWN_IN_HISTORY); + String strShowDateModificationInSearch = request.getParameter(PARAMETER_DATE_MODIFICATION_SHOWN_IN_SEARCH); + String strShowDateModificationInAdvancedSearch = request.getParameter(PARAMETER_DATE_MODIFICATION_SHOWN_IN_ADVANCED_SEARCH); + String strShowDateModificationInMultiSearch = request.getParameter(PARAMETER_DATE_MODIFICATION_SHOWN_IN_MULTI_SEARCH); + String strShowDateModificationInExport = request.getParameter(PARAMETER_DATE_MODIFICATION_SHOWN_IN_EXPORT); + + int nIdResultListTemplate = DirectoryUtils.convertStringToInt(strIdResultListTemplate); + int nIdResultRecordTemplate = DirectoryUtils.convertStringToInt(strIdResultRecordTemplate); + int nIdFormSearchTemplate = DirectoryUtils.convertStringToInt(strIdFormSearchTemplate); + int nNumberRecordPerPage = DirectoryUtils.convertStringToInt(strNumberRecordPerPage); + int nIdWorkflow = DirectoryUtils.convertStringToInt(strWorkflow); + int nIdWorkflowState = DirectoryUtils.convertStringToInt(strWorkflowState); String strFieldError = DirectoryUtils.EMPTY_STRING; - if ( ( strTitle == null ) || strTitle.trim( ).equals( DirectoryUtils.EMPTY_STRING ) ) - { + if ((strTitle == null) || strTitle.trim().equals(DirectoryUtils.EMPTY_STRING)) { strFieldError = FIELD_TITLE; - } - - else if ( ( strDescription == null ) || strDescription.trim( ).equals( DirectoryUtils.EMPTY_STRING ) ) - { + } else if ((strDescription == null) || strDescription.trim().equals(DirectoryUtils.EMPTY_STRING)) { strFieldError = FIELD_DESCRIPTION; - } - - else if ( ( strUnavailabilityMessage == null ) || - strUnavailabilityMessage.trim( ).equals( DirectoryUtils.EMPTY_STRING ) ) - { + } else if ((strUnavailabilityMessage == null) + || strUnavailabilityMessage.trim().equals(DirectoryUtils.EMPTY_STRING)) { strFieldError = FIELD_UNAVAILABILITY_MESSAGE; - } - else if ( nIdFormSearchTemplate == DirectoryUtils.CONSTANT_ID_NULL ) - { + } else if (nIdFormSearchTemplate == DirectoryUtils.CONSTANT_ID_NULL) { strFieldError = FIELD_ID_FORM_SEARCH_TEMPLATE; - } - - else if ( nIdResultListTemplate == DirectoryUtils.CONSTANT_ID_NULL ) - { + } else if (nIdResultListTemplate == DirectoryUtils.CONSTANT_ID_NULL) { strFieldError = FIELD_ID_RESULT_LIST_TEMPLATE; - } - else if ( nIdResultRecordTemplate == DirectoryUtils.CONSTANT_ID_NULL ) - { + } else if (nIdResultRecordTemplate == DirectoryUtils.CONSTANT_ID_NULL) { strFieldError = FIELD_ID_RESULT_RECORD_TEMPLATE; - } - else if ( ( strNumberRecordPerPage == null ) || - strNumberRecordPerPage.trim( ).equals( DirectoryUtils.EMPTY_STRING ) ) - { + } else if ((strNumberRecordPerPage == null) + || strNumberRecordPerPage.trim().equals(DirectoryUtils.EMPTY_STRING)) { strFieldError = FIELD_NUMBER_RECORD_PER_PAGE; } - if ( !strFieldError.equals( DirectoryUtils.EMPTY_STRING ) ) - { - Object[] tabRequiredFields = { I18nService.getLocalizedString( strFieldError, getLocale( ) ) }; + if (!strFieldError.equals(DirectoryUtils.EMPTY_STRING)) { + Object[] tabRequiredFields = {I18nService.getLocalizedString(strFieldError, getLocale())}; - return AdminMessageService.getMessageUrl( request, MESSAGE_MANDATORY_FIELD, tabRequiredFields, - AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_MANDATORY_FIELD, tabRequiredFields, + AdminMessage.TYPE_STOP); } - if ( nNumberRecordPerPage == -1 ) - { + if (nNumberRecordPerPage == -1) { strFieldError = FIELD_NUMBER_RECORD_PER_PAGE; } - if ( !strFieldError.equals( DirectoryUtils.EMPTY_STRING ) ) - { - Object[] tabRequiredFields = { I18nService.getLocalizedString( strFieldError, locale ) }; + if (!strFieldError.equals(DirectoryUtils.EMPTY_STRING)) { + Object[] tabRequiredFields = {I18nService.getLocalizedString(strFieldError, locale)}; - return AdminMessageService.getMessageUrl( request, MESSAGE_NUMERIC_FIELD, tabRequiredFields, - AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_NUMERIC_FIELD, tabRequiredFields, + AdminMessage.TYPE_STOP); } - RecordFieldFilter recordFilter = new RecordFieldFilter( ); - recordFilter.setIdDirectory( directory.getIdDirectory( ) ); + RecordFieldFilter recordFilter = new RecordFieldFilter(); + recordFilter.setIdDirectory(directory.getIdDirectory()); - int nCountRecord = _recordService.getCountRecord( recordFilter, getPlugin( ) ); + int nCountRecord = _recordService.getCountRecord(recordFilter, getPlugin()); - if ( ( directory.getIdWorkflow( ) != nIdWorkflow ) && ( nCountRecord != 0 ) ) - { - return AdminMessageService.getMessageUrl( request, MESSAGE_WORKFLOW_CHANGE, AdminMessage.TYPE_STOP ); + if ((directory.getIdWorkflow() != nIdWorkflow) && (nCountRecord != 0)) { + return AdminMessageService.getMessageUrl(request, MESSAGE_WORKFLOW_CHANGE, AdminMessage.TYPE_STOP); } - directory.setTitle( strTitle ); + directory.setTitle(strTitle); - if ( strFrontOfficeTitle == null ) - { + if (strFrontOfficeTitle == null) { strFrontOfficeTitle = StringUtils.EMPTY; } - directory.setFrontOfficeTitle( strFrontOfficeTitle ); - directory.setDescription( strDescription ); - directory.setUnavailabilityMessage( strUnavailabilityMessage ); - directory.setWorkgroup( strWorkgroup ); - directory.setRoleKey( strRoleKey ); - directory.setIdFormSearchTemplate( nIdFormSearchTemplate ); - directory.setIdResultListTemplate( nIdResultListTemplate ); - directory.setIdResultRecordTemplate( nIdResultRecordTemplate ); - directory.setNumberRecordPerPage( nNumberRecordPerPage ); - directory.setIdWorkflow( nIdWorkflow ); - - if ( nIdWorkflow > DirectoryUtils.CONSTANT_ID_NULL ) - { - directory.setIdWorkflowStateToRemove( nIdWorkflowState ); - } - else - { - directory.setIdWorkflowStateToRemove( DirectoryUtils.CONSTANT_ID_NULL ); - } - - if ( ( strDisplaySearchStateWorkflow != null ) && - strDisplaySearchStateWorkflow.equals( IS_DISPLAY_STATE_SEARCH ) ) - { - directory.setDisplayComplementarySearchState( false ); - directory.setDisplaySearchState( true ); - } - else if ( ( strDisplaySearchStateWorkflow != null ) && - strDisplaySearchStateWorkflow.equals( IS_DISPLAY_STATE_SEARCH_COMPLEMENTARY ) ) - { - directory.setDisplayComplementarySearchState( true ); - directory.setDisplaySearchState( false ); - } - else if ( ( strDisplaySearchStateWorkflow != null ) && - strDisplaySearchStateWorkflow.equals( IS_NOT_DISPLAY_STATE_SEARCH ) ) - { - directory.setDisplayComplementarySearchState( false ); - directory.setDisplaySearchState( false ); - } - - directory.setDateShownInResultList( strShowDateInResultList != null ); - directory.setDateShownInResultRecord( strShowDateInResultRecord != null ); - directory.setDateShownInHistory( strShowDateInHistory != null ); - directory.setDateShownInSearch( strShowDateInSearch != null ); - directory.setDateShownInAdvancedSearch( strShowDateInAdvancedSearch != null ); - directory.setDateShownInMultiSearch( strShowDateInMultiSearch != null ); - directory.setDateShownInExport( strShowDateInExport != null ); - - directory.setDateModificationShownInResultList( strShowDateModificationInResultList != null ); - directory.setDateModificationShownInResultRecord( strShowDateModificationInResultRecord != null ); - directory.setDateModificationShownInHistory( strShowDateModificationInHistory != null ); - directory.setDateModificationShownInSearch( strShowDateModificationInSearch != null ); - directory.setDateModificationShownInAdvancedSearch( strShowDateModificationInAdvancedSearch != null ); - directory.setDateModificationShownInMultiSearch( strShowDateModificationInMultiSearch != null ); - directory.setDateModificationShownInExport( strShowDateModificationInExport != null ); - - if ( ( strIdSortEntry != null ) && ( !strIdSortEntry.equals( DirectoryUtils.EMPTY_STRING ) ) ) - { - directory.setIdSortEntry( strIdSortEntry ); - } - else - { - directory.setIdSortEntry( null ); - } - - if ( ( strIdSortEntryFront != null ) && ( !strIdSortEntryFront.equals( DirectoryUtils.EMPTY_STRING ) ) ) - { - directory.setIdSortEntryFront( strIdSortEntryFront ); - } - else - { - directory.setIdSortEntryFront( null ); - } - - directory.setAscendingSort( strAscSort != null ); - directory.setAscendingSortFront( strAscSortFront != null ); - directory.setRecordActivated( strRecordActivated != null ); - directory.setIndexed( strIsIndexed != null ); - directory.setSearchOperatorOr( strSearchOperatorOr != null ); + directory.setFrontOfficeTitle(strFrontOfficeTitle); + directory.setDescription(strDescription); + directory.setUnavailabilityMessage(strUnavailabilityMessage); + directory.setWorkgroup(strWorkgroup); + directory.setRoleKey(strRoleKey); + directory.setIdFormSearchTemplate(nIdFormSearchTemplate); + directory.setIdResultListTemplate(nIdResultListTemplate); + directory.setIdResultRecordTemplate(nIdResultRecordTemplate); + directory.setNumberRecordPerPage(nNumberRecordPerPage); + directory.setIdWorkflow(nIdWorkflow); + + if (nIdWorkflow > DirectoryUtils.CONSTANT_ID_NULL) { + directory.setIdWorkflowStateToRemove(nIdWorkflowState); + } else { + directory.setIdWorkflowStateToRemove(DirectoryUtils.CONSTANT_ID_NULL); + } + + if ((strDisplaySearchStateWorkflow != null) + && strDisplaySearchStateWorkflow.equals(IS_DISPLAY_STATE_SEARCH)) { + directory.setDisplayComplementarySearchState(false); + directory.setDisplaySearchState(true); + } else if ((strDisplaySearchStateWorkflow != null) + && strDisplaySearchStateWorkflow.equals(IS_DISPLAY_STATE_SEARCH_COMPLEMENTARY)) { + directory.setDisplayComplementarySearchState(true); + directory.setDisplaySearchState(false); + } else if ((strDisplaySearchStateWorkflow != null) + && strDisplaySearchStateWorkflow.equals(IS_NOT_DISPLAY_STATE_SEARCH)) { + directory.setDisplayComplementarySearchState(false); + directory.setDisplaySearchState(false); + } + + directory.setDateShownInResultList(strShowDateInResultList != null); + directory.setDateShownInResultRecord(strShowDateInResultRecord != null); + directory.setDateShownInHistory(strShowDateInHistory != null); + directory.setDateShownInSearch(strShowDateInSearch != null); + directory.setDateShownInAdvancedSearch(strShowDateInAdvancedSearch != null); + directory.setDateShownInMultiSearch(strShowDateInMultiSearch != null); + directory.setDateShownInExport(strShowDateInExport != null); + + directory.setDateModificationShownInResultList(strShowDateModificationInResultList != null); + directory.setDateModificationShownInResultRecord(strShowDateModificationInResultRecord != null); + directory.setDateModificationShownInHistory(strShowDateModificationInHistory != null); + directory.setDateModificationShownInSearch(strShowDateModificationInSearch != null); + directory.setDateModificationShownInAdvancedSearch(strShowDateModificationInAdvancedSearch != null); + directory.setDateModificationShownInMultiSearch(strShowDateModificationInMultiSearch != null); + directory.setDateModificationShownInExport(strShowDateModificationInExport != null); + + if ((strIdSortEntry != null) && (!strIdSortEntry.equals(DirectoryUtils.EMPTY_STRING))) { + directory.setIdSortEntry(strIdSortEntry); + } else { + directory.setIdSortEntry(null); + } + + if ((strIdSortEntryFront != null) && (!strIdSortEntryFront.equals(DirectoryUtils.EMPTY_STRING))) { + directory.setIdSortEntryFront(strIdSortEntryFront); + } else { + directory.setIdSortEntryFront(null); + } + + directory.setAscendingSort(strAscSort != null); + directory.setAscendingSortFront(strAscSortFront != null); + directory.setRecordActivated(strRecordActivated != null); + directory.setIndexed(strIsIndexed != null); + directory.setSearchOperatorOr(strSearchOperatorOr != null); return null; // No error } /** * Gets the directory creation page + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The directory creation page */ - public String getCreateDirectory( HttpServletRequest request ) - throws AccessDeniedException - { - AdminUser adminUser = getUser( ); - Locale locale = getLocale( ); + public String getCreateDirectory(HttpServletRequest request) + throws AccessDeniedException { + AdminUser adminUser = getUser(); + Locale locale = getLocale(); - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, - DirectoryResourceIdService.PERMISSION_CREATE, adminUser ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, + DirectoryResourceIdService.PERMISSION_CREATE, adminUser)) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - DirectoryXslFilter filter = new DirectoryXslFilter( ); + DirectoryXslFilter filter = new DirectoryXslFilter(); - filter.setIdCategory( Category.ID_CATEGORY_STYLE_FORM_SEARCH ); + filter.setIdCategory(Category.ID_CATEGORY_STYLE_FORM_SEARCH); - ReferenceList refListStyleFormSearch = DirectoryXslHome.getRefList( filter, getPlugin( ) ); + ReferenceList refListStyleFormSearch = DirectoryXslHome.getRefList(filter, getPlugin()); - filter.setIdCategory( Category.ID_CATEGORY_STYLE_RESULT_LIST ); + filter.setIdCategory(Category.ID_CATEGORY_STYLE_RESULT_LIST); - ReferenceList refListStyleResultList = DirectoryXslHome.getRefList( filter, getPlugin( ) ); + ReferenceList refListStyleResultList = DirectoryXslHome.getRefList(filter, getPlugin()); - filter.setIdCategory( Category.ID_CATEGORY_STYLE_RESULT_RECORD ); + filter.setIdCategory(Category.ID_CATEGORY_STYLE_RESULT_RECORD); - ReferenceList refListStyleResultRecord = DirectoryXslHome.getRefList( filter, getPlugin( ) ); + ReferenceList refListStyleResultRecord = DirectoryXslHome.getRefList(filter, getPlugin()); - Map model = new HashMap( ); - model.put( MARK_USER_WORKGROUP_REF_LIST, AdminWorkgroupService.getUserWorkgroups( adminUser, locale ) ); + Map model = new HashMap(); + model.put(MARK_USER_WORKGROUP_REF_LIST, AdminWorkgroupService.getUserWorkgroups(adminUser, locale)); - if ( WorkflowService.getInstance( ).isAvailable( ) ) - { - model.put( MARK_WORKFLOW_REF_LIST, WorkflowService.getInstance( ).getWorkflowsEnabled( adminUser, locale ) ); - model.put( MARK_WORKFLOW_STATE_SEARCH_SELECTED, IS_NOT_DISPLAY_STATE_SEARCH ); + if (WorkflowService.getInstance().isAvailable()) { + model.put(MARK_WORKFLOW_REF_LIST, WorkflowService.getInstance().getWorkflowsEnabled(adminUser, locale)); + model.put(MARK_WORKFLOW_STATE_SEARCH_SELECTED, IS_NOT_DISPLAY_STATE_SEARCH); } - if ( SecurityService.isAuthenticationEnable( ) ) - { - model.put( MARK_ROLE_REF_LIST, RoleHome.getRolesList( ) ); + if (SecurityService.isAuthenticationEnable()) { + model.put(MARK_ROLE_REF_LIST, RoleHome.getRolesList()); } // Default Values - ReferenceList listParamDefaultValues = DirectoryParameterService.getService( ).findDefaultValueParameters( ); + ReferenceList listParamDefaultValues = DirectoryParameterService.getService().findDefaultValueParameters(); - model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) ); - model.put( MARK_LOCALE, AdminUserService.getLocale( request ).getLanguage( ) ); - model.put( MARK_FORM_SEARCH_TEMPLATE_LIST, refListStyleFormSearch ); - model.put( MARK_RESULT_LIST_TEMPLATE_LIST, refListStyleResultList ); - model.put( MARK_RESULT_RECORD_TEMPLATE_LIST, refListStyleResultRecord ); - model.put( MARK_LIST_PARAM_DEFAULT_VALUES, listParamDefaultValues ); + model.put(MARK_WEBAPP_URL, AppPathService.getBaseUrl(request)); + model.put(MARK_LOCALE, AdminUserService.getLocale(request).getLanguage()); + model.put(MARK_FORM_SEARCH_TEMPLATE_LIST, refListStyleFormSearch); + model.put(MARK_RESULT_LIST_TEMPLATE_LIST, refListStyleResultList); + model.put(MARK_RESULT_RECORD_TEMPLATE_LIST, refListStyleResultRecord); + model.put(MARK_LIST_PARAM_DEFAULT_VALUES, listParamDefaultValues); - setPageTitleProperty( PROPERTY_CREATE_DIRECTORY_PAGE_TITLE ); + setPageTitleProperty(PROPERTY_CREATE_DIRECTORY_PAGE_TITLE); - HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_CREATE_DIRECTORY, locale, model ); + HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_CREATE_DIRECTORY, locale, model); - return getAdminPage( template.getHtml( ) ); + return getAdminPage(template.getHtml()); } /** * Perform the directory creation + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doCreateDirectory( HttpServletRequest request ) - throws AccessDeniedException - { - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, - DirectoryResourceIdService.PERMISSION_CREATE, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); - } - - if ( ( request.getParameter( PARAMETER_CANCEL ) == null ) ) - { - Plugin plugin = getPlugin( ); - Directory directory = new Directory( ); - String strError = getDirectoryData( request, directory, getLocale( ) ); - - if ( strError != null ) - { + public String doCreateDirectory(HttpServletRequest request) + throws AccessDeniedException { + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, + DirectoryResourceIdService.PERMISSION_CREATE, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); + } + + if ((request.getParameter(PARAMETER_CANCEL) == null)) { + Plugin plugin = getPlugin(); + Directory directory = new Directory(); + String strError = getDirectoryData(request, directory, getLocale()); + + if (strError != null) { return strError; } - directory.setDateCreation( DirectoryUtils.getCurrentTimestamp( ) ); - DirectoryHome.create( directory, plugin ); + directory.setDateCreation(DirectoryUtils.getCurrentTimestamp()); + DirectoryHome.create(directory, plugin); } - return getJspManageDirectory( request ); + return getJspManageDirectory(request); } /** * Gets the directory modification page + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The directory modification page */ - public String getModifyDirectory( HttpServletRequest request ) - throws AccessDeniedException - { - List listEntry = new ArrayList( ); + public String getModifyDirectory(HttpServletRequest request) + throws AccessDeniedException { + List listEntry = new ArrayList(); List listEntryFirstLevel; int nNumberField; EntryFilter filter; - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); Directory directory = null; - if ( nIdDirectory != -1 ) - { - directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); - _searchFields.setIdDirectory( nIdDirectory ); + if (nIdDirectory != -1) { + directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); + _searchFields.setIdDirectory(nIdDirectory); } - if ( ( directory == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_MODIFY, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((directory == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_MODIFY, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - filter = new EntryFilter( ); + filter = new EntryFilter(); - filter.setIdDirectory( nIdDirectory ); - filter.setIsEntryParentNull( EntryFilter.FILTER_TRUE ); - listEntryFirstLevel = EntryHome.getEntryList( filter, getPlugin( ) ); + filter.setIdDirectory(nIdDirectory); + filter.setIsEntryParentNull(EntryFilter.FILTER_TRUE); + listEntryFirstLevel = EntryHome.getEntryList(filter, getPlugin()); - filter.setIsEntryParentNull( EntryFilter.ALL_INT ); - filter.setIsComment( EntryFilter.FILTER_FALSE ); - filter.setIsGroup( EntryFilter.FILTER_FALSE ); + filter.setIsEntryParentNull(EntryFilter.ALL_INT); + filter.setIsComment(EntryFilter.FILTER_FALSE); + filter.setIsGroup(EntryFilter.FILTER_FALSE); - nNumberField = EntryHome.getNumberEntryByFilter( filter, getPlugin( ) ); + nNumberField = EntryHome.getNumberEntryByFilter(filter, getPlugin()); - if ( listEntryFirstLevel.size( ) != 0 ) - { - listEntryFirstLevel.get( 0 ).setFirstInTheList( true ); - listEntryFirstLevel.get( listEntryFirstLevel.size( ) - 1 ).setLastInTheList( true ); + if (listEntryFirstLevel.size() != 0) { + listEntryFirstLevel.get(0).setFirstInTheList(true); + listEntryFirstLevel.get(listEntryFirstLevel.size() - 1).setLastInTheList(true); } - for ( IEntry entry : listEntryFirstLevel ) - { - listEntry.add( entry ); + for (IEntry entry : listEntryFirstLevel) { + listEntry.add(entry); - if ( entry.getEntryType( ).getGroup( ) ) - { - filter = new EntryFilter( ); - filter.setIdEntryParent( entry.getIdEntry( ) ); - entry.setChildren( EntryHome.getEntryList( filter, getPlugin( ) ) ); + if (entry.getEntryType().getGroup()) { + filter = new EntryFilter(); + filter.setIdEntryParent(entry.getIdEntry()); + entry.setChildren(EntryHome.getEntryList(filter, getPlugin())); - if ( !entry.getChildren( ).isEmpty( ) ) - { - entry.getChildren( ).get( 0 ).setFirstInTheList( true ); - entry.getChildren( ).get( entry.getChildren( ).size( ) - 1 ).setLastInTheList( true ); + if (!entry.getChildren().isEmpty()) { + entry.getChildren().get(0).setFirstInTheList(true); + entry.getChildren().get(entry.getChildren().size() - 1).setLastInTheList(true); } - for ( IEntry entryChild : entry.getChildren( ) ) - { - listEntry.add( entryChild ); + for (IEntry entryChild : entry.getChildren()) { + listEntry.add(entryChild); } } } // Get ReferenceList of entry group for mass actions - filter = new EntryFilter( ); - filter.setIdDirectory( nIdDirectory ); - filter.setIsGroup( EntryFilter.FILTER_TRUE ); - - List listEntryGroup = EntryHome.getEntryList( filter, getPlugin( ) ); - ReferenceList entryGroupReferenceList = ReferenceList.convert( listEntryGroup, "idEntry", "title", true ); - ReferenceItem emptyItem = new ReferenceItem( ); - emptyItem.setCode( "-1" ); - emptyItem.setName( StringEscapeUtils.escapeHtml( I18nService.getLocalizedString( - PROPERTY_FIRST_ITEM_ENTRY_GROUP, getLocale( ) ) ) ); - entryGroupReferenceList.add( 0, emptyItem ); + filter = new EntryFilter(); + filter.setIdDirectory(nIdDirectory); + filter.setIsGroup(EntryFilter.FILTER_TRUE); + + List listEntryGroup = EntryHome.getEntryList(filter, getPlugin()); + ReferenceList entryGroupReferenceList = ReferenceList.convert(listEntryGroup, "idEntry", "title", true); + ReferenceItem emptyItem = new ReferenceItem(); + emptyItem.setCode("-1"); + emptyItem.setName(StringEscapeUtils.escapeHtml(I18nService.getLocalizedString( + PROPERTY_FIRST_ITEM_ENTRY_GROUP, getLocale()))); + entryGroupReferenceList.add(0, emptyItem); /////////////// - Map> mapIdParentOrdersChildren = new HashMap>( ); + Map> mapIdParentOrdersChildren = new HashMap>(); // List of entry first level order - List listOrderEntryFirstLevel = new ArrayList( ); - List listEntryFirstLevelMap = new ArrayList( ); - listEntryFirstLevelMap.addAll( listEntryFirstLevel ); - initOrderFirstLevel( listEntryFirstLevelMap, listOrderEntryFirstLevel ); + List listOrderEntryFirstLevel = new ArrayList(); + List listEntryFirstLevelMap = new ArrayList(); + listEntryFirstLevelMap.addAll(listEntryFirstLevel); + initOrderFirstLevel(listEntryFirstLevelMap, listOrderEntryFirstLevel); - mapIdParentOrdersChildren.put( "0", listOrderEntryFirstLevel ); + mapIdParentOrdersChildren.put("0", listOrderEntryFirstLevel); - if ( listEntryFirstLevelMap.size( ) != 0 ) - { - listEntryFirstLevelMap.get( 0 ).setFirstInTheList( true ); - listEntryFirstLevelMap.get( listEntryFirstLevelMap.size( ) - 1 ).setLastInTheList( true ); + if (listEntryFirstLevelMap.size() != 0) { + listEntryFirstLevelMap.get(0).setFirstInTheList(true); + listEntryFirstLevelMap.get(listEntryFirstLevelMap.size() - 1).setLastInTheList(true); } //fillEntryListWithEntryFirstLevel( plugin, listEntry, listEntryFirstLevelMap ); - populateEntryMap( listEntry, mapIdParentOrdersChildren ); + populateEntryMap(listEntry, mapIdParentOrdersChildren); - _searchFields.setCurrentPageIndexEntry( Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, - _searchFields.getCurrentPageIndexEntry( ) ) ); + _searchFields.setCurrentPageIndexEntry(Paginator.getPageIndex(request, Paginator.PARAMETER_PAGE_INDEX, + _searchFields.getCurrentPageIndexEntry())); - _searchFields.setItemsPerPageEntry( Paginator.getItemsPerPage( request, Paginator.PARAMETER_ITEMS_PER_PAGE, - _searchFields.getItemsPerPageEntry( ), _searchFields.getDefaultItemsPerPage( ) ) ); + _searchFields.setItemsPerPageEntry(Paginator.getItemsPerPage(request, Paginator.PARAMETER_ITEMS_PER_PAGE, + _searchFields.getItemsPerPageEntry(), _searchFields.getDefaultItemsPerPage())); - LocalizedPaginator paginator = new LocalizedPaginator( listEntry, - _searchFields.getItemsPerPageEntry( ), - AppPathService.getBaseUrl( request ) + JSP_MODIFY_DIRECTORY + "?id_directory=" + nIdDirectory, - PARAMETER_PAGE_INDEX, _searchFields.getCurrentPageIndexEntry( ), getLocale( ) ); + LocalizedPaginator paginator = new LocalizedPaginator(listEntry, + _searchFields.getItemsPerPageEntry(), + AppPathService.getBaseUrl(request) + JSP_MODIFY_DIRECTORY + "?id_directory=" + nIdDirectory, + PARAMETER_PAGE_INDEX, _searchFields.getCurrentPageIndexEntry(), getLocale()); - AdminUser adminUser = getUser( ); + AdminUser adminUser = getUser(); - Locale locale = getLocale( ); + Locale locale = getLocale(); ReferenceList refListWorkGroups; ReferenceList refMailingList; - refListWorkGroups = AdminWorkgroupService.getUserWorkgroups( adminUser, locale ); + refListWorkGroups = AdminWorkgroupService.getUserWorkgroups(adminUser, locale); - refMailingList = new ReferenceList( ); + refMailingList = new ReferenceList(); - String strNothing = I18nService.getLocalizedString( PROPERTY_NOTHING, locale ); - refMailingList.addItem( -1, strNothing ); - refMailingList.addAll( AdminMailingListService.getMailingLists( adminUser ) ); + String strNothing = I18nService.getLocalizedString(PROPERTY_NOTHING, locale); + refMailingList.addItem(-1, strNothing); + refMailingList.addAll(AdminMailingListService.getMailingLists(adminUser)); - DirectoryXslFilter directoryXslFilter = new DirectoryXslFilter( ); + DirectoryXslFilter directoryXslFilter = new DirectoryXslFilter(); - directoryXslFilter.setIdCategory( Category.ID_CATEGORY_STYLE_FORM_SEARCH ); + directoryXslFilter.setIdCategory(Category.ID_CATEGORY_STYLE_FORM_SEARCH); - ReferenceList refListStyleFormSearch = DirectoryXslHome.getRefList( directoryXslFilter, getPlugin( ) ); + ReferenceList refListStyleFormSearch = DirectoryXslHome.getRefList(directoryXslFilter, getPlugin()); - directoryXslFilter.setIdCategory( Category.ID_CATEGORY_STYLE_RESULT_LIST ); + directoryXslFilter.setIdCategory(Category.ID_CATEGORY_STYLE_RESULT_LIST); - ReferenceList refListStyleResultList = DirectoryXslHome.getRefList( directoryXslFilter, getPlugin( ) ); + ReferenceList refListStyleResultList = DirectoryXslHome.getRefList(directoryXslFilter, getPlugin()); - directoryXslFilter.setIdCategory( Category.ID_CATEGORY_STYLE_RESULT_RECORD ); + directoryXslFilter.setIdCategory(Category.ID_CATEGORY_STYLE_RESULT_RECORD); - ReferenceList refListStyleResultRecord = DirectoryXslHome.getRefList( directoryXslFilter, getPlugin( ) ); + ReferenceList refListStyleResultRecord = DirectoryXslHome.getRefList(directoryXslFilter, getPlugin()); - Map model = new HashMap( ); - model.put( MARK_PAGINATOR, paginator ); - model.put( MARK_NB_ITEMS_PER_PAGE, DirectoryUtils.EMPTY_STRING + _searchFields.getItemsPerPageEntry( ) ); - model.put( MARK_USER_WORKGROUP_REF_LIST, refListWorkGroups ); + Map model = new HashMap(); + model.put(MARK_PAGINATOR, paginator); + model.put(MARK_NB_ITEMS_PER_PAGE, DirectoryUtils.EMPTY_STRING + _searchFields.getItemsPerPageEntry()); + model.put(MARK_USER_WORKGROUP_REF_LIST, refListWorkGroups); - if ( SecurityService.isAuthenticationEnable( ) ) - { - model.put( MARK_ROLE_REF_LIST, RoleHome.getRolesList( ) ); + if (SecurityService.isAuthenticationEnable()) { + model.put(MARK_ROLE_REF_LIST, RoleHome.getRolesList()); } - if ( WorkflowService.getInstance( ).isAvailable( ) ) - { - ReferenceList referenceList = WorkflowService.getInstance( ).getWorkflowsEnabled( adminUser, locale ); - model.put( MARK_WORKFLOW_REF_LIST, referenceList ); - model.put( MARK_WORKFLOW_SELECTED, directory.getIdWorkflow( ) ); + if (WorkflowService.getInstance().isAvailable()) { + ReferenceList referenceList = WorkflowService.getInstance().getWorkflowsEnabled(adminUser, locale); + model.put(MARK_WORKFLOW_REF_LIST, referenceList); + model.put(MARK_WORKFLOW_SELECTED, directory.getIdWorkflow()); - ReferenceList refListWorkflowState = new ReferenceList( ); - ReferenceItem refItem = new ReferenceItem( ); - refItem.setCode( Integer.toString( DirectoryUtils.CONSTANT_ID_NULL ) ); - refItem.setName( I18nService.getLocalizedString( MESSAGE_NO_DIRECTORY_STATE, - AdminUserService.getLocale( request ) ) ); - refListWorkflowState.add( refItem ); + ReferenceList refListWorkflowState = new ReferenceList(); + ReferenceItem refItem = new ReferenceItem(); + refItem.setCode(Integer.toString(DirectoryUtils.CONSTANT_ID_NULL)); + refItem.setName(I18nService.getLocalizedString(MESSAGE_NO_DIRECTORY_STATE, + AdminUserService.getLocale(request))); + refListWorkflowState.add(refItem); - if ( directory.getIdWorkflow( ) > DirectoryUtils.CONSTANT_ID_NULL ) - { - Collection listWorkflowState = WorkflowService.getInstance( ) - .getAllStateByWorkflow( directory.getIdWorkflow( ), - AdminUserService.getAdminUser( request ) ); + if (directory.getIdWorkflow() > DirectoryUtils.CONSTANT_ID_NULL) { + Collection listWorkflowState = WorkflowService.getInstance() + .getAllStateByWorkflow(directory.getIdWorkflow(), + AdminUserService.getAdminUser(request)); - if ( ( listWorkflowState != null ) && ( listWorkflowState.size( ) > 0 ) ) - { - for ( State state : listWorkflowState ) - { - refItem = new ReferenceItem( ); - refItem.setCode( Integer.toString( state.getId( ) ) ); - refItem.setName( state.getName( ) ); - refListWorkflowState.add( refItem ); + if ((listWorkflowState != null) && (listWorkflowState.size() > 0)) { + for (State state : listWorkflowState) { + refItem = new ReferenceItem(); + refItem.setCode(Integer.toString(state.getId())); + refItem.setName(state.getName()); + refListWorkflowState.add(refItem); } } } - model.put( MARK_WORKFLOW_STATE_REF_LIST, refListWorkflowState ); + model.put(MARK_WORKFLOW_STATE_REF_LIST, refListWorkflowState); - if ( !referenceList.isEmpty( ) ) - { - model.put( MARK_WORKFLOW_STATE_SEARCH, true ); + if (!referenceList.isEmpty()) { + model.put(MARK_WORKFLOW_STATE_SEARCH, true); /* * ReferenceList referenceList=new ReferenceList(); * referenceList.addItem(1, strName) */ - if ( directory.isDisplaySearchState( ) ) - { - model.put( MARK_WORKFLOW_STATE_SEARCH_SELECTED, IS_DISPLAY_STATE_SEARCH ); - } - else if ( directory.isDisplayComplementarySearchState( ) ) - { - model.put( MARK_WORKFLOW_STATE_SEARCH_SELECTED, IS_DISPLAY_STATE_SEARCH_COMPLEMENTARY ); - } - else - { - model.put( MARK_WORKFLOW_STATE_SEARCH_SELECTED, IS_NOT_DISPLAY_STATE_SEARCH ); + if (directory.isDisplaySearchState()) { + model.put(MARK_WORKFLOW_STATE_SEARCH_SELECTED, IS_DISPLAY_STATE_SEARCH); + } else if (directory.isDisplayComplementarySearchState()) { + model.put(MARK_WORKFLOW_STATE_SEARCH_SELECTED, IS_DISPLAY_STATE_SEARCH_COMPLEMENTARY); + } else { + model.put(MARK_WORKFLOW_STATE_SEARCH_SELECTED, IS_NOT_DISPLAY_STATE_SEARCH); } } } - model.put( MARK_FORM_SEARCH_TEMPLATE_LIST, refListStyleFormSearch ); - model.put( MARK_RESULT_LIST_TEMPLATE_LIST, refListStyleResultList ); - model.put( MARK_RESULT_RECORD_TEMPLATE_LIST, refListStyleResultRecord ); - model.put( MARK_ENTRY_TYPE_LIST, EntryTypeHome.getList( getPlugin( ) ) ); - model.put( MARK_DIRECTORY, directory ); - model.put( MARK_ENTRY_LIST, paginator.getPageItems( ) ); - model.put( MARK_ENTRY_GROUP_LIST, entryGroupReferenceList ); - model.put( MARK_NUMBER_FIELD, nNumberField ); - model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) ); - model.put( MARK_LOCALE, AdminUserService.getLocale( request ).getLanguage( ) ); - model.put( MARK_IS_ACTIVE_MYLUTECE_AUTHENTIFICATION, PluginService.isPluginEnable( MYLUTECE_PLUGIN ) ); - model.put( MARK_IS_USER_ATTRIBUTES_SERVICE_ENABLE, DirectoryUserAttributesManager.getManager( ).isEnabled( ) ); - model.put( MARK_ID_ENTRY_TYPE_MYLUTECE_USER, - AppPropertiesService.getPropertyInt( PROPERTY_ENTRY_TYPE_MYLUTECE_USER, 19 ) ); - model.put( MARK_ID_ENTRY_TYPE_REMOTE_MYLUTECE_USER, - AppPropertiesService.getPropertyInt( PROPERTY_ENTRY_TYPE_REMOTE_MYLUTECE_USER, 21 ) ); - setPageTitleProperty( PROPERTY_MODIFY_DIRECTORY_TITLE ); - model.put( MARK_MAP_CHILD, mapIdParentOrdersChildren ); - - HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MODIFY_DIRECTORY, locale, model ); - - return getAdminPage( template.getHtml( ) ); + model.put(MARK_FORM_SEARCH_TEMPLATE_LIST, refListStyleFormSearch); + model.put(MARK_RESULT_LIST_TEMPLATE_LIST, refListStyleResultList); + model.put(MARK_RESULT_RECORD_TEMPLATE_LIST, refListStyleResultRecord); + model.put(MARK_ENTRY_TYPE_LIST, EntryTypeHome.getList(getPlugin())); + model.put(MARK_DIRECTORY, directory); + model.put(MARK_ENTRY_LIST, paginator.getPageItems()); + model.put(MARK_ENTRY_GROUP_LIST, entryGroupReferenceList); + model.put(MARK_NUMBER_FIELD, nNumberField); + model.put(MARK_WEBAPP_URL, AppPathService.getBaseUrl(request)); + model.put(MARK_LOCALE, AdminUserService.getLocale(request).getLanguage()); + model.put(MARK_IS_ACTIVE_MYLUTECE_AUTHENTIFICATION, PluginService.isPluginEnable(MYLUTECE_PLUGIN)); + model.put(MARK_IS_USER_ATTRIBUTES_SERVICE_ENABLE, DirectoryUserAttributesManager.getManager().isEnabled()); + model.put(MARK_ID_ENTRY_TYPE_MYLUTECE_USER, + AppPropertiesService.getPropertyInt(PROPERTY_ENTRY_TYPE_MYLUTECE_USER, 19)); + model.put(MARK_ID_ENTRY_TYPE_REMOTE_MYLUTECE_USER, + AppPropertiesService.getPropertyInt(PROPERTY_ENTRY_TYPE_REMOTE_MYLUTECE_USER, 21)); + setPageTitleProperty(PROPERTY_MODIFY_DIRECTORY_TITLE); + model.put(MARK_MAP_CHILD, mapIdParentOrdersChildren); + + HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_MODIFY_DIRECTORY, locale, model); + + return getAdminPage(template.getHtml()); } /** * Perform the directory modification + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doModifyDirectory( HttpServletRequest request ) - throws AccessDeniedException - { - if ( request.getParameter( PARAMETER_CANCEL ) == null ) - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); + public String doModifyDirectory(HttpServletRequest request) + throws AccessDeniedException { + if (request.getParameter(PARAMETER_CANCEL) == null) { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); Directory directory; - if ( nIdDirectory != -1 ) - { - directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); + if (nIdDirectory != -1) { + directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); - if ( ( directory == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_MODIFY, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((directory == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_MODIFY, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - int nOldIdWorkflow = directory.getIdWorkflow( ); - String strError = getDirectoryData( request, directory, getLocale( ) ); + int nOldIdWorkflow = directory.getIdWorkflow(); + String strError = getDirectoryData(request, directory, getLocale()); - if ( strError != null ) - { + if (strError != null) { return strError; } // If the directory has changed, then we reset the workflow state to remove records - if ( nOldIdWorkflow != directory.getIdWorkflow( ) ) - { - directory.setIdWorkflowStateToRemove( DirectoryUtils.CONSTANT_ID_NULL ); + if (nOldIdWorkflow != directory.getIdWorkflow()) { + directory.setIdWorkflowStateToRemove(DirectoryUtils.CONSTANT_ID_NULL); } - directory.setIdDirectory( nIdDirectory ); - DirectoryHome.update( directory, getPlugin( ) ); + directory.setIdDirectory(nIdDirectory); + DirectoryHome.update(directory, getPlugin()); - if ( request.getParameter( PARAMETER_APPLY ) != null ) - { - return getJspModifyDirectory( request, nIdDirectory ); + if (request.getParameter(PARAMETER_APPLY) != null) { + return getJspModifyDirectory(request, nIdDirectory); } } } - return getJspManageDirectory( request ); + return getJspManageDirectory(request); } /** * Change the attribute's order (move up or move down in the list) + * * @param request the request * @return The URL of the form management page */ - public String doChangeOrderEntry( HttpServletRequest request ) - { + public String doChangeOrderEntry(HttpServletRequest request) { //gets the entry which needs to be changed (order) - Plugin plugin = getPlugin( ); + Plugin plugin = getPlugin(); String strEntryId = StringUtils.EMPTY; String strOrderToSet = StringUtils.EMPTY; Integer nEntryId = 0; Integer nOrderToSet = 0; - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); IEntry entry; // To execute mass action "Move into" - if ( ( request.getParameter( PARAMETER_MOVE_BUTTON + ".x" ) != null ) || - ( request.getParameter( PARAMETER_MOVE_BUTTON ) != null ) ) - { - String strIdNewParent = request.getParameter( PARAMETER_ID_ENTRY_GROUP ); + if ((request.getParameter(PARAMETER_MOVE_BUTTON + ".x") != null) + || (request.getParameter(PARAMETER_MOVE_BUTTON) != null)) { + String strIdNewParent = request.getParameter(PARAMETER_ID_ENTRY_GROUP); Integer nIdNewParent = 0; - if ( StringUtils.isNotBlank( strIdNewParent ) ) - { - nIdNewParent = DirectoryUtils.convertStringToInt( strIdNewParent ); + if (StringUtils.isNotBlank(strIdNewParent)) { + nIdNewParent = DirectoryUtils.convertStringToInt(strIdNewParent); } // gets the entries which needs to be changed - String[] entryToMoveList = request.getParameterValues( PARAMETER_ID_ENTRY ); + String[] entryToMoveList = request.getParameterValues(PARAMETER_ID_ENTRY); - IEntry entryParent = EntryHome.findByPrimaryKey( nIdNewParent, plugin ); - List listEntry = new ArrayList( ); + IEntry entryParent = EntryHome.findByPrimaryKey(nIdNewParent, plugin); + List listEntry = new ArrayList(); - if ( entryParent == null ) - { - EntryFilter filter = new EntryFilter( ); - filter.setIdDirectory( nIdDirectory ); - listEntry = EntryHome.getEntryList( filter, plugin ); + if (entryParent == null) { + EntryFilter filter = new EntryFilter(); + filter.setIdDirectory(nIdDirectory); + listEntry = EntryHome.getEntryList(filter, plugin); } - Integer nListEntrySize = listEntry.size( ); + Integer nListEntrySize = listEntry.size(); - if ( entryToMoveList != null ) - { + if (entryToMoveList != null) { // for each entry, move it into selected group - for ( String strIdEntryToMove : entryToMoveList ) - { - IEntry entryToMove = EntryHome.findByPrimaryKey( DirectoryUtils.convertStringToInt( - strIdEntryToMove ), plugin ); - entryParent = EntryHome.findByPrimaryKey( nIdNewParent, plugin ); - - if ( ( entryToMove == null ) ) - { - return AdminMessageService.getMessageUrl( request, MESSAGE_SELECT_GROUP, AdminMessage.TYPE_STOP ); - } + for (String strIdEntryToMove : entryToMoveList) { + IEntry entryToMove = EntryHome.findByPrimaryKey(DirectoryUtils.convertStringToInt( + strIdEntryToMove), plugin); + entryParent = EntryHome.findByPrimaryKey(nIdNewParent, plugin); - // if entryParent is null, move out selected entries - if ( ( entryParent == null ) && ( entryToMove.getParent( ) != null ) ) - { - doMoveOutEntry( plugin, nIdDirectory, nListEntrySize, entryToMove ); + if ((entryToMove == null)) { + return AdminMessageService.getMessageUrl(request, MESSAGE_SELECT_GROUP, AdminMessage.TYPE_STOP); } - // Move entry into group if not allready in - else if ( ( entryParent != null ) && - ( ( entryToMove.getParent( ) == null ) || - ( ( entryToMove.getParent( ) != null ) && - ( entryToMove.getParent( ).getIdEntry( ) != entryParent.getIdEntry( ) ) ) ) ) - { - this.doMoveEntryIntoGroup( plugin, entryToMove, entryParent ); + // if entryParent is null, move out selected entries + if ((entryParent == null) && (entryToMove.getParent() != null)) { + doMoveOutEntry(plugin, nIdDirectory, nListEntrySize, entryToMove); + } // Move entry into group if not allready in + else if ((entryParent != null) + && ((entryToMove.getParent() == null) + || ((entryToMove.getParent() != null) + && (entryToMove.getParent().getIdEntry() != entryParent.getIdEntry())))) { + this.doMoveEntryIntoGroup(plugin, entryToMove, entryParent); } } } - } - - // To change order of one entry - else - { - EntryFilter filter = new EntryFilter( ); - filter.setIdDirectory( nIdDirectory ); - - List entryList = EntryHome.getEntryList( filter, getPlugin( ) ); - - for ( int i = 0; i < entryList.size( ); i++ ) - { - entry = entryList.get( i ); - nEntryId = entry.getIdEntry( ); - strEntryId = request.getParameter( PARAMETER_MOVE_BUTTON + "_" + nEntryId.toString( ) ); - - if ( StringUtils.isNotBlank( strEntryId ) ) - { - strEntryId = nEntryId.toString( ); - strOrderToSet = request.getParameter( PARAMETER_ORDER_ID + "_" + nEntryId.toString( ) ); - i = entryList.size( ); + } // To change order of one entry + else { + EntryFilter filter = new EntryFilter(); + filter.setIdDirectory(nIdDirectory); + + List entryList = EntryHome.getEntryList(filter, getPlugin()); + + for (int i = 0; i < entryList.size(); i++) { + entry = entryList.get(i); + nEntryId = entry.getIdEntry(); + strEntryId = request.getParameter(PARAMETER_MOVE_BUTTON + "_" + nEntryId.toString()); + + if (StringUtils.isNotBlank(strEntryId)) { + strEntryId = nEntryId.toString(); + strOrderToSet = request.getParameter(PARAMETER_ORDER_ID + "_" + nEntryId.toString()); + i = entryList.size(); } } - if ( StringUtils.isNotBlank( strEntryId ) ) - { - nEntryId = DirectoryUtils.convertStringToInt( strEntryId ); + if (StringUtils.isNotBlank(strEntryId)) { + nEntryId = DirectoryUtils.convertStringToInt(strEntryId); } - if ( StringUtils.isNotBlank( strOrderToSet ) ) - { - nOrderToSet = DirectoryUtils.convertStringToInt( strOrderToSet ); + if (StringUtils.isNotBlank(strOrderToSet)) { + nOrderToSet = DirectoryUtils.convertStringToInt(strOrderToSet); } - IEntry entryToChangeOrder = EntryHome.findByPrimaryKey( nEntryId, plugin ); - int nActualOrder = entryToChangeOrder.getPosition( ); + IEntry entryToChangeOrder = EntryHome.findByPrimaryKey(nEntryId, plugin); + int nActualOrder = entryToChangeOrder.getPosition(); // does nothing if the order to set is equal to the actual order - if ( nOrderToSet != nActualOrder ) - { + if (nOrderToSet != nActualOrder) { // entry goes up in the list - if ( nOrderToSet < entryToChangeOrder.getPosition( ) ) - { - moveUpEntryOrder( plugin, nOrderToSet, entryToChangeOrder, - entryToChangeOrder.getDirectory( ).getIdDirectory( ) ); - } - - // entry goes down in the list - else - { - moveDownEntryOrder( plugin, nOrderToSet, entryToChangeOrder, - entryToChangeOrder.getDirectory( ).getIdDirectory( ) ); + if (nOrderToSet < entryToChangeOrder.getPosition()) { + moveUpEntryOrder(plugin, nOrderToSet, entryToChangeOrder, + entryToChangeOrder.getDirectory().getIdDirectory()); + } // entry goes down in the list + else { + moveDownEntryOrder(plugin, nOrderToSet, entryToChangeOrder, + entryToChangeOrder.getDirectory().getIdDirectory()); } } } - UrlItem url = new UrlItem( AppPathService.getBaseUrl( request ) + JSP_MODIFY_DIRECTORY ); - url.addParameter( PARAMETER_ID_DIRECTORY, nIdDirectory ); - url.setAnchor( PARAMETER_ANCHOR_LIST ); + UrlItem url = new UrlItem(AppPathService.getBaseUrl(request) + JSP_MODIFY_DIRECTORY); + url.addParameter(PARAMETER_ID_DIRECTORY, nIdDirectory); + url.setAnchor(PARAMETER_ANCHOR_LIST); - return url.getUrl( ); + return url.getUrl(); } /** * Move out entry (no parent) + * * @param plugin the plugin * @param nIdDirectory the id directory * @param nListEntrySize the number of entry * @param entryToMove the entry to move */ - private void doMoveOutEntry( Plugin plugin, int nIdDirectory, Integer nListEntrySize, IEntry entryToMove ) - { - this.moveDownEntryOrder( plugin, nListEntrySize, entryToMove, nIdDirectory ); - entryToMove.setParent( null ); - EntryHome.update( entryToMove, plugin ); + private void doMoveOutEntry(Plugin plugin, int nIdDirectory, Integer nListEntrySize, IEntry entryToMove) { + this.moveDownEntryOrder(plugin, nListEntrySize, entryToMove, nIdDirectory); + entryToMove.setParent(null); + EntryHome.update(entryToMove, plugin); } /** * Gets the confirmation page of delete directory + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return the confirmation page of delete directory */ - public String getConfirmRemoveDirectory( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); + public String getConfirmRemoveDirectory(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); String strMessage; - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); - if ( ( strIdDirectory == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_DELETE, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((strIdDirectory == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_DELETE, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - RecordFieldFilter recordFieldFilter = new RecordFieldFilter( ); - recordFieldFilter.setIdDirectory( nIdDirectory ); + RecordFieldFilter recordFieldFilter = new RecordFieldFilter(); + recordFieldFilter.setIdDirectory(nIdDirectory); - int nNumberRecord = _recordService.getCountRecord( recordFieldFilter, getPlugin( ) ); - strMessage = ( nNumberRecord == 0 ) ? MESSAGE_CONFIRM_REMOVE_DIRECTORY - : MESSAGE_CONFIRM_REMOVE_DIRECTORY_WITH_RECORD; + int nNumberRecord = _recordService.getCountRecord(recordFieldFilter, getPlugin()); + strMessage = (nNumberRecord == 0) ? MESSAGE_CONFIRM_REMOVE_DIRECTORY + : MESSAGE_CONFIRM_REMOVE_DIRECTORY_WITH_RECORD; - UrlItem url = new UrlItem( JSP_DO_REMOVE_DIRECTORY ); - url.addParameter( PARAMETER_ID_DIRECTORY, strIdDirectory ); + UrlItem url = new UrlItem(JSP_DO_REMOVE_DIRECTORY); + url.addParameter(PARAMETER_ID_DIRECTORY, strIdDirectory); - return AdminMessageService.getMessageUrl( request, strMessage, url.getUrl( ), AdminMessage.TYPE_CONFIRMATION ); + return AdminMessageService.getMessageUrl(request, strMessage, url.getUrl(), AdminMessage.TYPE_CONFIRMATION); } /** * Perform the directory suppression + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doRemoveDirectory( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - ArrayList listErrors = new ArrayList( ); + public String doRemoveDirectory(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + ArrayList listErrors = new ArrayList(); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_DELETE, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_DELETE, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - if ( !DirectoryRemovalListenerService.getService( ).checkForRemoval( strIdDirectory, listErrors, getLocale( ) ) ) - { - String strCause = AdminMessageService.getFormattedList( listErrors, getLocale( ) ); - Object[] args = { strCause }; + if (!DirectoryRemovalListenerService.getService().checkForRemoval(strIdDirectory, listErrors, getLocale())) { + String strCause = AdminMessageService.getFormattedList(listErrors, getLocale()); + Object[] args = {strCause}; - return AdminMessageService.getMessageUrl( request, MESSAGE_CANNOT_REMOVE_DIRECTORY, args, - AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_CANNOT_REMOVE_DIRECTORY, args, + AdminMessage.TYPE_STOP); } - DirectoryHome.remove( nIdDirectory, getPlugin( ) ); + DirectoryHome.remove(nIdDirectory, getPlugin()); - return getJspManageDirectory( request ); + return getJspManageDirectory(request); } /** * Gets the confirmation page of remove all Directory Record + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return the confirmation page of delete all Directory Record */ - public String getConfirmRemoveAllDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); + public String getConfirmRemoveAllDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_DELETE_ALL_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_DELETE_ALL_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - UrlItem url = new UrlItem( JSP_DO_REMOVE_ALL_DIRECTORY_RECORD ); - url.addParameter( PARAMETER_ID_DIRECTORY, strIdDirectory ); + UrlItem url = new UrlItem(JSP_DO_REMOVE_ALL_DIRECTORY_RECORD); + url.addParameter(PARAMETER_ID_DIRECTORY, strIdDirectory); - return AdminMessageService.getMessageUrl( request, MESSAGE_CONFIRM_REMOVE_ALL_DIRECTORY_RECORD, url.getUrl( ), - AdminMessage.TYPE_CONFIRMATION ); + return AdminMessageService.getMessageUrl(request, MESSAGE_CONFIRM_REMOVE_ALL_DIRECTORY_RECORD, url.getUrl(), + AdminMessage.TYPE_CONFIRMATION); } /** * Remove all directory record of the directory + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doRemoveAllDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - Plugin plugin = getPlugin( ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); + public String doRemoveAllDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + Plugin plugin = getPlugin(); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_DELETE_ALL_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_DELETE_ALL_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - RecordFieldFilter recordFilter = new RecordFieldFilter( ); - recordFilter.setIdDirectory( nIdDirectory ); + RecordFieldFilter recordFilter = new RecordFieldFilter(); + recordFilter.setIdDirectory(nIdDirectory); - for ( Integer nRecordId : _recordService.getListRecordId( recordFilter, plugin ) ) - { - _recordService.remove( nRecordId, plugin ); + for (Integer nRecordId : _recordService.getListRecordId(recordFilter, plugin)) { + _recordService.remove(nRecordId, plugin); } /* Depreciated, this function does not remove the associated files */ - /* RecordHome.removeByIdDirectory( nIdDirectory, plugin ); */ - return getJspManageDirectory( request ); + /* RecordHome.removeByIdDirectory( nIdDirectory, plugin ); */ + return getJspManageDirectory(request); } /** * copy the directory whose key is specified in the Http request + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doCopyDirectory( HttpServletRequest request ) - throws AccessDeniedException - { - Plugin plugin = getPlugin( ); + public String doCopyDirectory(HttpServletRequest request) + throws AccessDeniedException { + Plugin plugin = getPlugin(); Directory directory; - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - directory = DirectoryHome.findByPrimaryKey( nIdDirectory, plugin ); + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + directory = DirectoryHome.findByPrimaryKey(nIdDirectory, plugin); - if ( ( directory == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_COPY, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((directory == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_COPY, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - Object[] tabFormTitleCopy = { directory.getTitle( ) }; - String strTitleCopyForm = I18nService.getLocalizedString( PROPERTY_COPY_DIRECTORY_TITLE, tabFormTitleCopy, - getLocale( ) ); + Object[] tabFormTitleCopy = {directory.getTitle()}; + String strTitleCopyForm = I18nService.getLocalizedString(PROPERTY_COPY_DIRECTORY_TITLE, tabFormTitleCopy, + getLocale()); - if ( strTitleCopyForm != null ) - { - directory.setTitle( strTitleCopyForm ); + if (strTitleCopyForm != null) { + directory.setTitle(strTitleCopyForm); } - DirectoryHome.copy( directory, plugin ); + DirectoryHome.copy(directory, plugin); - return getJspManageDirectory( request ); + return getJspManageDirectory(request); } /** * Gets the entry creation page + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The entry creation page */ - public String getCreateEntry( HttpServletRequest request ) - throws AccessDeniedException - { + public String getCreateEntry(HttpServletRequest request) + throws AccessDeniedException { Directory directory; - Plugin plugin = getPlugin( ); + Plugin plugin = getPlugin(); IEntry entry; - entry = DirectoryUtils.createEntryByType( request, plugin ); + entry = DirectoryUtils.createEntryByType(request, plugin); boolean bAssociationEntryWorkgroup; boolean bAssociationEntryRole; - if ( ( entry == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((entry == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - directory = DirectoryHome.findByPrimaryKey( _searchFields.getIdDirectory( ), plugin ); - entry.setDirectory( directory ); + directory = DirectoryHome.findByPrimaryKey(_searchFields.getIdDirectory(), plugin); + entry.setDirectory(directory); //test if an entry is already asoociated with a role or a workgroup - EntryFilter filter = new EntryFilter( ); - filter.setIdDirectory( _searchFields.getIdDirectory( ) ); - filter.setIsRoleAssociated( EntryFilter.FILTER_TRUE ); - bAssociationEntryRole = ( EntryHome.getNumberEntryByFilter( filter, plugin ) != 0 ); - filter.setIsRoleAssociated( EntryFilter.ALL_INT ); - filter.setIsWorkgroupAssociated( EntryFilter.FILTER_TRUE ); - bAssociationEntryWorkgroup = ( EntryHome.getNumberEntryByFilter( filter, plugin ) != 0 ); + EntryFilter filter = new EntryFilter(); + filter.setIdDirectory(_searchFields.getIdDirectory()); + filter.setIsRoleAssociated(EntryFilter.FILTER_TRUE); + bAssociationEntryRole = (EntryHome.getNumberEntryByFilter(filter, plugin) != 0); + filter.setIsRoleAssociated(EntryFilter.ALL_INT); + filter.setIsWorkgroupAssociated(EntryFilter.FILTER_TRUE); + bAssociationEntryWorkgroup = (EntryHome.getNumberEntryByFilter(filter, plugin) != 0); - Map model = new HashMap( ); + Map model = new HashMap(); //For Entry Type Directory - String strAutorizeEntryType = AppPropertiesService.getProperty( PROPERTY_ENTRY_AUTORIZE_FOR_ENTRY_DIRECTORY ); - String[] strTabAutorizeEntryType = strAutorizeEntryType.split( "," ); - - ReferenceList listEntryAssociateWithoutJavascript = new ReferenceList( ); - List> listEntryWithJavascript = new ArrayList>( ); - - for ( ReferenceItem item : DirectoryHome.getDirectoryList( plugin ) ) - { - List listEntry = new ArrayList( ); - Directory directoryTmp = DirectoryHome.findByPrimaryKey( DirectoryUtils.convertStringToInt( - item.getCode( ) ), plugin ); - EntryFilter entryFilter = new EntryFilter( ); - entryFilter.setIdDirectory( directoryTmp.getIdDirectory( ) ); - - for ( IEntry entryTmp : EntryHome.getEntryList( entryFilter, plugin ) ) - { + String strAutorizeEntryType = AppPropertiesService.getProperty(PROPERTY_ENTRY_AUTORIZE_FOR_ENTRY_DIRECTORY); + String[] strTabAutorizeEntryType = strAutorizeEntryType.split(","); + + ReferenceList listEntryAssociateWithoutJavascript = new ReferenceList(); + List> listEntryWithJavascript = new ArrayList>(); + + for (ReferenceItem item : DirectoryHome.getDirectoryList(plugin)) { + List listEntry = new ArrayList(); + Directory directoryTmp = DirectoryHome.findByPrimaryKey(DirectoryUtils.convertStringToInt( + item.getCode()), plugin); + EntryFilter entryFilter = new EntryFilter(); + entryFilter.setIdDirectory(directoryTmp.getIdDirectory()); + + for (IEntry entryTmp : EntryHome.getEntryList(entryFilter, plugin)) { boolean bEntryAutorize = false; - for ( int i = 0; ( i < strTabAutorizeEntryType.length ) && !bEntryAutorize; i++ ) - { - if ( entryTmp.getEntryType( ).getIdType( ) == DirectoryUtils.convertStringToInt( - strTabAutorizeEntryType[i] ) ) - { + for (int i = 0; (i < strTabAutorizeEntryType.length) && !bEntryAutorize; i++) { + if (entryTmp.getEntryType().getIdType() == DirectoryUtils.convertStringToInt( + strTabAutorizeEntryType[i])) { bEntryAutorize = true; } } - if ( bEntryAutorize ) - { - listEntryAssociateWithoutJavascript.addItem( entryTmp.getIdEntry( ), - directoryTmp.getTitle( ) + " - " + entryTmp.getTitle( ) ); - listEntry.add( entryTmp ); + if (bEntryAutorize) { + listEntryAssociateWithoutJavascript.addItem(entryTmp.getIdEntry(), + directoryTmp.getTitle() + " - " + entryTmp.getTitle()); + listEntry.add(entryTmp); } } - listEntryWithJavascript.add( listEntry ); + listEntryWithJavascript.add(listEntry); } // Default Values - ReferenceList listParamDefaultValues = EntryParameterService.getService( ).findAll( ); + ReferenceList listParamDefaultValues = EntryParameterService.getService().findAll(); - model.put( MARK_DIRECTORY_ENTRY_LIST_ASSOCIATE, listEntryAssociateWithoutJavascript ); - model.put( MARK_DIRECTORY_LIST_ASSOCIATE, DirectoryHome.getDirectoryList( plugin ) ); - model.put( MARK_ENTRY_LIST_ASSOCIATE, listEntryWithJavascript ); + model.put(MARK_DIRECTORY_ENTRY_LIST_ASSOCIATE, listEntryAssociateWithoutJavascript); + model.put(MARK_DIRECTORY_LIST_ASSOCIATE, DirectoryHome.getDirectoryList(plugin)); + model.put(MARK_ENTRY_LIST_ASSOCIATE, listEntryWithJavascript); - model.put( MARK_ENTRY, entry ); - model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) ); - model.put( MARK_LOCALE, AdminUserService.getLocale( request ).getLanguage( ) ); - model.put( MARK_IS_ASSOCIATION_ENTRY_WORKGROUP, bAssociationEntryWorkgroup ); - model.put( MARK_IS_ASSOCIATION_ENTRY_ROLE, bAssociationEntryRole ); - model.put( MARK_IS_AUTHENTIFICATION_ENABLED, SecurityService.isAuthenticationEnable( ) ); - model.put( MARK_LIST_PARAM_DEFAULT_VALUES, listParamDefaultValues ); + model.put(MARK_ENTRY, entry); + model.put(MARK_WEBAPP_URL, AppPathService.getBaseUrl(request)); + model.put(MARK_LOCALE, AdminUserService.getLocale(request).getLanguage()); + model.put(MARK_IS_ASSOCIATION_ENTRY_WORKGROUP, bAssociationEntryWorkgroup); + model.put(MARK_IS_ASSOCIATION_ENTRY_ROLE, bAssociationEntryRole); + model.put(MARK_IS_AUTHENTIFICATION_ENABLED, SecurityService.isAuthenticationEnable()); + model.put(MARK_LIST_PARAM_DEFAULT_VALUES, listParamDefaultValues); - if ( entry.getEntryType( ).getComment( ) ) - { - setPageTitleProperty( PROPERTY_CREATE_ENTRY_COMMENT_PAGE_TITLE ); - } - else - { - setPageTitleProperty( PROPERTY_CREATE_ENTRY_FIELD_PAGE_TITLE ); + if (entry.getEntryType().getComment()) { + setPageTitleProperty(PROPERTY_CREATE_ENTRY_COMMENT_PAGE_TITLE); + } else { + setPageTitleProperty(PROPERTY_CREATE_ENTRY_FIELD_PAGE_TITLE); } - HtmlTemplate template = AppTemplateService.getTemplate( entry.getTemplateCreate( ), getLocale( ), model ); + HtmlTemplate template = AppTemplateService.getTemplate(entry.getTemplateCreate(), getLocale(), model); - return getAdminPage( template.getHtml( ) ); + return getAdminPage(template.getHtml()); } /** * Perform the entry creation + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doCreateEntry( HttpServletRequest request ) - throws AccessDeniedException - { + public String doCreateEntry(HttpServletRequest request) + throws AccessDeniedException { IEntry entry; Directory directory; - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, Integer.toString( _searchFields.getIdDirectory( ) ), - DirectoryResourceIdService.PERMISSION_MODIFY, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, Integer.toString(_searchFields.getIdDirectory()), + DirectoryResourceIdService.PERMISSION_MODIFY, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - if ( ( request.getParameter( PARAMETER_CANCEL ) == null ) ) - { - entry = DirectoryUtils.createEntryByType( request, getPlugin( ) ); + if ((request.getParameter(PARAMETER_CANCEL) == null)) { + entry = DirectoryUtils.createEntryByType(request, getPlugin()); - if ( entry == null ) - { - return getJspManageDirectory( request ); + if (entry == null) { + return getJspManageDirectory(request); } - String strError = entry.getEntryData( request, getLocale( ) ); + String strError = entry.getEntryData(request, getLocale()); - if ( strError != null ) - { + if (strError != null) { return strError; } - directory = new Directory( ); - directory.setIdDirectory( _searchFields.getIdDirectory( ) ); - entry.setDirectory( directory ); - entry.setIdEntry( EntryHome.create( entry, getPlugin( ) ) ); - - if ( entry.getFields( ) != null ) - { - for ( Field field : entry.getFields( ) ) - { - field.setEntry( entry ); - FieldHome.create( field, getPlugin( ) ); + directory = new Directory(); + directory.setIdDirectory(_searchFields.getIdDirectory()); + entry.setDirectory(directory); + entry.setIdEntry(EntryHome.create(entry, getPlugin())); + + if (entry.getFields() != null) { + for (Field field : entry.getFields()) { + field.setEntry(entry); + FieldHome.create(field, getPlugin()); } } - if ( request.getParameter( PARAMETER_APPLY ) != null ) - { - return getJspModifyEntry( request, entry.getIdEntry( ) ); + if (request.getParameter(PARAMETER_APPLY) != null) { + return getJspModifyEntry(request, entry.getIdEntry()); } } - return getJspModifyDirectory( request, _searchFields.getIdDirectory( ) ); + return getJspModifyDirectory(request, _searchFields.getIdDirectory()); } /** * Gets the entry modification page + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The entry modification page */ - public String getModifyEntry( HttpServletRequest request ) - throws AccessDeniedException - { + public String getModifyEntry(HttpServletRequest request) + throws AccessDeniedException { boolean bAssociationEntryWorkgroup; boolean bAssociationEntryRole; - Plugin plugin = getPlugin( ); + Plugin plugin = getPlugin(); IEntry entry; ReferenceList refListRegularExpression; - String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY ); - int nIdEntry = DirectoryUtils.convertStringToInt( strIdEntry ); - entry = EntryHome.findByPrimaryKey( nIdEntry, plugin ); + String strIdEntry = request.getParameter(PARAMETER_ID_ENTRY); + int nIdEntry = DirectoryUtils.convertStringToInt(strIdEntry); + entry = EntryHome.findByPrimaryKey(nIdEntry, plugin); - if ( ( entry == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((entry == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - _searchFields.setIdEntry( nIdEntry ); + _searchFields.setIdEntry(nIdEntry); - List listField = new ArrayList( ); + List listField = new ArrayList(); - for ( Field field : entry.getFields( ) ) - { - field = FieldHome.findByPrimaryKey( field.getIdField( ), plugin ); - listField.add( field ); + for (Field field : entry.getFields()) { + field = FieldHome.findByPrimaryKey(field.getIdField(), plugin); + listField.add(field); } - entry.setFields( listField ); + entry.setFields(listField); - HashMap model = new HashMap( ); + HashMap model = new HashMap(); - int nIdTypeImage = DirectoryUtils.convertStringToInt( AppPropertiesService.getProperty( - PROPERTY_ENTRY_TYPE_IMAGE, DEFAULT_TYPE_IMAGE ) ); - - if ( entry.getEntryType( ).getIdType( ) == nIdTypeImage ) - { - for ( Field field : entry.getFields( ) ) - { - if ( ( field.getValue( ) != null ) && ( field.getValue( ).equals( FIELD_THUMBNAIL ) ) ) - { - model.put( MARK_THUMBNAIL_FIELD, field ); - model.put( MARK_HAS_THUMBNAIL, true ); - } + int nIdTypeImage = DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty( + PROPERTY_ENTRY_TYPE_IMAGE, DEFAULT_TYPE_IMAGE)); - else if ( ( field.getValue( ) != null ) && ( field.getValue( ).equals( FIELD_BIG_THUMBNAIL ) ) ) - { - model.put( MARK_BIG_THUMBNAIL_FIELD, field ); - model.put( MARK_HAS_BIG_THUMBNAIL, true ); - } - - else if ( ( field.getValue( ) != null ) && ( field.getValue( ).equals( FIELD_IMAGE ) ) ) - { - model.put( MARK_IMAGE_FIELD, field ); + if (entry.getEntryType().getIdType() == nIdTypeImage) { + for (Field field : entry.getFields()) { + if ((field.getValue() != null) && (field.getValue().equals(FIELD_THUMBNAIL))) { + model.put(MARK_THUMBNAIL_FIELD, field); + model.put(MARK_HAS_THUMBNAIL, true); + } else if ((field.getValue() != null) && (field.getValue().equals(FIELD_BIG_THUMBNAIL))) { + model.put(MARK_BIG_THUMBNAIL_FIELD, field); + model.put(MARK_HAS_BIG_THUMBNAIL, true); + } else if ((field.getValue() != null) && (field.getValue().equals(FIELD_IMAGE))) { + model.put(MARK_IMAGE_FIELD, field); } } } - model.put( MARK_ENTRY, entry ); - _searchFields.setCurrentPageIndex( Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, - _searchFields.getCurrentPageIndex( ) ) ); - _searchFields.setItemsPerPage( Paginator.getItemsPerPage( request, Paginator.PARAMETER_ITEMS_PER_PAGE, - _searchFields.getItemsPerPage( ), _searchFields.getDefaultItemsPerPage( ) ) ); + model.put(MARK_ENTRY, entry); + _searchFields.setCurrentPageIndex(Paginator.getPageIndex(request, Paginator.PARAMETER_PAGE_INDEX, + _searchFields.getCurrentPageIndex())); + _searchFields.setItemsPerPage(Paginator.getItemsPerPage(request, Paginator.PARAMETER_ITEMS_PER_PAGE, + _searchFields.getItemsPerPage(), _searchFields.getDefaultItemsPerPage())); - LocalizedPaginator paginator = entry.getPaginator( _searchFields.getItemsPerPage( ), - AppPathService.getBaseUrl( request ) + JSP_MODIFY_ENTRY + "?id_entry=" + nIdEntry, - PARAMETER_PAGE_INDEX, _searchFields.getCurrentPageIndex( ), getLocale( ) ); + LocalizedPaginator paginator = entry.getPaginator(_searchFields.getItemsPerPage(), + AppPathService.getBaseUrl(request) + JSP_MODIFY_ENTRY + "?id_entry=" + nIdEntry, + PARAMETER_PAGE_INDEX, _searchFields.getCurrentPageIndex(), getLocale()); - if ( paginator != null ) - { - model.put( MARK_NB_ITEMS_PER_PAGE, DirectoryUtils.EMPTY_STRING + _searchFields.getItemsPerPage( ) ); - model.put( MARK_NUMBER_ITEMS, paginator.getItemsCount( ) ); - model.put( MARK_LIST, paginator.getPageItems( ) ); - model.put( MARK_PAGINATOR, paginator ); + if (paginator != null) { + model.put(MARK_NB_ITEMS_PER_PAGE, DirectoryUtils.EMPTY_STRING + _searchFields.getItemsPerPage()); + model.put(MARK_NUMBER_ITEMS, paginator.getItemsCount()); + model.put(MARK_LIST, paginator.getPageItems()); + model.put(MARK_PAGINATOR, paginator); } - refListRegularExpression = entry.getReferenceListRegularExpression( entry, plugin ); + refListRegularExpression = entry.getReferenceListRegularExpression(entry, plugin); - if ( refListRegularExpression != null ) - { - model.put( MARK_REGULAR_EXPRESSION_LIST_REF_LIST, refListRegularExpression ); + if (refListRegularExpression != null) { + model.put(MARK_REGULAR_EXPRESSION_LIST_REF_LIST, refListRegularExpression); } - model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) ); - model.put( MARK_LOCALE, AdminUserService.getLocale( request ).getLanguage( ) ); + model.put(MARK_WEBAPP_URL, AppPathService.getBaseUrl(request)); + model.put(MARK_LOCALE, AdminUserService.getLocale(request).getLanguage()); - if ( entry.getEntryType( ).getComment( ) ) - { - setPageTitleProperty( PROPERTY_MODIFY_ENTRY_COMMENT_PAGE_TITLE ); - } - else if ( entry.getEntryType( ).getGroup( ) ) - { - setPageTitleProperty( PROPERTY_MODIFY_ENTRY_GROUP_PAGE_TITLE ); - } - else - { - setPageTitleProperty( PROPERTY_MODIFY_ENTRY_FIELD_PAGE_TITLE ); + if (entry.getEntryType().getComment()) { + setPageTitleProperty(PROPERTY_MODIFY_ENTRY_COMMENT_PAGE_TITLE); + } else if (entry.getEntryType().getGroup()) { + setPageTitleProperty(PROPERTY_MODIFY_ENTRY_GROUP_PAGE_TITLE); + } else { + setPageTitleProperty(PROPERTY_MODIFY_ENTRY_FIELD_PAGE_TITLE); } //test if an entry is already asoociated with a role or a workgroup - EntryFilter filter = new EntryFilter( ); - filter.setIdDirectory( _searchFields.getIdDirectory( ) ); - filter.setIsRoleAssociated( EntryFilter.FILTER_TRUE ); - bAssociationEntryRole = ( EntryHome.getNumberEntryByFilter( filter, plugin ) != 0 ); - filter.setIsRoleAssociated( EntryFilter.ALL_INT ); - filter.setIsWorkgroupAssociated( EntryFilter.FILTER_TRUE ); - bAssociationEntryWorkgroup = ( EntryHome.getNumberEntryByFilter( filter, plugin ) != 0 ); + EntryFilter filter = new EntryFilter(); + filter.setIdDirectory(_searchFields.getIdDirectory()); + filter.setIsRoleAssociated(EntryFilter.FILTER_TRUE); + bAssociationEntryRole = (EntryHome.getNumberEntryByFilter(filter, plugin) != 0); + filter.setIsRoleAssociated(EntryFilter.ALL_INT); + filter.setIsWorkgroupAssociated(EntryFilter.FILTER_TRUE); + bAssociationEntryWorkgroup = (EntryHome.getNumberEntryByFilter(filter, plugin) != 0); //For Entry Type Directory - String strAutorizeEntryType = AppPropertiesService.getProperty( PROPERTY_ENTRY_AUTORIZE_FOR_ENTRY_DIRECTORY ); - String[] strTabAutorizeEntryType = strAutorizeEntryType.split( "," ); - - ReferenceList listEntryAssociateWithoutJavascript = new ReferenceList( ); - List> listEntryWithJavascript = new ArrayList>( ); - - for ( ReferenceItem item : DirectoryHome.getDirectoryList( plugin ) ) - { - List listEntry = new ArrayList( ); - Directory directoryTmp = DirectoryHome.findByPrimaryKey( DirectoryUtils.convertStringToInt( - item.getCode( ) ), plugin ); - EntryFilter entryFilter = new EntryFilter( ); - entryFilter.setIdDirectory( directoryTmp.getIdDirectory( ) ); - - for ( IEntry entryTmp : EntryHome.getEntryList( entryFilter, plugin ) ) - { + String strAutorizeEntryType = AppPropertiesService.getProperty(PROPERTY_ENTRY_AUTORIZE_FOR_ENTRY_DIRECTORY); + String[] strTabAutorizeEntryType = strAutorizeEntryType.split(","); + + ReferenceList listEntryAssociateWithoutJavascript = new ReferenceList(); + List> listEntryWithJavascript = new ArrayList>(); + + for (ReferenceItem item : DirectoryHome.getDirectoryList(plugin)) { + List listEntry = new ArrayList(); + Directory directoryTmp = DirectoryHome.findByPrimaryKey(DirectoryUtils.convertStringToInt( + item.getCode()), plugin); + EntryFilter entryFilter = new EntryFilter(); + entryFilter.setIdDirectory(directoryTmp.getIdDirectory()); + + for (IEntry entryTmp : EntryHome.getEntryList(entryFilter, plugin)) { boolean bEntryAutorize = false; - for ( int i = 0; ( i < strTabAutorizeEntryType.length ) && !bEntryAutorize; i++ ) - { - if ( entryTmp.getEntryType( ).getIdType( ) == DirectoryUtils.convertStringToInt( - strTabAutorizeEntryType[i] ) ) - { + for (int i = 0; (i < strTabAutorizeEntryType.length) && !bEntryAutorize; i++) { + if (entryTmp.getEntryType().getIdType() == DirectoryUtils.convertStringToInt( + strTabAutorizeEntryType[i])) { bEntryAutorize = true; } } - if ( bEntryAutorize ) - { - listEntryAssociateWithoutJavascript.addItem( entryTmp.getIdEntry( ), - directoryTmp.getTitle( ) + " - " + entryTmp.getTitle( ) ); - listEntry.add( entryTmp ); + if (bEntryAutorize) { + listEntryAssociateWithoutJavascript.addItem(entryTmp.getIdEntry(), + directoryTmp.getTitle() + " - " + entryTmp.getTitle()); + listEntry.add(entryTmp); } } - listEntryWithJavascript.add( listEntry ); + listEntryWithJavascript.add(listEntry); } - model.put( MARK_DIRECTORY_ENTRY_LIST_ASSOCIATE, listEntryAssociateWithoutJavascript ); - model.put( MARK_DIRECTORY_LIST_ASSOCIATE, DirectoryHome.getDirectoryList( plugin ) ); + model.put(MARK_DIRECTORY_ENTRY_LIST_ASSOCIATE, listEntryAssociateWithoutJavascript); + model.put(MARK_DIRECTORY_LIST_ASSOCIATE, DirectoryHome.getDirectoryList(plugin)); - if ( ( entry.getEntryAssociate( ) != DirectoryUtils.CONSTANT_ID_NULL ) && - ( EntryHome.findByPrimaryKey( entry.getEntryAssociate( ), plugin ) != null ) ) - { - model.put( MARK_DIRECTORY_ASSOCIATE, - EntryHome.findByPrimaryKey( entry.getEntryAssociate( ), plugin ).getDirectory( ).getIdDirectory( ) ); + if ((entry.getEntryAssociate() != DirectoryUtils.CONSTANT_ID_NULL) + && (EntryHome.findByPrimaryKey(entry.getEntryAssociate(), plugin) != null)) { + model.put(MARK_DIRECTORY_ASSOCIATE, + EntryHome.findByPrimaryKey(entry.getEntryAssociate(), plugin).getDirectory().getIdDirectory()); } - model.put( MARK_ENTRY_LIST_ASSOCIATE, listEntryWithJavascript ); - model.put( MARK_IS_ASSOCIATION_ENTRY_WORKGROUP, bAssociationEntryWorkgroup ); - model.put( MARK_IS_ASSOCIATION_ENTRY_ROLE, bAssociationEntryRole ); - model.put( MARK_IS_AUTHENTIFICATION_ENABLED, SecurityService.isAuthenticationEnable( ) ); - model.put( MARK_ID_DIRECTORY, _searchFields.getIdDirectory( ) ); + model.put(MARK_ENTRY_LIST_ASSOCIATE, listEntryWithJavascript); + model.put(MARK_IS_ASSOCIATION_ENTRY_WORKGROUP, bAssociationEntryWorkgroup); + model.put(MARK_IS_ASSOCIATION_ENTRY_ROLE, bAssociationEntryRole); + model.put(MARK_IS_AUTHENTIFICATION_ENABLED, SecurityService.isAuthenticationEnable()); + model.put(MARK_ID_DIRECTORY, _searchFields.getIdDirectory()); - HtmlTemplate template = AppTemplateService.getTemplate( entry.getTemplateModify( ), getLocale( ), model ); + HtmlTemplate template = AppTemplateService.getTemplate(entry.getTemplateModify(), getLocale(), model); - return getAdminPage( template.getHtml( ) ); + return getAdminPage(template.getHtml()); } /** * Perform the entry modification + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doModifyEntry( HttpServletRequest request ) - throws AccessDeniedException - { - Plugin plugin = getPlugin( ); + public String doModifyEntry(HttpServletRequest request) + throws AccessDeniedException { + Plugin plugin = getPlugin(); IEntry entry; - String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY ); - int nIdEntry = DirectoryUtils.convertStringToInt( strIdEntry ); + String strIdEntry = request.getParameter(PARAMETER_ID_ENTRY); + int nIdEntry = DirectoryUtils.convertStringToInt(strIdEntry); - if ( ( nIdEntry == -1 ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((nIdEntry == -1) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - entry = EntryHome.findByPrimaryKey( nIdEntry, plugin ); + entry = EntryHome.findByPrimaryKey(nIdEntry, plugin); - if ( request.getParameter( PARAMETER_CANCEL ) == null ) - { - String strError = entry.getEntryData( request, getLocale( ) ); + if (request.getParameter(PARAMETER_CANCEL) == null) { + String strError = entry.getEntryData(request, getLocale()); - if ( strError != null ) - { + if (strError != null) { return strError; } - EntryHome.update( entry, plugin ); + EntryHome.update(entry, plugin); - if ( entry.getFields( ) != null ) - { - for ( Field field : entry.getFields( ) ) - { + if (entry.getFields() != null) { + for (Field field : entry.getFields()) { // Check if the field already exists in the database - Field fieldStored = FieldHome.findByPrimaryKey( field.getIdField( ), plugin ); + Field fieldStored = FieldHome.findByPrimaryKey(field.getIdField(), plugin); - if ( fieldStored != null ) - { + if (fieldStored != null) { // If it exists, update - FieldHome.update( field, plugin ); - } - else - { + FieldHome.update(field, plugin); + } else { // If it does not exist, create - FieldHome.create( field, plugin ); + FieldHome.create(field, plugin); } } } } - if ( request.getParameter( PARAMETER_APPLY ) == null ) - { - return getJspModifyDirectory( request, _searchFields.getIdDirectory( ) ); + if (request.getParameter(PARAMETER_APPLY) == null) { + return getJspModifyDirectory(request, _searchFields.getIdDirectory()); } - return getJspModifyEntry( request, nIdEntry ); + return getJspModifyEntry(request, nIdEntry); } /** * Gets the confirmation page of delete entry + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return the confirmation page of delete entry */ - public String getConfirmRemoveEntry( HttpServletRequest request ) - throws AccessDeniedException - { + public String getConfirmRemoveEntry(HttpServletRequest request) + throws AccessDeniedException { IEntry entry; - Plugin plugin = getPlugin( ); - String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY ); + Plugin plugin = getPlugin(); + String strIdEntry = request.getParameter(PARAMETER_ID_ENTRY); String strMessage; - int nIdEntry = DirectoryUtils.convertStringToInt( strIdEntry ); + int nIdEntry = DirectoryUtils.convertStringToInt(strIdEntry); - if ( ( nIdEntry == -1 ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((nIdEntry == -1) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - entry = EntryHome.findByPrimaryKey( nIdEntry, plugin ); + entry = EntryHome.findByPrimaryKey(nIdEntry, plugin); - if ( entry.getEntryType( ).getGroup( ) ) - { - strMessage = ( !entry.getChildren( ).isEmpty( ) ) ? MESSAGE_CONFIRM_REMOVE_GROUP_WITH_ENTRY - : MESSAGE_CONFIRM_REMOVE_GROUP_WITH_ANY_ENTRY; - } - else - { + if (entry.getEntryType().getGroup()) { + strMessage = (!entry.getChildren().isEmpty()) ? MESSAGE_CONFIRM_REMOVE_GROUP_WITH_ENTRY + : MESSAGE_CONFIRM_REMOVE_GROUP_WITH_ANY_ENTRY; + } else { strMessage = MESSAGE_CONFIRM_REMOVE_ENTRY; } - UrlItem url = new UrlItem( JSP_DO_REMOVE_ENTRY ); - url.addParameter( PARAMETER_ID_ENTRY, strIdEntry + "#list" ); + UrlItem url = new UrlItem(JSP_DO_REMOVE_ENTRY); + url.addParameter(PARAMETER_ID_ENTRY, strIdEntry + "#list"); - return AdminMessageService.getMessageUrl( request, strMessage, url.getUrl( ), AdminMessage.TYPE_CONFIRMATION ); + return AdminMessageService.getMessageUrl(request, strMessage, url.getUrl(), AdminMessage.TYPE_CONFIRMATION); } /** * Perform the entry supression + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doRemoveEntry( HttpServletRequest request ) - throws AccessDeniedException - { - Plugin plugin = getPlugin( ); - String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY ); - ArrayList listErrors = new ArrayList( ); + public String doRemoveEntry(HttpServletRequest request) + throws AccessDeniedException { + Plugin plugin = getPlugin(); + String strIdEntry = request.getParameter(PARAMETER_ID_ENTRY); + ArrayList listErrors = new ArrayList(); - int nIdEntry = DirectoryUtils.convertStringToInt( strIdEntry ); - IEntry entry = EntryHome.findByPrimaryKey( nIdEntry, getPlugin( ) ); + int nIdEntry = DirectoryUtils.convertStringToInt(strIdEntry); + IEntry entry = EntryHome.findByPrimaryKey(nIdEntry, getPlugin()); - if ( ( entry == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((entry == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - RecordFieldFilter recordFieldFilter = new RecordFieldFilter( ); - recordFieldFilter.setIdDirectory( _searchFields.getIdDirectory( ) ); + RecordFieldFilter recordFieldFilter = new RecordFieldFilter(); + recordFieldFilter.setIdDirectory(_searchFields.getIdDirectory()); - if ( !EntryRemovalListenerService.getService( ).checkForRemoval( strIdEntry, listErrors, getLocale( ) ) ) - { - String strCause = AdminMessageService.getFormattedList( listErrors, getLocale( ) ); - Object[] args = { strCause }; + if (!EntryRemovalListenerService.getService().checkForRemoval(strIdEntry, listErrors, getLocale())) { + String strCause = AdminMessageService.getFormattedList(listErrors, getLocale()); + Object[] args = {strCause}; - return AdminMessageService.getMessageUrl( request, MESSAGE_CANNOT_REMOVE_ENTRY, args, AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_CANNOT_REMOVE_ENTRY, args, AdminMessage.TYPE_STOP); } //remove all recordField associated - RecordFieldFilter filterField = new RecordFieldFilter( ); - filterField.setIdEntry( nIdEntry ); - RecordFieldHome.removeByFilter( filterField, true, plugin ); + RecordFieldFilter filterField = new RecordFieldFilter(); + filterField.setIdEntry(nIdEntry); + RecordFieldHome.removeByFilter(filterField, true, plugin); //remove entry List listEntry; - EntryFilter filter = new EntryFilter( ); - filter.setIdDirectory( entry.getDirectory( ).getIdDirectory( ) ); - listEntry = EntryHome.getEntryList( filter, plugin ); - this.moveDownEntryOrder( plugin, listEntry.size( ), entry, entry.getDirectory( ).getIdDirectory( ) ); - EntryHome.remove( nIdEntry, plugin ); + EntryFilter filter = new EntryFilter(); + filter.setIdDirectory(entry.getDirectory().getIdDirectory()); + listEntry = EntryHome.getEntryList(filter, plugin); + this.moveDownEntryOrder(plugin, listEntry.size(), entry, entry.getDirectory().getIdDirectory()); + EntryHome.remove(nIdEntry, plugin); - return getJspModifyDirectory( request, _searchFields.getIdDirectory( ) ); + return getJspModifyDirectory(request, _searchFields.getIdDirectory()); } /** * copy the entry whose key is specified in the Http request + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doCopyEntry( HttpServletRequest request ) - throws AccessDeniedException - { - Plugin plugin = getPlugin( ); - String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY ); + public String doCopyEntry(HttpServletRequest request) + throws AccessDeniedException { + Plugin plugin = getPlugin(); + String strIdEntry = request.getParameter(PARAMETER_ID_ENTRY); IEntry entry; - int nIdEntry = DirectoryUtils.convertStringToInt( strIdEntry ); - entry = EntryHome.findByPrimaryKey( nIdEntry, plugin ); + int nIdEntry = DirectoryUtils.convertStringToInt(strIdEntry); + entry = EntryHome.findByPrimaryKey(nIdEntry, plugin); - if ( ( entry == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((entry == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - RecordFieldFilter recordFieldFilter = new RecordFieldFilter( ); - recordFieldFilter.setIdDirectory( _searchFields.getIdDirectory( ) ); + RecordFieldFilter recordFieldFilter = new RecordFieldFilter(); + recordFieldFilter.setIdDirectory(_searchFields.getIdDirectory()); - Object[] tabEntryTitleCopy = { entry.getTitle( ) }; - String strTitleCopyEntry = I18nService.getLocalizedString( PROPERTY_COPY_ENTRY_TITLE, tabEntryTitleCopy, - getLocale( ) ); + Object[] tabEntryTitleCopy = {entry.getTitle()}; + String strTitleCopyEntry = I18nService.getLocalizedString(PROPERTY_COPY_ENTRY_TITLE, tabEntryTitleCopy, + getLocale()); - if ( strTitleCopyEntry != null ) - { - entry.setTitle( strTitleCopyEntry ); + if (strTitleCopyEntry != null) { + entry.setTitle(strTitleCopyEntry); } - EntryHome.copy( entry, plugin ); + EntryHome.copy(entry, plugin); - return getJspModifyDirectory( request, _searchFields.getIdDirectory( ) ); + return getJspModifyDirectory(request, _searchFields.getIdDirectory()); } /** * Gets the list of questions group + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return the list of questions group */ - public String getMoveEntry( HttpServletRequest request ) - throws AccessDeniedException - { - Plugin plugin = getPlugin( ); + public String getMoveEntry(HttpServletRequest request) + throws AccessDeniedException { + Plugin plugin = getPlugin(); IEntry entry; List listGroup; EntryFilter filter; - String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY ); - int nIdEntry = DirectoryUtils.convertStringToInt( strIdEntry ); - entry = EntryHome.findByPrimaryKey( nIdEntry, plugin ); + String strIdEntry = request.getParameter(PARAMETER_ID_ENTRY); + int nIdEntry = DirectoryUtils.convertStringToInt(strIdEntry); + entry = EntryHome.findByPrimaryKey(nIdEntry, plugin); - if ( ( entry == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((entry == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - _searchFields.setIdEntry( nIdEntry ); + _searchFields.setIdEntry(nIdEntry); //recup group - filter = new EntryFilter( ); - filter.setIdDirectory( entry.getDirectory( ).getIdDirectory( ) ); - filter.setIsGroup( EntryFilter.FILTER_TRUE ); - listGroup = EntryHome.getEntryList( filter, plugin ); + filter = new EntryFilter(); + filter.setIdDirectory(entry.getDirectory().getIdDirectory()); + filter.setIsGroup(EntryFilter.FILTER_TRUE); + listGroup = EntryHome.getEntryList(filter, plugin); - Map model = new HashMap( ); - model.put( MARK_ENTRY, entry ); - model.put( MARK_ENTRY_LIST, listGroup ); + Map model = new HashMap(); + model.put(MARK_ENTRY, entry); + model.put(MARK_ENTRY_LIST, listGroup); - setPageTitleProperty( DirectoryUtils.EMPTY_STRING ); + setPageTitleProperty(DirectoryUtils.EMPTY_STRING); - HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MOVE_ENTRY, getLocale( ), model ); + HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_MOVE_ENTRY, getLocale(), model); - return getAdminPage( template.getHtml( ) ); + return getAdminPage(template.getHtml()); } /** * Move the entry in the questions group specified in parameter + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doMoveEntry( HttpServletRequest request ) - throws AccessDeniedException - { - Plugin plugin = getPlugin( ); + public String doMoveEntry(HttpServletRequest request) + throws AccessDeniedException { + Plugin plugin = getPlugin(); IEntry entryToMove; IEntry entryGroup; - String strIdEntryGroup = request.getParameter( PARAMETER_ID_ENTRY ); - int nIdEntryGroup = DirectoryUtils.convertStringToInt( strIdEntryGroup ); + String strIdEntryGroup = request.getParameter(PARAMETER_ID_ENTRY); + int nIdEntryGroup = DirectoryUtils.convertStringToInt(strIdEntryGroup); - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, Integer.toString( _searchFields.getIdDirectory( ) ), - DirectoryResourceIdService.PERMISSION_MODIFY, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, Integer.toString(_searchFields.getIdDirectory()), + DirectoryResourceIdService.PERMISSION_MODIFY, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - entryToMove = EntryHome.findByPrimaryKey( _searchFields.getIdEntry( ), plugin ); - entryGroup = EntryHome.findByPrimaryKey( nIdEntryGroup, plugin ); + entryToMove = EntryHome.findByPrimaryKey(_searchFields.getIdEntry(), plugin); + entryGroup = EntryHome.findByPrimaryKey(nIdEntryGroup, plugin); - if ( ( entryToMove == null ) || ( entryGroup == null ) ) - { - return AdminMessageService.getMessageUrl( request, MESSAGE_SELECT_GROUP, AdminMessage.TYPE_STOP ); + if ((entryToMove == null) || (entryGroup == null)) { + return AdminMessageService.getMessageUrl(request, MESSAGE_SELECT_GROUP, AdminMessage.TYPE_STOP); } - doMoveEntryIntoGroup( plugin, entryToMove, entryGroup ); + doMoveEntryIntoGroup(plugin, entryToMove, entryGroup); - return getJspModifyDirectory( request, _searchFields.getIdDirectory( ) ); + return getJspModifyDirectory(request, _searchFields.getIdDirectory()); } /** * Move EntryToMove into entryGroup + * * @param plugin the plugin * @param entryToMove the entry to move * @param entryGroup the entry parent */ - private void doMoveEntryIntoGroup( Plugin plugin, IEntry entryToMove, IEntry entryGroup ) - { + private void doMoveEntryIntoGroup(Plugin plugin, IEntry entryToMove, IEntry entryGroup) { int nPosition; // if ( ( entryGroup.getChildren( ) != null ) && ( !entryGroup.getChildren( ).isEmpty( ) ) ) // { // nPosition = entryGroup.getPosition( ) + entryGroup.getChildren( ).size( ) + 1; // } - if ( entryToMove.getPosition( ) < entryGroup.getPosition( ) ) - { - nPosition = entryGroup.getPosition( ); - this.moveDownEntryOrder( plugin, nPosition, entryToMove, entryToMove.getDirectory( ).getIdDirectory( ) ); - } - else - { - nPosition = entryGroup.getPosition( ) + entryGroup.getChildren( ).size( ) + 1; - this.moveUpEntryOrder( plugin, nPosition, entryToMove, entryToMove.getDirectory( ).getIdDirectory( ) ); + if (entryToMove.getPosition() < entryGroup.getPosition()) { + nPosition = entryGroup.getPosition(); + this.moveDownEntryOrder(plugin, nPosition, entryToMove, entryToMove.getDirectory().getIdDirectory()); + } else { + nPosition = entryGroup.getPosition() + entryGroup.getChildren().size() + 1; + this.moveUpEntryOrder(plugin, nPosition, entryToMove, entryToMove.getDirectory().getIdDirectory()); } - entryToMove.setParent( entryGroup ); - EntryHome.update( entryToMove, plugin ); + entryToMove.setParent(entryGroup); + EntryHome.update(entryToMove, plugin); } /** * Move up the entry + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doMoveUpEntry( HttpServletRequest request ) - throws AccessDeniedException - { - Plugin plugin = getPlugin( ); + public String doMoveUpEntry(HttpServletRequest request) + throws AccessDeniedException { + Plugin plugin = getPlugin(); IEntry entry; - String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY ); - int nIdEntry = DirectoryUtils.convertStringToInt( strIdEntry ); - entry = EntryHome.findByPrimaryKey( nIdEntry, plugin ); + String strIdEntry = request.getParameter(PARAMETER_ID_ENTRY); + int nIdEntry = DirectoryUtils.convertStringToInt(strIdEntry); + entry = EntryHome.findByPrimaryKey(nIdEntry, plugin); - if ( ( entry == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((entry == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } List listEntry; - EntryFilter filter = new EntryFilter( ); - filter.setIdDirectory( entry.getDirectory( ).getIdDirectory( ) ); + EntryFilter filter = new EntryFilter(); + filter.setIdDirectory(entry.getDirectory().getIdDirectory()); - if ( entry.getParent( ) != null ) - { - filter.setIdEntryParent( entry.getParent( ).getIdEntry( ) ); - } - else - { - filter.setIsEntryParentNull( EntryFilter.FILTER_TRUE ); + if (entry.getParent() != null) { + filter.setIdEntryParent(entry.getParent().getIdEntry()); + } else { + filter.setIsEntryParentNull(EntryFilter.FILTER_TRUE); } - listEntry = EntryHome.getEntryList( filter, plugin ); + listEntry = EntryHome.getEntryList(filter, plugin); - int nIndexEntry = DirectoryUtils.getIndexEntryInTheEntryList( nIdEntry, listEntry ); + int nIndexEntry = DirectoryUtils.getIndexEntryInTheEntryList(nIdEntry, listEntry); - if ( nIndexEntry != 0 ) - { + if (nIndexEntry != 0) { int nNewPosition; IEntry entryToInversePosition; - entryToInversePosition = listEntry.get( nIndexEntry - 1 ); - entryToInversePosition = EntryHome.findByPrimaryKey( entryToInversePosition.getIdEntry( ), plugin ); + entryToInversePosition = listEntry.get(nIndexEntry - 1); + entryToInversePosition = EntryHome.findByPrimaryKey(entryToInversePosition.getIdEntry(), plugin); - nNewPosition = entryToInversePosition.getPosition( ); - entryToInversePosition.setPosition( entry.getPosition( ) ); - entry.setPosition( nNewPosition ); - EntryHome.update( entry, plugin ); - EntryHome.update( entryToInversePosition, plugin ); + nNewPosition = entryToInversePosition.getPosition(); + entryToInversePosition.setPosition(entry.getPosition()); + entry.setPosition(nNewPosition); + EntryHome.update(entry, plugin); + EntryHome.update(entryToInversePosition, plugin); } - return getJspModifyDirectory( request, _searchFields.getIdDirectory( ) ); + return getJspModifyDirectory(request, _searchFields.getIdDirectory()); } /** * Move down the entry + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doMoveDownEntry( HttpServletRequest request ) - throws AccessDeniedException - { - Plugin plugin = getPlugin( ); + public String doMoveDownEntry(HttpServletRequest request) + throws AccessDeniedException { + Plugin plugin = getPlugin(); IEntry entry; - String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY ); - int nIdEntry = DirectoryUtils.convertStringToInt( strIdEntry ); - entry = EntryHome.findByPrimaryKey( nIdEntry, plugin ); + String strIdEntry = request.getParameter(PARAMETER_ID_ENTRY); + int nIdEntry = DirectoryUtils.convertStringToInt(strIdEntry); + entry = EntryHome.findByPrimaryKey(nIdEntry, plugin); - if ( ( entry == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((entry == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } List listEntry; - EntryFilter filter = new EntryFilter( ); - filter.setIdDirectory( entry.getDirectory( ).getIdDirectory( ) ); + EntryFilter filter = new EntryFilter(); + filter.setIdDirectory(entry.getDirectory().getIdDirectory()); - if ( entry.getParent( ) != null ) - { - filter.setIdEntryParent( entry.getParent( ).getIdEntry( ) ); - } - else - { - filter.setIsEntryParentNull( EntryFilter.FILTER_TRUE ); + if (entry.getParent() != null) { + filter.setIdEntryParent(entry.getParent().getIdEntry()); + } else { + filter.setIsEntryParentNull(EntryFilter.FILTER_TRUE); } - listEntry = EntryHome.getEntryList( filter, plugin ); + listEntry = EntryHome.getEntryList(filter, plugin); - int nIndexEntry = DirectoryUtils.getIndexEntryInTheEntryList( nIdEntry, listEntry ); + int nIndexEntry = DirectoryUtils.getIndexEntryInTheEntryList(nIdEntry, listEntry); - if ( nIndexEntry != ( listEntry.size( ) - 1 ) ) - { + if (nIndexEntry != (listEntry.size() - 1)) { int nNewPosition; IEntry entryToInversePosition; - entryToInversePosition = listEntry.get( nIndexEntry + 1 ); - entryToInversePosition = EntryHome.findByPrimaryKey( entryToInversePosition.getIdEntry( ), plugin ); + entryToInversePosition = listEntry.get(nIndexEntry + 1); + entryToInversePosition = EntryHome.findByPrimaryKey(entryToInversePosition.getIdEntry(), plugin); - nNewPosition = entryToInversePosition.getPosition( ); - entryToInversePosition.setPosition( entry.getPosition( ) ); - entry.setPosition( nNewPosition ); - EntryHome.update( entry, plugin ); - EntryHome.update( entryToInversePosition, plugin ); + nNewPosition = entryToInversePosition.getPosition(); + entryToInversePosition.setPosition(entry.getPosition()); + entry.setPosition(nNewPosition); + EntryHome.update(entry, plugin); + EntryHome.update(entryToInversePosition, plugin); } - return getJspModifyDirectory( request, _searchFields.getIdDirectory( ) ); + return getJspModifyDirectory(request, _searchFields.getIdDirectory()); } /** * Move out the entry + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doMoveOutEntry( HttpServletRequest request ) - throws AccessDeniedException - { - Plugin plugin = getPlugin( ); + public String doMoveOutEntry(HttpServletRequest request) + throws AccessDeniedException { + Plugin plugin = getPlugin(); IEntry entry; - String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY ); - int nIdEntry = DirectoryUtils.convertStringToInt( strIdEntry ); - entry = EntryHome.findByPrimaryKey( nIdEntry, plugin ); + String strIdEntry = request.getParameter(PARAMETER_ID_ENTRY); + int nIdEntry = DirectoryUtils.convertStringToInt(strIdEntry); + entry = EntryHome.findByPrimaryKey(nIdEntry, plugin); - if ( ( entry == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((entry == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } List listEntry; - EntryFilter filter = new EntryFilter( ); - filter.setIdDirectory( entry.getDirectory( ).getIdDirectory( ) ); - listEntry = EntryHome.getEntryList( filter, plugin ); + EntryFilter filter = new EntryFilter(); + filter.setIdDirectory(entry.getDirectory().getIdDirectory()); + listEntry = EntryHome.getEntryList(filter, plugin); - Integer nListEntrySize = listEntry.size( ); + Integer nListEntrySize = listEntry.size(); - this.doMoveOutEntry( plugin, entry.getDirectory( ).getIdDirectory( ), nListEntrySize, entry ); + this.doMoveOutEntry(plugin, entry.getDirectory().getIdDirectory(), nListEntrySize, entry); - return getJspModifyDirectory( request, _searchFields.getIdDirectory( ) ); + return getJspModifyDirectory(request, _searchFields.getIdDirectory()); } /** * Gets the confirmation page of disable directory + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return the confirmation page of disable directory */ - public String getConfirmDisableDirectory( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); + public String getConfirmDisableDirectory(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); String strMessage; - if ( ( nIdDirectory == DirectoryUtils.CONSTANT_ID_NULL ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_CHANGE_STATE, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((nIdDirectory == DirectoryUtils.CONSTANT_ID_NULL) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_CHANGE_STATE, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } strMessage = MESSAGE_CONFIRM_DISABLE_DIRECTORY; - UrlItem url = new UrlItem( JSP_DO_DISABLE_DIRECTORY ); - url.addParameter( PARAMETER_ID_DIRECTORY, strIdDirectory ); + UrlItem url = new UrlItem(JSP_DO_DISABLE_DIRECTORY); + url.addParameter(PARAMETER_ID_DIRECTORY, strIdDirectory); - return AdminMessageService.getMessageUrl( request, strMessage, url.getUrl( ), AdminMessage.TYPE_CONFIRMATION ); + return AdminMessageService.getMessageUrl(request, strMessage, url.getUrl(), AdminMessage.TYPE_CONFIRMATION); } /** * Perform disable directory + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doDisableDirectory( HttpServletRequest request ) - throws AccessDeniedException - { + public String doDisableDirectory(HttpServletRequest request) + throws AccessDeniedException { Directory directory; - Plugin plugin = getPlugin( ); - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - directory = DirectoryHome.findByPrimaryKey( nIdDirectory, plugin ); + Plugin plugin = getPlugin(); + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + directory = DirectoryHome.findByPrimaryKey(nIdDirectory, plugin); - if ( ( directory == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_CHANGE_STATE, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((directory == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_CHANGE_STATE, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - directory.setEnabled( false ); - DirectoryHome.update( directory, getPlugin( ) ); + directory.setEnabled(false); + DirectoryHome.update(directory, getPlugin()); - return getJspManageDirectory( request ); + return getJspManageDirectory(request); } /** * Perform enable directory + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doEnableDirectory( HttpServletRequest request ) - throws AccessDeniedException - { + public String doEnableDirectory(HttpServletRequest request) + throws AccessDeniedException { Directory directory; - Plugin plugin = getPlugin( ); - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - directory = DirectoryHome.findByPrimaryKey( nIdDirectory, plugin ); + Plugin plugin = getPlugin(); + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + directory = DirectoryHome.findByPrimaryKey(nIdDirectory, plugin); - if ( ( directory == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_CHANGE_STATE, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((directory == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_CHANGE_STATE, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - directory.setEnabled( true ); - DirectoryHome.update( directory, getPlugin( ) ); + directory.setEnabled(true); + DirectoryHome.update(directory, getPlugin()); - return getJspManageDirectory( request ); + return getJspManageDirectory(request); } /** * Gets the field creation page + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return the field creation page */ - public String getCreateField( HttpServletRequest request ) - throws AccessDeniedException - { - Field field = new Field( ); - IEntry entry = EntryHome.findByPrimaryKey( _searchFields.getIdEntry( ), getPlugin( ) ); + public String getCreateField(HttpServletRequest request) + throws AccessDeniedException { + Field field = new Field(); + IEntry entry = EntryHome.findByPrimaryKey(_searchFields.getIdEntry(), getPlugin()); - if ( ( entry == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((entry == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - field.setEntry( entry ); + field.setEntry(entry); - Map model = new HashMap( ); - Locale locale = getLocale( ); - model.put( MARK_FIELD, field ); - model.put( MARK_USER_WORKGROUP_REF_LIST, AdminWorkgroupService.getUserWorkgroups( getUser( ), locale ) ); + Map model = new HashMap(); + Locale locale = getLocale(); + model.put(MARK_FIELD, field); + model.put(MARK_USER_WORKGROUP_REF_LIST, AdminWorkgroupService.getUserWorkgroups(getUser(), locale)); - if ( SecurityService.isAuthenticationEnable( ) ) - { - model.put( MARK_ROLE_REF_LIST, RoleHome.getRolesList( ) ); + if (SecurityService.isAuthenticationEnable()) { + model.put(MARK_ROLE_REF_LIST, RoleHome.getRolesList()); } - HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_CREATE_FIELD, locale, model ); - setPageTitleProperty( PROPERTY_CREATE_FIELD_PAGE_TITLE ); + HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_CREATE_FIELD, locale, model); + setPageTitleProperty(PROPERTY_CREATE_FIELD_PAGE_TITLE); - return getAdminPage( template.getHtml( ) ); + return getAdminPage(template.getHtml()); } /** * Gets the field modification page + * * @param request The HTTP request * @param bWithConditionalQuestion true if the field is associate to - * conditionals questions + * conditionals questions * @throws AccessDeniedException the {@link AccessDeniedException} * @return the field modification page */ - public String getModifyField( HttpServletRequest request, boolean bWithConditionalQuestion ) - throws AccessDeniedException - { + public String getModifyField(HttpServletRequest request, boolean bWithConditionalQuestion) + throws AccessDeniedException { Field field = null; IEntry entry = null; - Plugin plugin = getPlugin( ); - String strIdField = request.getParameter( PARAMETER_ID_FIELD ); - int nIdField = DirectoryUtils.convertStringToInt( strIdField ); - field = FieldHome.findByPrimaryKey( nIdField, getPlugin( ) ); + Plugin plugin = getPlugin(); + String strIdField = request.getParameter(PARAMETER_ID_FIELD); + int nIdField = DirectoryUtils.convertStringToInt(strIdField); + field = FieldHome.findByPrimaryKey(nIdField, getPlugin()); - if ( ( field == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((field == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - entry = EntryHome.findByPrimaryKey( field.getEntry( ).getIdEntry( ), plugin ); + entry = EntryHome.findByPrimaryKey(field.getEntry().getIdEntry(), plugin); - field.setEntry( entry ); + field.setEntry(entry); - Map model = new HashMap( ); - Locale locale = getLocale( ); - model.put( MARK_FIELD, field ); - model.put( MARK_USER_WORKGROUP_REF_LIST, AdminWorkgroupService.getUserWorkgroups( getUser( ), locale ) ); + Map model = new HashMap(); + Locale locale = getLocale(); + model.put(MARK_FIELD, field); + model.put(MARK_USER_WORKGROUP_REF_LIST, AdminWorkgroupService.getUserWorkgroups(getUser(), locale)); - if ( SecurityService.isAuthenticationEnable( ) ) - { - model.put( MARK_ROLE_REF_LIST, RoleHome.getRolesList( ) ); + if (SecurityService.isAuthenticationEnable()) { + model.put(MARK_ROLE_REF_LIST, RoleHome.getRolesList()); } - HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MODIFY_FIELD, locale, model ); - setPageTitleProperty( PROPERTY_MODIFY_FIELD_PAGE_TITLE ); + HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_MODIFY_FIELD, locale, model); + setPageTitleProperty(PROPERTY_MODIFY_FIELD_PAGE_TITLE); - return getAdminPage( template.getHtml( ) ); + return getAdminPage(template.getHtml()); } /** * Perform creation field + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doCreateField( HttpServletRequest request ) - throws AccessDeniedException - { - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, Integer.toString( _searchFields.getIdDirectory( ) ), - DirectoryResourceIdService.PERMISSION_MODIFY, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + public String doCreateField(HttpServletRequest request) + throws AccessDeniedException { + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, Integer.toString(_searchFields.getIdDirectory()), + DirectoryResourceIdService.PERMISSION_MODIFY, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - if ( request.getParameter( PARAMETER_CANCEL ) == null ) - { - IEntry entry = new Entry( ); - entry.setIdEntry( _searchFields.getIdEntry( ) ); + if (request.getParameter(PARAMETER_CANCEL) == null) { + IEntry entry = new Entry(); + entry.setIdEntry(_searchFields.getIdEntry()); - Field field = new Field( ); - field.setEntry( entry ); + Field field = new Field(); + field.setEntry(entry); - String strError = getFieldData( request, field ); + String strError = getFieldData(request, field); - if ( strError != null ) - { + if (strError != null) { return strError; } - FieldHome.create( field, getPlugin( ) ); + FieldHome.create(field, getPlugin()); } - return getJspModifyEntry( request, _searchFields.getIdEntry( ) ); + return getJspModifyEntry(request, _searchFields.getIdEntry()); } /** * Perform modification field + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doModifyField( HttpServletRequest request ) - throws AccessDeniedException - { - Plugin plugin = getPlugin( ); + public String doModifyField(HttpServletRequest request) + throws AccessDeniedException { + Plugin plugin = getPlugin(); Field field = null; - String strIdField = request.getParameter( PARAMETER_ID_FIELD ); - int nIdField = DirectoryUtils.convertStringToInt( strIdField ); - field = FieldHome.findByPrimaryKey( nIdField, plugin ); + String strIdField = request.getParameter(PARAMETER_ID_FIELD); + int nIdField = DirectoryUtils.convertStringToInt(strIdField); + field = FieldHome.findByPrimaryKey(nIdField, plugin); - if ( ( field == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((field == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - if ( request.getParameter( PARAMETER_CANCEL ) == null ) - { - String strError = getFieldData( request, field ); + if (request.getParameter(PARAMETER_CANCEL) == null) { + String strError = getFieldData(request, field); - if ( strError != null ) - { + if (strError != null) { return strError; } - FieldHome.update( field, getPlugin( ) ); + FieldHome.update(field, getPlugin()); } - if ( request.getParameter( PARAMETER_APPLY ) == null ) - { - return getJspModifyEntry( request, field.getEntry( ).getIdEntry( ) ); + if (request.getParameter(PARAMETER_APPLY) == null) { + return getJspModifyEntry(request, field.getEntry().getIdEntry()); } - return getJspModifyField( request, nIdField ); + return getJspModifyField(request, nIdField); } /** * Get the request data and if there is no error insert the data in the - * field specified in parameter. - * return null if there is no error or else return the error page url + * field specified in parameter. return null if there is no error or else + * return the error page url + * * @param request the request * @param field field * @return null if there is no error or else return the error page url */ - private String getFieldData( HttpServletRequest request, Field field ) - { - String strTitle = request.getParameter( PARAMETER_TITLE ); - String strValue = request.getParameter( PARAMETER_VALUE ); - String strDefaultValue = request.getParameter( PARAMETER_DEFAULT_VALUE ); + private String getFieldData(HttpServletRequest request, Field field) { + String strTitle = request.getParameter(PARAMETER_TITLE); + String strValue = request.getParameter(PARAMETER_VALUE); + String strDefaultValue = request.getParameter(PARAMETER_DEFAULT_VALUE); String strFieldError = DirectoryUtils.EMPTY_STRING; - if ( ( strTitle == null ) || DirectoryUtils.EMPTY_STRING.equals( strTitle ) ) - { + if ((strTitle == null) || DirectoryUtils.EMPTY_STRING.equals(strTitle)) { strFieldError = FIELD_TITLE_FIELD; - } - else if ( ( strValue == null ) || DirectoryUtils.EMPTY_STRING.equals( strValue ) ) - { + } else if ((strValue == null) || DirectoryUtils.EMPTY_STRING.equals(strValue)) { strFieldError = FIELD_VALUE_FIELD; - } - else if ( !StringUtil.checkCodeKey( strValue ) ) - { - return AdminMessageService.getMessageUrl( request, MESSAGE_FIELD_VALUE_FIELD, AdminMessage.TYPE_STOP ); + } else if (!StringUtil.checkCodeKey(strValue)) { + return AdminMessageService.getMessageUrl(request, MESSAGE_FIELD_VALUE_FIELD, AdminMessage.TYPE_STOP); } - String strRoleKey = request.getParameter( PARAMETER_ROLE_KEY ); - String strWorkgroupKey = request.getParameter( PARAMETER_WORKGROUP ); + String strRoleKey = request.getParameter(PARAMETER_ROLE_KEY); + String strWorkgroupKey = request.getParameter(PARAMETER_WORKGROUP); - if ( !strFieldError.equals( DirectoryUtils.EMPTY_STRING ) ) - { - Object[] tabRequiredFields = { I18nService.getLocalizedString( strFieldError, getLocale( ) ) }; + if (!strFieldError.equals(DirectoryUtils.EMPTY_STRING)) { + Object[] tabRequiredFields = {I18nService.getLocalizedString(strFieldError, getLocale())}; - return AdminMessageService.getMessageUrl( request, MESSAGE_MANDATORY_FIELD, tabRequiredFields, - AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_MANDATORY_FIELD, tabRequiredFields, + AdminMessage.TYPE_STOP); } - field.setTitle( strTitle ); - field.setValue( strValue ); - field.setDefaultValue( strDefaultValue != null ); - field.setRoleKey( strRoleKey ); - field.setWorkgroup( strWorkgroupKey ); + field.setTitle(strTitle); + field.setValue(strValue); + field.setDefaultValue(strDefaultValue != null); + field.setRoleKey(strRoleKey); + field.setWorkgroup(strWorkgroupKey); return null; // No error } /** * Gets the confirmation page of delete field + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return the confirmation page of delete field */ - public String getConfirmRemoveField( HttpServletRequest request ) - throws AccessDeniedException - { - if ( ( request.getParameter( PARAMETER_ID_FIELD ) == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); - } - - String strIdField = request.getParameter( PARAMETER_ID_FIELD ); - UrlItem url = new UrlItem( JSP_DO_REMOVE_FIELD ); - url.addParameter( PARAMETER_ID_FIELD, strIdField + "#list" ); - - return AdminMessageService.getMessageUrl( request, MESSAGE_CONFIRM_REMOVE_FIELD, url.getUrl( ), - AdminMessage.TYPE_CONFIRMATION ); + public String getConfirmRemoveField(HttpServletRequest request) + throws AccessDeniedException { + if ((request.getParameter(PARAMETER_ID_FIELD) == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); + } + + String strIdField = request.getParameter(PARAMETER_ID_FIELD); + UrlItem url = new UrlItem(JSP_DO_REMOVE_FIELD); + url.addParameter(PARAMETER_ID_FIELD, strIdField + "#list"); + + return AdminMessageService.getMessageUrl(request, MESSAGE_CONFIRM_REMOVE_FIELD, url.getUrl(), + AdminMessage.TYPE_CONFIRMATION); } /** * Perform suppression field + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doRemoveField( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdField = request.getParameter( PARAMETER_ID_FIELD ); - int nIdField = DirectoryUtils.convertStringToInt( strIdField ); + public String doRemoveField(HttpServletRequest request) + throws AccessDeniedException { + String strIdField = request.getParameter(PARAMETER_ID_FIELD); + int nIdField = DirectoryUtils.convertStringToInt(strIdField); - if ( ( nIdField == -1 ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((nIdField == -1) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - RecordFieldFilter recordFieldFilter = new RecordFieldFilter( ); - recordFieldFilter.setIdField( nIdField ); + RecordFieldFilter recordFieldFilter = new RecordFieldFilter(); + recordFieldFilter.setIdField(nIdField); - if ( ( RecordFieldHome.getCountRecordField( recordFieldFilter, getPlugin( ) ) != 0 ) ) - { - return AdminMessageService.getMessageUrl( request, MESSAGE_CANNOT_REMOVE_FIELD_DIRECTORY_IS_NOT_EMPTY, - AdminMessage.TYPE_STOP ); + if ((RecordFieldHome.getCountRecordField(recordFieldFilter, getPlugin()) != 0)) { + return AdminMessageService.getMessageUrl(request, MESSAGE_CANNOT_REMOVE_FIELD_DIRECTORY_IS_NOT_EMPTY, + AdminMessage.TYPE_STOP); } - FieldHome.remove( nIdField, getPlugin( ) ); + FieldHome.remove(nIdField, getPlugin()); - return getJspModifyEntry( request, _searchFields.getIdEntry( ) ); + return getJspModifyEntry(request, _searchFields.getIdEntry()); } /** * Move up the field + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doMoveUpField( HttpServletRequest request ) - throws AccessDeniedException - { - Plugin plugin = getPlugin( ); + public String doMoveUpField(HttpServletRequest request) + throws AccessDeniedException { + Plugin plugin = getPlugin(); List listField; Field field; - String strIdField = request.getParameter( PARAMETER_ID_FIELD ); - int nIdField = DirectoryUtils.convertStringToInt( strIdField ); - field = FieldHome.findByPrimaryKey( nIdField, plugin ); + String strIdField = request.getParameter(PARAMETER_ID_FIELD); + int nIdField = DirectoryUtils.convertStringToInt(strIdField); + field = FieldHome.findByPrimaryKey(nIdField, plugin); - if ( ( field == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((field == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - listField = FieldHome.getFieldListByIdEntry( field.getEntry( ).getIdEntry( ), plugin ); + listField = FieldHome.getFieldListByIdEntry(field.getEntry().getIdEntry(), plugin); - int nIndexField = DirectoryUtils.getIndexFieldInTheFieldList( nIdField, listField ); + int nIndexField = DirectoryUtils.getIndexFieldInTheFieldList(nIdField, listField); - if ( nIndexField != 0 ) - { + if (nIndexField != 0) { int nNewPosition; Field fieldToInversePosition; - fieldToInversePosition = listField.get( nIndexField - 1 ); - nNewPosition = fieldToInversePosition.getPosition( ); - fieldToInversePosition.setPosition( field.getPosition( ) ); - field.setPosition( nNewPosition ); - FieldHome.update( field, plugin ); - FieldHome.update( fieldToInversePosition, plugin ); + fieldToInversePosition = listField.get(nIndexField - 1); + nNewPosition = fieldToInversePosition.getPosition(); + fieldToInversePosition.setPosition(field.getPosition()); + field.setPosition(nNewPosition); + FieldHome.update(field, plugin); + FieldHome.update(fieldToInversePosition, plugin); } - return getJspModifyEntry( request, _searchFields.getIdEntry( ) ); + return getJspModifyEntry(request, _searchFields.getIdEntry()); } /** * Move down the field + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doMoveDownField( HttpServletRequest request ) - throws AccessDeniedException - { - Plugin plugin = getPlugin( ); + public String doMoveDownField(HttpServletRequest request) + throws AccessDeniedException { + Plugin plugin = getPlugin(); List listField; Field field; - String strIdField = request.getParameter( PARAMETER_ID_FIELD ); - int nIdField = DirectoryUtils.convertStringToInt( strIdField ); - field = FieldHome.findByPrimaryKey( nIdField, plugin ); + String strIdField = request.getParameter(PARAMETER_ID_FIELD); + int nIdField = DirectoryUtils.convertStringToInt(strIdField); + field = FieldHome.findByPrimaryKey(nIdField, plugin); - if ( ( field == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((field == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - listField = FieldHome.getFieldListByIdEntry( field.getEntry( ).getIdEntry( ), plugin ); + listField = FieldHome.getFieldListByIdEntry(field.getEntry().getIdEntry(), plugin); - int nIndexField = DirectoryUtils.getIndexFieldInTheFieldList( nIdField, listField ); + int nIndexField = DirectoryUtils.getIndexFieldInTheFieldList(nIdField, listField); - if ( nIndexField != ( listField.size( ) - 1 ) ) - { + if (nIndexField != (listField.size() - 1)) { int nNewPosition; Field fieldToInversePosition; - fieldToInversePosition = listField.get( nIndexField + 1 ); - nNewPosition = fieldToInversePosition.getPosition( ); - fieldToInversePosition.setPosition( field.getPosition( ) ); - field.setPosition( nNewPosition ); - FieldHome.update( field, plugin ); - FieldHome.update( fieldToInversePosition, plugin ); + fieldToInversePosition = listField.get(nIndexField + 1); + nNewPosition = fieldToInversePosition.getPosition(); + fieldToInversePosition.setPosition(field.getPosition()); + field.setPosition(nNewPosition); + FieldHome.update(field, plugin); + FieldHome.update(fieldToInversePosition, plugin); } - return getJspModifyEntry( request, _searchFields.getIdEntry( ) ); + return getJspModifyEntry(request, _searchFields.getIdEntry()); } /** * Delete association between field and regular expression + * * @param request the Http Request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doRemoveRegularExpression( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdExpression = request.getParameter( PARAMETER_ID_EXPRESSION ); - String strIdField = request.getParameter( PARAMETER_ID_FIELD ); - int nIdField = DirectoryUtils.convertStringToInt( strIdField ); - int nIdExpression = DirectoryUtils.convertStringToInt( strIdExpression ); + public String doRemoveRegularExpression(HttpServletRequest request) + throws AccessDeniedException { + String strIdExpression = request.getParameter(PARAMETER_ID_EXPRESSION); + String strIdField = request.getParameter(PARAMETER_ID_FIELD); + int nIdField = DirectoryUtils.convertStringToInt(strIdField); + int nIdExpression = DirectoryUtils.convertStringToInt(strIdExpression); - if ( ( nIdExpression == DirectoryUtils.CONSTANT_ID_NULL ) || ( nIdField == DirectoryUtils.CONSTANT_ID_NULL ) || - ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((nIdExpression == DirectoryUtils.CONSTANT_ID_NULL) || (nIdField == DirectoryUtils.CONSTANT_ID_NULL) + || (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser()))) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - FieldHome.removeVerifyBy( nIdField, nIdExpression, getPlugin( ) ); + FieldHome.removeVerifyBy(nIdField, nIdExpression, getPlugin()); - return getJspModifyEntry( request, _searchFields.getIdEntry( ) ); + return getJspModifyEntry(request, _searchFields.getIdEntry()); } /** * insert association between field and regular expression + * * @param request the Http Request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doInsertRegularExpression( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdExpression = request.getParameter( PARAMETER_ID_EXPRESSION ); - String strIdField = request.getParameter( PARAMETER_ID_FIELD ); - int nIdField = DirectoryUtils.convertStringToInt( strIdField ); - int nIdExpression = DirectoryUtils.convertStringToInt( strIdExpression ); + public String doInsertRegularExpression(HttpServletRequest request) + throws AccessDeniedException { + String strIdExpression = request.getParameter(PARAMETER_ID_EXPRESSION); + String strIdField = request.getParameter(PARAMETER_ID_FIELD); + int nIdField = DirectoryUtils.convertStringToInt(strIdField); + int nIdExpression = DirectoryUtils.convertStringToInt(strIdExpression); - if ( ( nIdExpression == DirectoryUtils.CONSTANT_ID_NULL ) || ( nIdField == DirectoryUtils.CONSTANT_ID_NULL ) || - ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( _searchFields.getIdDirectory( ) ), DirectoryResourceIdService.PERMISSION_MODIFY, - getUser( ) ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((nIdExpression == DirectoryUtils.CONSTANT_ID_NULL) || (nIdField == DirectoryUtils.CONSTANT_ID_NULL) + || (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(_searchFields.getIdDirectory()), DirectoryResourceIdService.PERMISSION_MODIFY, + getUser()))) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - FieldHome.createVerifyBy( nIdField, nIdExpression, getPlugin( ) ); + FieldHome.createVerifyBy(nIdField, nIdExpression, getPlugin()); - return getJspModifyEntry( request, _searchFields.getIdEntry( ) ); + return getJspModifyEntry(request, _searchFields.getIdEntry()); } /** * Get the map query and return on manage directory record + * * @param request the Http Request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action * @deprecated Use fr.paris.lutece.plugins.directory.web.action. - * SearchRecordDirectoryAction instead + * SearchRecordDirectoryAction instead */ @Deprecated - public String doSearchDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { - AppLogService.error( - "Calling doSearchDirectoryRecord which no longer work. Use fr.paris.lutece.plugins.directory.web.action.SearchRecordDirectoryAction instead." ); + public String doSearchDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { + AppLogService.error( + "Calling doSearchDirectoryRecord which no longer work. Use fr.paris.lutece.plugins.directory.web.action.SearchRecordDirectoryAction instead."); return null; } /** * Return management of directory record ( list of directory record ). + * * @param request The Http request * @param response the Http response * @throws AccessDeniedException the {@link AccessDeniedException} * @return IPluginActionResult */ - public IPluginActionResult getManageDirectoryRecord( HttpServletRequest request, HttpServletResponse response ) - throws AccessDeniedException - { + public IPluginActionResult getManageDirectoryRecord(HttpServletRequest request, HttpServletResponse response) + throws AccessDeniedException { + String strExtentCurrent = request.getParameter(MARK_EXTENT_CURRENT) == null ? "" : request.getParameter(MARK_EXTENT_CURRENT); + String strVisibleLayer = request.getParameter(MARK_VISIBLE_LAYER) == null ? "" : request.getParameter(MARK_VISIBLE_LAYER); + + HttpSession session = request.getSession(false); + + if (!strExtentCurrent.isEmpty() && !strVisibleLayer.isEmpty()) { + session.setAttribute(MARK_EXTENT_CURRENT, strExtentCurrent); + session.setAttribute(MARK_VISIBLE_LAYER, strVisibleLayer); + } + // fill the selected records - String[] selectedRecords = request.getParameterValues( PARAMETER_SELECTED_RECORD ); + String[] selectedRecords = request.getParameterValues(PARAMETER_SELECTED_RECORD); List listSelectedRecords; - if ( selectedRecords != null ) - { - listSelectedRecords = Arrays.asList( selectedRecords ); + if (selectedRecords != null) { + listSelectedRecords = Arrays.asList(selectedRecords); - if ( AppLogService.isDebugEnabled( ) ) - { - AppLogService.debug( "List selected record : " + listSelectedRecords ); + if (AppLogService.isDebugEnabled()) { + AppLogService.debug("List selected record : " + listSelectedRecords); } - } - else - { - listSelectedRecords = new ArrayList( ); + } else { + listSelectedRecords = new ArrayList(); } - _searchFields.setSelectedRecords( listSelectedRecords ); + _searchFields.setSelectedRecords(listSelectedRecords); // first - see if there is an invoked action - IDirectoryAction action = PluginActionManager.getPluginAction( request, IDirectoryAction.class ); + IDirectoryAction action = PluginActionManager.getPluginAction(request, IDirectoryAction.class); - if ( action != null ) - { - if ( AppLogService.isDebugEnabled( ) ) - { - AppLogService.debug( "Processing directory action " + action.getName( ) ); + if (action != null) { + if (AppLogService.isDebugEnabled()) { + AppLogService.debug("Processing directory action " + action.getName()); } - return action.process( request, response, getUser( ), _searchFields ); + return action.process(request, response, getUser(), _searchFields); } // display could have been an action but it's the default one an will always be here... - DefaultPluginActionResult result = new DefaultPluginActionResult( ); - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - boolean bWorkflowServiceEnable = WorkflowService.getInstance( ).isAvailable( ); - AdminUser adminUser = getUser( ); - Directory directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); + DefaultPluginActionResult result = new DefaultPluginActionResult(); + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + boolean bWorkflowServiceEnable = WorkflowService.getInstance().isAvailable(); + AdminUser adminUser = getUser(); + Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); - if ( ( directory == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_MANAGE_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((directory == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_MANAGE_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - if ( ( request.getParameter( PARAMETER_SESSION ) == null ) || - Boolean.parseBoolean( request.getParameter( PARAMETER_RESET_SEARCH ) ) ) - { - reInitDirectoryRecordFilter( ); + if ((request.getParameter(PARAMETER_SESSION) == null) + || Boolean.parseBoolean(request.getParameter(PARAMETER_RESET_SEARCH))) { + reInitDirectoryRecordFilter(); } - _searchFields.setRedirectUrl( request ); - _searchFields.setCurrentPageIndexDirectoryRecord( Paginator.getPageIndex( request, - Paginator.PARAMETER_PAGE_INDEX, _searchFields.getCurrentPageIndexDirectoryRecord( ) ) ); - _searchFields.setItemsPerPageDirectoryRecord( Paginator.getItemsPerPage( request, - Paginator.PARAMETER_ITEMS_PER_PAGE, _searchFields.getItemsPerPageDirectoryRecord( ), - _searchFields.getDefaultItemsPerPage( ) ) ); + _searchFields.setRedirectUrl(request); + _searchFields.setCurrentPageIndexDirectoryRecord(Paginator.getPageIndex(request, + Paginator.PARAMETER_PAGE_INDEX, _searchFields.getCurrentPageIndexDirectoryRecord())); + _searchFields.setItemsPerPageDirectoryRecord(Paginator.getItemsPerPage(request, + Paginator.PARAMETER_ITEMS_PER_PAGE, _searchFields.getItemsPerPageDirectoryRecord(), + _searchFields.getDefaultItemsPerPage())); //build entryFilter - EntryFilter entryFilter = new EntryFilter( ); - entryFilter.setIdDirectory( directory.getIdDirectory( ) ); - entryFilter.setIsGroup( EntryFilter.FILTER_FALSE ); - entryFilter.setIsComment( EntryFilter.FILTER_FALSE ); - - List listEntryFormMainSearch = new ArrayList( ); - List listEntryFormComplementarySearch = new ArrayList( ); - List listEntryResultSearch = new ArrayList( ); - List listEntryGeolocation = new ArrayList( ); - - for ( IEntry entry : EntryHome.getEntryList( entryFilter, getPlugin( ) ) ) - { - IEntry entryTmp = EntryHome.findByPrimaryKey( entry.getIdEntry( ), getPlugin( ) ); - - if ( entryTmp.isWorkgroupAssociated( ) ) - { - entryTmp.setFields( DirectoryUtils.getAuthorizedFieldsByWorkgroup( entryTmp.getFields( ), getUser( ) ) ); + EntryFilter entryFilter = new EntryFilter(); + entryFilter.setIdDirectory(directory.getIdDirectory()); + entryFilter.setIsGroup(EntryFilter.FILTER_FALSE); + entryFilter.setIsComment(EntryFilter.FILTER_FALSE); + + List listEntryFormMainSearch = new ArrayList(); + List listEntryFormComplementarySearch = new ArrayList(); + List listEntryResultSearch = new ArrayList(); + List listEntryGeolocation = new ArrayList(); + + for (IEntry entry : EntryHome.getEntryList(entryFilter, getPlugin())) { + IEntry entryTmp = EntryHome.findByPrimaryKey(entry.getIdEntry(), getPlugin()); + + if (entryTmp.isWorkgroupAssociated()) { + entryTmp.setFields(DirectoryUtils.getAuthorizedFieldsByWorkgroup(entryTmp.getFields(), getUser())); } - if ( entryTmp.isIndexed( ) ) - { - if ( !entryTmp.isShownInAdvancedSearch( ) ) - { - listEntryFormMainSearch.add( entryTmp ); - } - else - { - listEntryFormComplementarySearch.add( entryTmp ); + if (entryTmp.isIndexed()) { + if (!entryTmp.isShownInAdvancedSearch()) { + listEntryFormMainSearch.add(entryTmp); + } else { + listEntryFormComplementarySearch.add(entryTmp); } } - if ( entry.isShownInResultList( ) ) - { - listEntryResultSearch.add( entryTmp ); + if (entry.isShownInResultList()) { + listEntryResultSearch.add(entryTmp); // add geolocation entries - if ( entry.getEntryType( ).getIdType( ) == AppPropertiesService.getPropertyInt( - PROPERTY_ENTRY_TYPE_GEOLOCATION, 16 ) ) - { - listEntryGeolocation.add( entry ); + if (entry.getEntryType().getIdType() == AppPropertiesService.getPropertyInt( + PROPERTY_ENTRY_TYPE_GEOLOCATION, 16)) { + listEntryGeolocation.add(entry); } } } - _searchFields.setSortParameters( request, directory, getPlugin( ) ); + _searchFields.setSortParameters(request, directory, getPlugin()); - List listResultRecordId = DirectoryUtils.getListResults( request, directory, bWorkflowServiceEnable, - true, _searchFields, getUser( ), getLocale( ) ); + List listResultRecordId = DirectoryUtils.getListResults(request, directory, bWorkflowServiceEnable, + true, _searchFields, getUser(), getLocale()); // Store the list of id records in session - _searchFields.setListIdsResultRecord( listResultRecordId ); + _searchFields.setListIdsResultRecord(listResultRecordId); // HACK : We copy the list so workflow does not clear the paginator list. - LocalizedPaginator paginator = new LocalizedPaginator( new ArrayList( - listResultRecordId ), _searchFields.getItemsPerPageDirectoryRecord( ), - DirectoryUtils.getJspManageDirectoryRecord( request, nIdDirectory ), PARAMETER_PAGE_INDEX, - _searchFields.getCurrentPageIndexDirectoryRecord( ), getLocale( ) ); + LocalizedPaginator paginator = new LocalizedPaginator(new ArrayList( + listResultRecordId), _searchFields.getItemsPerPageDirectoryRecord(), + DirectoryUtils.getJspManageDirectoryRecord(request, nIdDirectory), PARAMETER_PAGE_INDEX, + _searchFields.getCurrentPageIndexDirectoryRecord(), getLocale()); // get only record for page items. - List lRecord = _recordService.loadListByListId( paginator.getPageItems( ), getPlugin( ) ); + List lRecord = _recordService.loadListByListId(paginator.getPageItems(), getPlugin()); - boolean bHistoryEnabled = WorkflowService.getInstance( ).isAvailable( ) && - ( directory.getIdWorkflow( ) != DirectoryUtils.CONSTANT_ID_NULL ); - RecordFieldFilter recordFieldFilter = new RecordFieldFilter( ); - recordFieldFilter.setIsEntryShownInResultList( RecordFieldFilter.FILTER_TRUE ); + boolean bHistoryEnabled = WorkflowService.getInstance().isAvailable() + && (directory.getIdWorkflow() != DirectoryUtils.CONSTANT_ID_NULL); + RecordFieldFilter recordFieldFilter = new RecordFieldFilter(); + recordFieldFilter.setIsEntryShownInResultList(RecordFieldFilter.FILTER_TRUE); - bWorkflowServiceEnable = ( directory.getIdWorkflow( ) != DirectoryUtils.CONSTANT_ID_NULL ) && - bWorkflowServiceEnable; + bWorkflowServiceEnable = (directory.getIdWorkflow() != DirectoryUtils.CONSTANT_ID_NULL) + && bWorkflowServiceEnable; - List> listResourceActions = new ArrayList>( lRecord.size( ) ); + List> listResourceActions = new ArrayList>(lRecord.size()); - List listActionsForDirectoryEnable = DirectoryActionHome.selectActionsRecordByFormState( Directory.STATE_ENABLE, - getPlugin( ), getLocale( ) ); - List listActionsForDirectoryDisable = DirectoryActionHome.selectActionsRecordByFormState( Directory.STATE_DISABLE, - getPlugin( ), getLocale( ) ); + List listActionsForDirectoryEnable = DirectoryActionHome.selectActionsRecordByFormState(Directory.STATE_ENABLE, + getPlugin(), getLocale()); + List listActionsForDirectoryDisable = DirectoryActionHome.selectActionsRecordByFormState(Directory.STATE_DISABLE, + getPlugin(), getLocale()); - listActionsForDirectoryEnable = (List) RBACService.getAuthorizedActionsCollection( listActionsForDirectoryEnable, - directory, getUser( ) ); - listActionsForDirectoryDisable = (List) RBACService.getAuthorizedActionsCollection( listActionsForDirectoryDisable, - directory, getUser( ) ); + listActionsForDirectoryEnable = (List) RBACService.getAuthorizedActionsCollection(listActionsForDirectoryEnable, + directory, getUser()); + listActionsForDirectoryDisable = (List) RBACService.getAuthorizedActionsCollection(listActionsForDirectoryDisable, + directory, getUser()); // Get asynchronous file names put at false for better performance // since it must call a webservice to get the file name boolean bGetFileName = false; - for ( Record record : lRecord ) - { - listResourceActions.add( DirectoryService.getInstance( ) - .getResourceAction( record, directory, listEntryResultSearch, - adminUser, listActionsForDirectoryEnable, listActionsForDirectoryDisable, bGetFileName, - getPlugin( ) ) ); - } - - Map model = new HashMap( ); - - model.put( MARK_SHOW_DATE_CREATION_RESULT, directory.isDateShownInResultList( ) ); - model.put( MARK_SHOW_DATE_MODIFICATION_RESULT, directory.isDateModificationShownInResultList( ) ); - model.put( MARK_ID_ENTRY_TYPE_IMAGE, AppPropertiesService.getPropertyInt( PROPERTY_ENTRY_TYPE_IMAGE, 10 ) ); - model.put( MARK_ID_ENTRY_TYPE_DIRECTORY, - AppPropertiesService.getPropertyInt( PROPERTY_ENTRY_TYPE_DIRECTORY, 12 ) ); - model.put( MARK_ID_ENTRY_TYPE_GEOLOCATION, - AppPropertiesService.getPropertyInt( PROPERTY_ENTRY_TYPE_GEOLOCATION, 16 ) ); - model.put( MARK_ID_ENTRY_TYPE_MYLUTECE_USER, - AppPropertiesService.getPropertyInt( PROPERTY_ENTRY_TYPE_MYLUTECE_USER, 19 ) ); - model.put( MARK_ID_ENTRY_TYPE_NUMBERING, - AppPropertiesService.getPropertyInt( PROPERTY_ENTRY_TYPE_NUMBERING, 11 ) ); - model.put( MARK_ENTRY_LIST_GEOLOCATION, listEntryGeolocation ); - model.put( MARK_WORKFLOW_STATE_SEARCH_DEFAULT, _searchFields.get_nIdWorkflowSate( ) ); - model.put( MARK_PAGINATOR, paginator ); - model.put( MARK_NB_ITEMS_PER_PAGE, Integer.toString( _searchFields.getItemsPerPageDirectoryRecord( ) ) ); - model.put( MARK_ENTRY_LIST_FORM_MAIN_SEARCH, listEntryFormMainSearch ); - model.put( MARK_ENTRY_LIST_FORM_COMPLEMENTARY_SEARCH, listEntryFormComplementarySearch ); - model.put( MARK_ENTRY_LIST_SEARCH_RESULT, listEntryResultSearch ); - - model.put( MARK_MAP_ID_ENTRY_LIST_RECORD_FIELD, _searchFields.getMapQuery( ) ); - model.put( MARK_DATE_CREATION_SEARCH, _searchFields.getDateCreationRecord( ) ); - model.put( MARK_DATE_CREATION_BEGIN_SEARCH, _searchFields.getDateCreationBeginRecord( ) ); - model.put( MARK_DATE_CREATION_END_SEARCH, _searchFields.getDateCreationEndRecord( ) ); - model.put( MARK_DATE_MODIFICATION_SEARCH, _searchFields.getDateModificationRecord( ) ); - model.put( MARK_DATE_MODIFICATION_BEGIN_SEARCH, _searchFields.getDateModificationBeginRecord( ) ); - model.put( MARK_DATE_MODIFICATION_END_SEARCH, _searchFields.getDateModificationEndRecord( ) ); - - model.put( MARK_DIRECTORY, directory ); + for (Record record : lRecord) { + listResourceActions.add(DirectoryService.getInstance() + .getResourceAction(record, directory, listEntryResultSearch, + adminUser, listActionsForDirectoryEnable, listActionsForDirectoryDisable, bGetFileName, + getPlugin())); + } + + Map model = new HashMap(); + + model.put(MARK_SHOW_DATE_CREATION_RESULT, directory.isDateShownInResultList()); + model.put(MARK_SHOW_DATE_MODIFICATION_RESULT, directory.isDateModificationShownInResultList()); + model.put(MARK_ID_ENTRY_TYPE_IMAGE, AppPropertiesService.getPropertyInt(PROPERTY_ENTRY_TYPE_IMAGE, 10)); + model.put(MARK_ID_ENTRY_TYPE_DIRECTORY, + AppPropertiesService.getPropertyInt(PROPERTY_ENTRY_TYPE_DIRECTORY, 12)); + model.put(MARK_ID_ENTRY_TYPE_GEOLOCATION, + AppPropertiesService.getPropertyInt(PROPERTY_ENTRY_TYPE_GEOLOCATION, 16)); + model.put(MARK_ID_ENTRY_TYPE_MYLUTECE_USER, + AppPropertiesService.getPropertyInt(PROPERTY_ENTRY_TYPE_MYLUTECE_USER, 19)); + model.put(MARK_ID_ENTRY_TYPE_NUMBERING, + AppPropertiesService.getPropertyInt(PROPERTY_ENTRY_TYPE_NUMBERING, 11)); + model.put(MARK_ENTRY_LIST_GEOLOCATION, listEntryGeolocation); + model.put(MARK_WORKFLOW_STATE_SEARCH_DEFAULT, _searchFields.get_nIdWorkflowSate()); + model.put(MARK_PAGINATOR, paginator); + model.put(MARK_NB_ITEMS_PER_PAGE, Integer.toString(_searchFields.getItemsPerPageDirectoryRecord())); + model.put(MARK_ENTRY_LIST_FORM_MAIN_SEARCH, listEntryFormMainSearch); + model.put(MARK_ENTRY_LIST_FORM_COMPLEMENTARY_SEARCH, listEntryFormComplementarySearch); + model.put(MARK_ENTRY_LIST_SEARCH_RESULT, listEntryResultSearch); + + model.put(MARK_MAP_ID_ENTRY_LIST_RECORD_FIELD, _searchFields.getMapQuery()); + model.put(MARK_DATE_CREATION_SEARCH, _searchFields.getDateCreationRecord()); + model.put(MARK_DATE_CREATION_BEGIN_SEARCH, _searchFields.getDateCreationBeginRecord()); + model.put(MARK_DATE_CREATION_END_SEARCH, _searchFields.getDateCreationEndRecord()); + model.put(MARK_DATE_MODIFICATION_SEARCH, _searchFields.getDateModificationRecord()); + model.put(MARK_DATE_MODIFICATION_BEGIN_SEARCH, _searchFields.getDateModificationBeginRecord()); + model.put(MARK_DATE_MODIFICATION_END_SEARCH, _searchFields.getDateModificationEndRecord()); + + model.put(MARK_DIRECTORY, directory); //model.put( MARK_DIRECTORY_RECORD_LIST, listRecordResult ); //model.put( MARK_NUMBER_RECORD, paginator.getItemsCount( ) ); - model.put( MARK_NUMBER_RECORD, listResultRecordId.size( ) ); - model.put( MARK_RESOURCE_ACTIONS_LIST, listResourceActions ); - model.put( MARK_HISTORY_WORKFLOW_ENABLED, bHistoryEnabled ); - model.put( MARK_PERMISSION_CREATE_RECORD, - RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_CREATE_RECORD, getUser( ) ) ); - model.put( MARK_PERMISSION_MASS_PRINT, - RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_MASS_PRINT, getUser( ) ) ); - model.put( MARK_PERMISSION_VISUALISATION_MYLUTECE_USER, - RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_VISUALISATION_MYLUTECE_USER, getUser( ) ) ); - - model.put( MARK_LOCALE, getLocale( ) ); - model.put( MARK_IS_WORKFLOW_ENABLED, bWorkflowServiceEnable ); - - if ( directory.isDisplayComplementarySearchState( ) || directory.isDisplaySearchState( ) ) - { - ReferenceList referenceList = new ReferenceList( ); - referenceList.addItem( -1, "" ); - - Collection colState = WorkflowService.getInstance( ) - .getAllStateByWorkflow( directory.getIdWorkflow( ), adminUser ); - - if ( colState != null ) - { - for ( State stateWorkflow : colState ) - { - referenceList.addItem( stateWorkflow.getId( ), stateWorkflow.getName( ) ); + model.put(MARK_NUMBER_RECORD, listResultRecordId.size()); + model.put(MARK_RESOURCE_ACTIONS_LIST, listResourceActions); + model.put(MARK_HISTORY_WORKFLOW_ENABLED, bHistoryEnabled); + model.put(MARK_PERMISSION_CREATE_RECORD, + RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_CREATE_RECORD, getUser())); + model.put(MARK_PERMISSION_MASS_PRINT, + RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_MASS_PRINT, getUser())); + model.put(MARK_PERMISSION_VISUALISATION_MYLUTECE_USER, + RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_VISUALISATION_MYLUTECE_USER, getUser())); + + model.put(MARK_LOCALE, getLocale()); + model.put(MARK_IS_WORKFLOW_ENABLED, bWorkflowServiceEnable); + model.put(MARK_WEBAPP_URL, AppPathService.getBaseUrl(request)); + + model.put(MARK_EXTENT_CURRENT, session.getAttribute(MARK_EXTENT_CURRENT)); + model.put(MARK_VISIBLE_LAYER, session.getAttribute(MARK_VISIBLE_LAYER)); + + if (directory.isDisplayComplementarySearchState() || directory.isDisplaySearchState()) { + ReferenceList referenceList = new ReferenceList(); + referenceList.addItem(-1, ""); + + Collection colState = WorkflowService.getInstance() + .getAllStateByWorkflow(directory.getIdWorkflow(), adminUser); + + if (colState != null) { + for (State stateWorkflow : colState) { + referenceList.addItem(stateWorkflow.getId(), stateWorkflow.getName()); } } - model.put( MARK_SEARCH_STATE_WORKFLOW, referenceList ); + model.put(MARK_SEARCH_STATE_WORKFLOW, referenceList); } - PluginActionManager.fillModel( request, adminUser, model, IDirectoryAction.class, MARK_DIRECTORY_ACTIONS ); + PluginActionManager.fillModel(request, adminUser, model, IDirectoryAction.class, MARK_DIRECTORY_ACTIONS); - setPageTitleProperty( PROPERTY_MANAGE_DIRECTORY_RECORD_PAGE_TITLE ); + setPageTitleProperty(PROPERTY_MANAGE_DIRECTORY_RECORD_PAGE_TITLE); - HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_MANAGE_DIRECTORY_RECORD, getLocale( ), - model ); + HtmlTemplate templateList = AppTemplateService.getTemplate(TEMPLATE_MANAGE_DIRECTORY_RECORD, getLocale(), + model); - result.setHtmlContent( getAdminPage( templateList.getHtml( ) ) ); + result.setHtmlContent(getAdminPage(templateList.getHtml())); return result; } /** * Export Directory record + * * @param request the Http Request * @param response the Http response * @throws AccessDeniedException the {@link AccessDeniedException} - * @deprecated use - * fr.paris.lutece.plugins.directory.web.action. - * ExportDirectoryAction - * instead + * @deprecated use fr.paris.lutece.plugins.directory.web.action. + * ExportDirectoryAction instead */ @Deprecated - public void doExportDirectoryRecord( HttpServletRequest request, HttpServletResponse response ) - throws AccessDeniedException - { - AppLogService.error( - "Calling doExportDirectoryRecord which no longer work. Use fr.paris.lutece.plugins.directory.web.action.ExportDirectoryAction instead." ); + public void doExportDirectoryRecord(HttpServletRequest request, HttpServletResponse response) + throws AccessDeniedException { + AppLogService.error( + "Calling doExportDirectoryRecord which no longer work. Use fr.paris.lutece.plugins.directory.web.action.ExportDirectoryAction instead."); } /** * Return the interface for import directory record + * * @param request The Http request * @throws AccessDeniedException the {@link AccessDeniedException} * @return Html directory * */ - public String getImportDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); + public String getImportDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - Directory directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); - if ( ( directory == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_IMPORT_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((directory == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_IMPORT_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - Map model = new HashMap( ); + Map model = new HashMap(); - if ( request.getParameter( PARAMETER_SESSION ) != null ) - { - if ( _searchFields.getError( ) != null ) - { - model.put( MARK_STR_ERROR, _searchFields.getError( ).toString( ) ); + if (request.getParameter(PARAMETER_SESSION) != null) { + if (_searchFields.getError() != null) { + model.put(MARK_STR_ERROR, _searchFields.getError().toString()); } - model.put( MARK_NUMBER_LINES_ERROR, _searchFields.getCountLineFailure( ) ); - model.put( MARK_NUMBER_LINES_IMPORTED, - _searchFields.getCountLine( ) - _searchFields.getCountLineFailure( ) ); - model.put( MARK_FINISH_IMPORT, true ); - _searchFields.setCountLine( 0 ); - _searchFields.setCountLineFailure( 0 ); - _searchFields.setError( null ); + model.put(MARK_NUMBER_LINES_ERROR, _searchFields.getCountLineFailure()); + model.put(MARK_NUMBER_LINES_IMPORTED, + _searchFields.getCountLine() - _searchFields.getCountLineFailure()); + model.put(MARK_FINISH_IMPORT, true); + _searchFields.setCountLine(0); + _searchFields.setCountLineFailure(0); + _searchFields.setError(null); } - model.put( MARK_LOCALE, getLocale( ) ); - model.put( MARK_DIRECTORY, directory ); - setPageTitleProperty( PROPERTY_IMPORT_DIRECTORY_RECORD_PAGE_TITLE ); + model.put(MARK_LOCALE, getLocale()); + model.put(MARK_DIRECTORY, directory); + setPageTitleProperty(PROPERTY_IMPORT_DIRECTORY_RECORD_PAGE_TITLE); - HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_IMPORT_DIRECTORY_RECORD, getLocale( ), - model ); + HtmlTemplate templateList = AppTemplateService.getTemplate(TEMPLATE_IMPORT_DIRECTORY_RECORD, getLocale(), + model); - return getAdminPage( templateList.getHtml( ) ); + return getAdminPage(templateList.getHtml()); } /** * ImportDirectory record + * * @param request the Http Request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doImportDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { + public String doImportDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; - FileItem fileItem = multipartRequest.getFile( PARAMETER_FILE_IMPORT ); - String strMimeType = FileSystemUtil.getMIMEType( FileUploadService.getFileNameOnly( fileItem ) ); + FileItem fileItem = multipartRequest.getFile(PARAMETER_FILE_IMPORT); + String strMimeType = FileSystemUtil.getMIMEType(FileUploadService.getFileNameOnly(fileItem)); - if ( ( fileItem == null ) || ( fileItem.getName( ) == null ) || - DirectoryUtils.EMPTY_STRING.equals( fileItem.getName( ) ) ) - { - Object[] tabRequiredFields = { I18nService.getLocalizedString( FIELD_FILE_IMPORT, getLocale( ) ) }; + if ((fileItem == null) || (fileItem.getName() == null) + || DirectoryUtils.EMPTY_STRING.equals(fileItem.getName())) { + Object[] tabRequiredFields = {I18nService.getLocalizedString(FIELD_FILE_IMPORT, getLocale())}; - return AdminMessageService.getMessageUrl( request, MESSAGE_MANDATORY_FIELD, tabRequiredFields, - AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_MANDATORY_FIELD, tabRequiredFields, + AdminMessage.TYPE_STOP); } - if ( ( !strMimeType.equals( CONSTANT_MIME_TYPE_CSV ) && !strMimeType.equals( CONSTANT_MIME_TYPE_OCTETSTREAM ) && - !strMimeType.equals( CONSTANT_MIME_TYPE_TEXT_CSV ) ) || - !fileItem.getName( ).toLowerCase( ).endsWith( CONSTANT_EXTENSION_CSV_FILE ) ) - { - return AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_CSV_FILE_IMPORT, AdminMessage.TYPE_STOP ); + if ((!strMimeType.equals(CONSTANT_MIME_TYPE_CSV) && !strMimeType.equals(CONSTANT_MIME_TYPE_OCTETSTREAM) + && !strMimeType.equals(CONSTANT_MIME_TYPE_TEXT_CSV)) + || !fileItem.getName().toLowerCase().endsWith(CONSTANT_EXTENSION_CSV_FILE)) { + return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_CSV_FILE_IMPORT, AdminMessage.TYPE_STOP); } - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - Directory directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); - if ( ( directory == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_MANAGE_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((directory == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_MANAGE_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - Character strCsvSeparator = AppPropertiesService.getProperty( PROPERTY_IMPORT_CSV_DELIMITER ).charAt( 0 ); - _searchFields.setError( new StringBuffer( ) ); + Character strCsvSeparator = AppPropertiesService.getProperty(PROPERTY_IMPORT_CSV_DELIMITER).charAt(0); + _searchFields.setError(new StringBuffer()); - EntryFilter filter = new EntryFilter( ); - filter.setIdDirectory( nIdDirectory ); - filter.setIsComment( EntryFilter.FILTER_FALSE ); - filter.setIsEntryParentNull( EntryFilter.FILTER_TRUE ); + EntryFilter filter = new EntryFilter(); + filter.setIdDirectory(nIdDirectory); + filter.setIsComment(EntryFilter.FILTER_FALSE); + filter.setIsEntryParentNull(EntryFilter.FILTER_TRUE); - List listEntry = new ArrayList( ); + List listEntry = new ArrayList(); - List listEntryFirstLevel = EntryHome.getEntryList( filter, getPlugin( ) ); + List listEntryFirstLevel = EntryHome.getEntryList(filter, getPlugin()); - filter.setIsEntryParentNull( EntryFilter.ALL_INT ); + filter.setIsEntryParentNull(EntryFilter.ALL_INT); - for ( IEntry entry : listEntryFirstLevel ) - { - if ( !entry.getEntryType( ).getGroup( ) ) - { - listEntry.add( EntryHome.findByPrimaryKey( entry.getIdEntry( ), getPlugin( ) ) ); + for (IEntry entry : listEntryFirstLevel) { + if (!entry.getEntryType().getGroup()) { + listEntry.add(EntryHome.findByPrimaryKey(entry.getIdEntry(), getPlugin())); } - filter.setIdEntryParent( entry.getIdEntry( ) ); + filter.setIdEntryParent(entry.getIdEntry()); - List listChildren = EntryHome.getEntryList( filter, getPlugin( ) ); + List listChildren = EntryHome.getEntryList(filter, getPlugin()); - for ( IEntry entryChild : listChildren ) - { - listEntry.add( EntryHome.findByPrimaryKey( entryChild.getIdEntry( ), getPlugin( ) ) ); + for (IEntry entryChild : listChildren) { + listEntry.add(EntryHome.findByPrimaryKey(entryChild.getIdEntry(), getPlugin())); } } - Object[] tabEntry = listEntry.toArray( ); + Object[] tabEntry = listEntry.toArray(); - try - { - InputStreamReader inputStreamReader = new InputStreamReader( fileItem.getInputStream( ) ); - CSVReader csvReader = new CSVReader( inputStreamReader, strCsvSeparator, '\"' ); + try { + InputStreamReader inputStreamReader = new InputStreamReader(fileItem.getInputStream()); + CSVReader csvReader = new CSVReader(inputStreamReader, strCsvSeparator, '\"'); String[] nextLine; - _searchFields.setCountLine( 0 ); - _searchFields.setCountLineFailure( 0 ); - - while ( ( nextLine = csvReader.readNext( ) ) != null ) - { - _searchFields.setCountLine( _searchFields.getCountLine( ) + 1 ); - - if ( nextLine.length != tabEntry.length ) - { - _searchFields.getError( ).append( I18nService.getLocalizedString( PROPERTY_LINE, getLocale( ) ) ); - _searchFields.getError( ).append( _searchFields.getCountLine( ) ); - _searchFields.getError( ).append( " > " ); - _searchFields.getError( ) - .append( I18nService.getLocalizedString( MESSAGE_ERROR_CSV_NUMBER_SEPARATOR, - getLocale( ) ) ); - _searchFields.getError( ).append( "
" ); - _searchFields.setCountLineFailure( _searchFields.getCountLineFailure( ) + 1 ); - } - else - { - Record record = new Record( ); - record.setDirectory( directory ); - - List listRecordField = new ArrayList( ); - - try - { - for ( int i = 0; i < nextLine.length; i++ ) - { - ( (IEntry) tabEntry[i] ).getImportRecordFieldData( record, nextLine[i], true, - listRecordField, getLocale( ) ); + _searchFields.setCountLine(0); + _searchFields.setCountLineFailure(0); + + while ((nextLine = csvReader.readNext()) != null) { + _searchFields.setCountLine(_searchFields.getCountLine() + 1); + + if (nextLine.length != tabEntry.length) { + _searchFields.getError().append(I18nService.getLocalizedString(PROPERTY_LINE, getLocale())); + _searchFields.getError().append(_searchFields.getCountLine()); + _searchFields.getError().append(" > "); + _searchFields.getError() + .append(I18nService.getLocalizedString(MESSAGE_ERROR_CSV_NUMBER_SEPARATOR, + getLocale())); + _searchFields.getError().append("
"); + _searchFields.setCountLineFailure(_searchFields.getCountLineFailure() + 1); + } else { + Record record = new Record(); + record.setDirectory(directory); + + List listRecordField = new ArrayList(); + + try { + for (int i = 0; i < nextLine.length; i++) { + ((IEntry) tabEntry[i]).getImportRecordFieldData(record, nextLine[i], true, + listRecordField, getLocale()); } - record.setListRecordField( listRecordField ); - record.setDateCreation( DirectoryUtils.getCurrentTimestamp( ) ); + record.setListRecordField(listRecordField); + record.setDateCreation(DirectoryUtils.getCurrentTimestamp()); //Autopublication - record.setEnabled( true ); - _recordService.create( record, getPlugin( ) ); - } - catch ( DirectoryErrorException error ) - { - _searchFields.getError( ).append( I18nService.getLocalizedString( PROPERTY_LINE, getLocale( ) ) ); - _searchFields.getError( ).append( _searchFields.getCountLine( ) ); - _searchFields.getError( ).append( " > " ); - - if ( error.isMandatoryError( ) ) - { - Object[] tabRequiredFields = { error.getTitleField( ) }; - _searchFields.getError( ) - .append( I18nService.getLocalizedString( - MESSAGE_DIRECTORY_ERROR_MANDATORY_FIELD, tabRequiredFields, getLocale( ) ) ); - } - else - { - Object[] tabRequiredFields = { error.getTitleField( ), error.getErrorMessage( ) }; - _searchFields.getError( ) - .append( I18nService.getLocalizedString( MESSAGE_DIRECTORY_ERROR, - tabRequiredFields, getLocale( ) ) ); + record.setEnabled(true); + _recordService.create(record, getPlugin()); + } catch (DirectoryErrorException error) { + _searchFields.getError().append(I18nService.getLocalizedString(PROPERTY_LINE, getLocale())); + _searchFields.getError().append(_searchFields.getCountLine()); + _searchFields.getError().append(" > "); + + if (error.isMandatoryError()) { + Object[] tabRequiredFields = {error.getTitleField()}; + _searchFields.getError() + .append(I18nService.getLocalizedString( + MESSAGE_DIRECTORY_ERROR_MANDATORY_FIELD, tabRequiredFields, getLocale())); + } else { + Object[] tabRequiredFields = {error.getTitleField(), error.getErrorMessage()}; + _searchFields.getError() + .append(I18nService.getLocalizedString(MESSAGE_DIRECTORY_ERROR, + tabRequiredFields, getLocale())); } - _searchFields.getError( ).append( "
" ); - _searchFields.setCountLineFailure( _searchFields.getCountLineFailure( ) + 1 ); + _searchFields.getError().append("
"); + _searchFields.setCountLineFailure(_searchFields.getCountLineFailure() + 1); } } } + } catch (IOException e) { + AppLogService.error(e); } - catch ( IOException e ) - { - AppLogService.error( e ); - } - - return getJspImportDirectoryRecord( request, nIdDirectory ); + return getJspImportDirectoryRecord(request, nIdDirectory); } /** * Return the interface for index all directory + * * @param request The Http request * @throws AccessDeniedException the {@link AccessDeniedException} * @return Html directory */ - public String getIndexAllDirectory( HttpServletRequest request ) - throws AccessDeniedException - { - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, - DirectoryResourceIdService.PERMISSION_INDEX_ALL_DIRECTORY, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + public String getIndexAllDirectory(HttpServletRequest request) + throws AccessDeniedException { + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, + DirectoryResourceIdService.PERMISSION_INDEX_ALL_DIRECTORY, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - Map model = new HashMap( ); + Map model = new HashMap(); - model.put( MARK_LOCALE, getLocale( ) ); + model.put(MARK_LOCALE, getLocale()); - setPageTitleProperty( PROPERTY_INDEX_ALL_DIRECTORY_PAGE_TITLE ); + setPageTitleProperty(PROPERTY_INDEX_ALL_DIRECTORY_PAGE_TITLE); - HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_INDEX_ALL_DIRECTORY, getLocale( ), model ); + HtmlTemplate templateList = AppTemplateService.getTemplate(TEMPLATE_INDEX_ALL_DIRECTORY, getLocale(), model); - return getAdminPage( templateList.getHtml( ) ); + return getAdminPage(templateList.getHtml()); } /** * Gets the confirmation page of indexing all directory + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return the confirmation page of delete directory record */ - public String getConfirmIndexAllDirectory( HttpServletRequest request ) - throws AccessDeniedException - { - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, - DirectoryResourceIdService.PERMISSION_INDEX_ALL_DIRECTORY, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + public String getConfirmIndexAllDirectory(HttpServletRequest request) + throws AccessDeniedException { + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, + DirectoryResourceIdService.PERMISSION_INDEX_ALL_DIRECTORY, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - UrlItem url = new UrlItem( JSP_DO_INDEX_ALL_DIRECTORY ); + UrlItem url = new UrlItem(JSP_DO_INDEX_ALL_DIRECTORY); - return AdminMessageService.getMessageUrl( request, MESSAGE_CONFIRM_INDEX_ALL_DIRECTORY, url.getUrl( ), - AdminMessage.TYPE_CONFIRMATION ); + return AdminMessageService.getMessageUrl(request, MESSAGE_CONFIRM_INDEX_ALL_DIRECTORY, url.getUrl(), + AdminMessage.TYPE_CONFIRMATION); } /** * Start indexing + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doIndexAllDirectory( HttpServletRequest request ) - throws AccessDeniedException - { - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, - DirectoryResourceIdService.PERMISSION_INDEX_ALL_DIRECTORY, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + public String doIndexAllDirectory(HttpServletRequest request) + throws AccessDeniedException { + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, + DirectoryResourceIdService.PERMISSION_INDEX_ALL_DIRECTORY, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - if ( request.getParameter( PARAMETER_CANCEL ) == null ) - { - DirectorySearchService.getInstance( ).processIndexing( true ); + if (request.getParameter(PARAMETER_CANCEL) == null) { + DirectorySearchService.getInstance().processIndexing(true); } - return getHomeUrl( request ); + return getHomeUrl(request); } /** * Return management of directory record ( list of directory record ) + * * @param request The Http request * @throws AccessDeniedException the {@link AccessDeniedException} * @return Html directory */ - public String getCreateDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - Directory directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); + public String getCreateDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); - if ( ( directory == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_CREATE_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((directory == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_CREATE_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - Map model = new HashMap( ); + Map model = new HashMap(); /** * Map of - * 1) The user has uploaded/deleted a file - * - The updated map is stored in the session + * 1) The user has uploaded/deleted a file - The updated map is stored + * in the session 2) The user has not uploaded/delete a file - The map + * is filled with the data from the database - The asynchronous uploaded + * files map is reinitialized + */ + Map> map = null; + + // Get the map of >) session.getAttribute(DirectoryUtils.SESSION_DIRECTORY_LIST_SUBMITTED_RECORD_FIELDS); + + if (map != null) { + model.put(MARK_MAP_ID_ENTRY_LIST_RECORD_FIELD, map); + // IMPORTANT : Remove the map from the session + session.removeAttribute(DirectoryUtils.SESSION_DIRECTORY_LIST_SUBMITTED_RECORD_FIELDS); + } + } + + // Get the map classically from the database + /** * 2) The user has not uploaded/delete a file - * - The map is filled with the data from the database - * - The asynchronous uploaded files map is reinitialized + */ + if (map == null) { + // Remove asynchronous uploaded file from session + DirectoryAsynchronousUploadHandler.getHandler().removeSessionFiles(request.getSession().getId()); + } + + List listEntry = DirectoryUtils.getFormEntries(nIdDirectory, getPlugin(), getUser()); + + model.put(MARK_ENTRY_LIST, listEntry); + + if (SecurityService.isAuthenticationEnable()) { + model.put(MARK_ROLE_REF_LIST, RoleHome.getRolesList()); + } + + model.put(MARK_DIRECTORY, directory); + model.put(MARK_WEBAPP_URL, AppPathService.getBaseUrl(request)); + model.put(MARK_LOCALE, getLocale()); + setPageTitleProperty(PROPERTY_CREATE_DIRECTORY_RECORD_PAGE_TITLE); + + HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_CREATE_DIRECTORY_RECORD, getLocale(), model); + + return getAdminPage(template.getHtml()); + } + + /** + * Gets the creates the directory record with initial values. + * + * @param request the request + * @return the creates the directory record with initial values + * @throws AccessDeniedException the access denied exception + */ + @SuppressWarnings("unchecked") + public String getCreateDirectoryRecordWithInitialValues(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); + + if ((directory == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_CREATE_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); + } + + Map model = new HashMap(); + + /** + * Map of + * 1) The user has uploaded/deleted a file - The updated map is stored + * in the session 2) The user has not uploaded/delete a file - The map + * is filled with the data from the database - The asynchronous uploaded + * files map is reinitialized */ Map> map = null; @@ -3355,148 +3212,159 @@ DirectoryResourceIdService.PERMISSION_CREATE_RECORD, getUser( ) ) ) * 1) Case when the user has uploaded a file, the the map is stored in * the session */ - HttpSession session = request.getSession( false ); + HttpSession session = request.getSession(false); - if ( session != null ) - { - map = (Map>) session.getAttribute( DirectoryUtils.SESSION_DIRECTORY_LIST_SUBMITTED_RECORD_FIELDS ); + if (session != null) { + map = (Map>) session.getAttribute(DirectoryUtils.SESSION_DIRECTORY_LIST_SUBMITTED_RECORD_FIELDS); - if ( map != null ) - { - model.put( MARK_MAP_ID_ENTRY_LIST_RECORD_FIELD, map ); + if (map != null) { + model.put(MARK_MAP_ID_ENTRY_LIST_RECORD_FIELD, map); // IMPORTANT : Remove the map from the session - session.removeAttribute( DirectoryUtils.SESSION_DIRECTORY_LIST_SUBMITTED_RECORD_FIELDS ); + session.removeAttribute(DirectoryUtils.SESSION_DIRECTORY_LIST_SUBMITTED_RECORD_FIELDS); } } // Get the map classically from the database - /** 2) The user has not uploaded/delete a file */ - if ( map == null ) - { + /** + * 2) The user has not uploaded/delete a file + */ + if (map == null) { // Remove asynchronous uploaded file from session - DirectoryAsynchronousUploadHandler.getHandler( ).removeSessionFiles( request.getSession( ).getId( ) ); + DirectoryAsynchronousUploadHandler.getHandler().removeSessionFiles(request.getSession().getId()); } - List listEntry = DirectoryUtils.getFormEntries( nIdDirectory, getPlugin( ), getUser( ) ); - model.put( MARK_ENTRY_LIST, listEntry ); + List listEntry = DirectoryUtils.getFormEntries(nIdDirectory, getPlugin(), getUser()); + + //setValue inital +// /jsp/admin/plugins/directory/CreateDirectoryRecordWithInitialValues.jsp?id_directory=1&fn=abdou&cid=302714&ln=fall&guid=680a9e86-ffdc-45e6-a3c6-e3020b487624&ph=0858812641&em=fallphenix1987@gmail.com + //&pfn=1&pln=2&pem=3&pguid=4&pcid=5 + String fn = request.getParameter(PARAMETER_GRU_FIRST_NAME); + String ln = request.getParameter(PARAMETER_GRU_LAST_NAME); + String em = request.getParameter(PARAMETER_GRU_EMAIL); + String guid = request.getParameter(PARAMETER_GRU_GUID); + String cid = request.getParameter(PARAMETER_GRU_CID); - if ( SecurityService.isAuthenticationEnable( ) ) - { - model.put( MARK_ROLE_REF_LIST, RoleHome.getRolesList( ) ); + int pfn = (StringUtils.isNumeric(request.getParameter(MARK_POSITION_GRU_FIRST_NAME))) ? Integer.parseInt(request.getParameter(MARK_POSITION_GRU_FIRST_NAME)) : 1; + int pln = (StringUtils.isNumeric(request.getParameter(MARK_POSITION_GRU_LAST_NAME))) ? Integer.parseInt(request.getParameter(MARK_POSITION_GRU_LAST_NAME)) : 2; + int pem = (StringUtils.isNumeric(request.getParameter(MARK_POSITION_GRU_EMAIL))) ? Integer.parseInt(request.getParameter(MARK_POSITION_GRU_EMAIL)) : 3; + int pguid = (StringUtils.isNumeric(request.getParameter(MARK_POSITION_GRU_GUID))) ? Integer.parseInt(request.getParameter(MARK_POSITION_GRU_GUID)) : 4; + int pcid = (StringUtils.isNumeric(request.getParameter(MARK_POSITION_GRU_CID))) ? Integer.parseInt(request.getParameter(MARK_POSITION_GRU_CID)) : 5; + + listEntry.get(pfn - 1).getFields().get(0).setValue(fn); + listEntry.get(pln - 1).getFields().get(0).setValue(ln); + listEntry.get(pem - 1).getFields().get(0).setValue(em); + listEntry.get(pguid - 1).getFields().get(0).setValue(guid); + listEntry.get(pcid - 1).getFields().get(0).setValue(cid); + + model.put(MARK_ENTRY_LIST, listEntry); + + if (SecurityService.isAuthenticationEnable()) { + model.put(MARK_ROLE_REF_LIST, RoleHome.getRolesList()); } - model.put( MARK_DIRECTORY, directory ); - model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) ); - model.put( MARK_LOCALE, getLocale( ) ); - setPageTitleProperty( PROPERTY_CREATE_DIRECTORY_RECORD_PAGE_TITLE ); + model.put(MARK_DIRECTORY, directory); + model.put(MARK_WEBAPP_URL, AppPathService.getBaseUrl(request)); + model.put(MARK_LOCALE, getLocale()); + setPageTitleProperty(PROPERTY_CREATE_DIRECTORY_RECORD_PAGE_TITLE); - HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_CREATE_DIRECTORY_RECORD, getLocale( ), model ); + HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_CREATE_DIRECTORY_RECORD, getLocale(), model); - return getAdminPage( template.getHtml( ) ); + return getAdminPage(template.getHtml()); } /** * Perform the directory record creation + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doCreateDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - Directory directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); + public String doCreateDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); - if ( ( directory == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_CREATE_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((directory == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_CREATE_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - if ( request.getParameter( PARAMETER_CANCEL ) == null ) - { - Record record = new Record( ); - record.setDirectory( directory ); + if (request.getParameter(PARAMETER_CANCEL) == null) { + Record record = new Record(); + record.setDirectory(directory); + populateSynchronousUpload(request, Integer.toString(record.getDirectory().getIdDirectory())); + String strRedirectUrl = getDirectoryRecordData(record, request); - String strRedirectUrl = getDirectoryRecordData( record, request ); - - if ( StringUtils.isNotBlank( strRedirectUrl ) ) - { + if (StringUtils.isNotBlank(strRedirectUrl)) { return strRedirectUrl; } - record.setDateCreation( DirectoryUtils.getCurrentTimestamp( ) ); + record.setDateCreation(DirectoryUtils.getCurrentTimestamp()); //Autopublication - record.setEnabled( directory.isRecordActivated( ) ); - - TransactionManager.beginTransaction( getPlugin( ) ); - - try - { - _recordService.create( record, getPlugin( ) ); - - if ( WorkflowService.getInstance( ).isAvailable( ) && - ( directory.getIdWorkflow( ) != DirectoryUtils.CONSTANT_ID_NULL ) ) - { - WorkflowService.getInstance( ) - .getState( record.getIdRecord( ), Record.WORKFLOW_RESOURCE_TYPE, - directory.getIdWorkflow( ), Integer.valueOf( directory.getIdDirectory( ) ) ); - WorkflowService.getInstance( ) - .executeActionAutomatic( record.getIdRecord( ), Record.WORKFLOW_RESOURCE_TYPE, - directory.getIdWorkflow( ), Integer.valueOf( directory.getIdDirectory( ) ) ); + record.setEnabled(directory.isRecordActivated()); + + TransactionManager.beginTransaction(getPlugin()); + + try { + _recordService.create(record, getPlugin()); + + if (WorkflowService.getInstance().isAvailable() + && (directory.getIdWorkflow() != DirectoryUtils.CONSTANT_ID_NULL)) { + WorkflowService.getInstance() + .getState(record.getIdRecord(), Record.WORKFLOW_RESOURCE_TYPE, + directory.getIdWorkflow(), Integer.valueOf(directory.getIdDirectory())); + WorkflowService.getInstance() + .executeActionAutomatic(record.getIdRecord(), Record.WORKFLOW_RESOURCE_TYPE, + directory.getIdWorkflow(), Integer.valueOf(directory.getIdDirectory())); } - TransactionManager.commitTransaction( getPlugin( ) ); - } - catch ( Exception ex ) - { + TransactionManager.commitTransaction(getPlugin()); + } catch (Exception ex) { // something very wrong happened... a database check might be needed - AppLogService.error( ex.getMessage( ) + " for Record " + record.getIdRecord( ), ex ); + AppLogService.error(ex.getMessage() + " for Record " + record.getIdRecord(), ex); // revert - TransactionManager.rollBack( getPlugin( ) ); + TransactionManager.rollBack(getPlugin()); // throw a message to the user - return AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_GENERIC_MESSAGE, AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_GENERIC_MESSAGE, AdminMessage.TYPE_STOP); } } - return DirectoryUtils.getJspManageDirectoryRecord( request, nIdDirectory ); + return DirectoryUtils.getJspManageDirectoryRecord(request, nIdDirectory); } /** * Return management of directory record ( list of directory record ) + * * @param request The Http request * @throws AccessDeniedException the {@link AccessDeniedException} * @return Html directory */ - public String getModifyDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectoryRecord = request.getParameter( PARAMETER_ID_DIRECTORY_RECORD ); - int nIdDirectoryRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - Record record = _recordService.findByPrimaryKey( nIdDirectoryRecord, getPlugin( ) ); + public String getModifyDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectoryRecord = request.getParameter(PARAMETER_ID_DIRECTORY_RECORD); + int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + Record record = _recordService.findByPrimaryKey(nIdDirectoryRecord, getPlugin()); - if ( ( record == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - record.getDirectory( ).getIdDirectory( ) + DirectoryUtils.EMPTY_STRING, - DirectoryResourceIdService.PERMISSION_MODIFY_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((record == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + record.getDirectory().getIdDirectory() + DirectoryUtils.EMPTY_STRING, + DirectoryResourceIdService.PERMISSION_MODIFY_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } // List of entries to display - List listEntry = DirectoryUtils.getFormEntries( record.getDirectory( ).getIdDirectory( ), - getPlugin( ), getUser( ) ); + List listEntry = DirectoryUtils.getFormEntries(record.getDirectory().getIdDirectory(), + getPlugin(), getUser()); /** * Map of - * 1) The user has uploaded/deleted a file - * - The updated map is stored in the session - * 2) The user has not uploaded/delete a file - * - The map is filled with the data from the database - * - The asynchronous uploaded files map is reinitialized + * 1) The user has uploaded/deleted a file - The updated map is stored + * in the session 2) The user has not uploaded/delete a file - The map + * is filled with the data from the database - The asynchronous uploaded + * files map is reinitialized */ Map> map = null; @@ -3505,394 +3373,359 @@ DirectoryResourceIdService.PERMISSION_MODIFY_RECORD, getUser( ) ) ) * 1) Case when the user has uploaded a file, the the map is stored in * the session */ - HttpSession session = request.getSession( false ); + HttpSession session = request.getSession(false); - if ( session != null ) - { - map = (Map>) session.getAttribute( DirectoryUtils.SESSION_DIRECTORY_LIST_SUBMITTED_RECORD_FIELDS ); + if (session != null) { + map = (Map>) session.getAttribute(DirectoryUtils.SESSION_DIRECTORY_LIST_SUBMITTED_RECORD_FIELDS); // IMPORTANT : Remove the map from the session - session.removeAttribute( DirectoryUtils.SESSION_DIRECTORY_LIST_SUBMITTED_RECORD_FIELDS ); + session.removeAttribute(DirectoryUtils.SESSION_DIRECTORY_LIST_SUBMITTED_RECORD_FIELDS); } // Get the map classically from the database - /** 2) The user has not uploaded/delete a file */ - if ( map == null ) - { - map = DirectoryUtils.getMapIdEntryListRecordField( listEntry, nIdDirectoryRecord, getPlugin( ) ); + /** + * 2) The user has not uploaded/delete a file + */ + if (map == null) { + map = DirectoryUtils.getMapIdEntryListRecordField(listEntry, nIdDirectoryRecord, getPlugin()); // Reinit the asynchronous uploaded file map - DirectoryAsynchronousUploadHandler.getHandler( ).reinitMap( request, map, getPlugin( ) ); + DirectoryAsynchronousUploadHandler.getHandler().reinitMap(request, map, getPlugin()); } - Directory directory = DirectoryHome.findByPrimaryKey( record.getDirectory( ).getIdDirectory( ), getPlugin( ) ); + Directory directory = DirectoryHome.findByPrimaryKey(record.getDirectory().getIdDirectory(), getPlugin()); - Map model = new HashMap( ); + Map model = new HashMap(); - model.put( MARK_ENTRY_LIST, listEntry ); - model.put( MARK_MAP_ID_ENTRY_LIST_RECORD_FIELD, map ); - model.put( MARK_DIRECTORY, directory ); + model.put(MARK_ENTRY_LIST, listEntry); + model.put(MARK_MAP_ID_ENTRY_LIST_RECORD_FIELD, map); + model.put(MARK_DIRECTORY, directory); - if ( PortalService.isExtendActivated( ) ) - { - ExtendableResourcePluginActionManager.fillModel( request, AdminUserService.getAdminUser( request ), model, - record.getIdExtendableResource( ), record.getExtendableResourceType( ) ); + if (PortalService.isExtendActivated()) { + ExtendableResourcePluginActionManager.fillModel(request, AdminUserService.getAdminUser(request), model, + record.getIdExtendableResource(), record.getExtendableResourceType()); } - if ( SecurityService.isAuthenticationEnable( ) ) - { - model.put( MARK_ROLE_REF_LIST, RoleHome.getRolesList( ) ); + if (SecurityService.isAuthenticationEnable()) { + model.put(MARK_ROLE_REF_LIST, RoleHome.getRolesList()); } - model.put( MARK_DIRECTORY_RECORD, record ); - model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) ); - model.put( MARK_LOCALE, getLocale( ) ); - setPageTitleProperty( PROPERTY_MODIFY_DIRECTORY_RECORD_PAGE_TITLE ); + model.put(MARK_DIRECTORY_RECORD, record); + model.put(MARK_WEBAPP_URL, AppPathService.getBaseUrl(request)); + model.put(MARK_LOCALE, getLocale()); + setPageTitleProperty(PROPERTY_MODIFY_DIRECTORY_RECORD_PAGE_TITLE); - HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MODIFY_DIRECTORY_RECORD, getLocale( ), model ); + HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_MODIFY_DIRECTORY_RECORD, getLocale(), model); - return getAdminPage( template.getHtml( ) ); + return getAdminPage(template.getHtml()); } /** * Perform the directory record creation + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doModifyDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectoryRecord = request.getParameter( PARAMETER_ID_DIRECTORY_RECORD ); - int nIdDirectoryRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - Record record = _recordService.findByPrimaryKey( nIdDirectoryRecord, getPlugin( ) ); - - if ( ( record == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - record.getDirectory( ).getIdDirectory( ) + DirectoryUtils.EMPTY_STRING, - DirectoryResourceIdService.PERMISSION_MODIFY_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); - } - - if ( request.getParameter( PARAMETER_CANCEL ) == null ) - { - String strRedirectUrl = getDirectoryRecordData( record, request ); - - if ( StringUtils.isNotBlank( strRedirectUrl ) ) - { + public String doModifyDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectoryRecord = request.getParameter(PARAMETER_ID_DIRECTORY_RECORD); + int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + Record record = _recordService.findByPrimaryKey(nIdDirectoryRecord, getPlugin()); + + if ((record == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + record.getDirectory().getIdDirectory() + DirectoryUtils.EMPTY_STRING, + DirectoryResourceIdService.PERMISSION_MODIFY_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); + } + + if (request.getParameter(PARAMETER_CANCEL) == null) { + populateSynchronousUpload(request, Integer.toString(record.getDirectory().getIdDirectory())); + String strRedirectUrl = getDirectoryRecordData(record, request); + if (StringUtils.isNotBlank(strRedirectUrl)) { return strRedirectUrl; } - - try - { - _recordService.updateWidthRecordField( record, getPlugin( ) ); - } - catch ( Exception ex ) - { + try { + _recordService.updateWidthRecordField(record, getPlugin()); + } catch (Exception ex) { // something very wrong happened... a database check might be needed - AppLogService.error( ex.getMessage( ) + " when updating Record " + record.getIdRecord( ), ex ); + AppLogService.error(ex.getMessage() + " when updating Record " + record.getIdRecord(), ex); // throw a message to the user - return AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_GENERIC_MESSAGE, AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_GENERIC_MESSAGE, AdminMessage.TYPE_STOP); } } - return getRedirectUrl( request ); + return getRedirectUrl(request); } /** * Gets the confirmation page of delete directory record + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return the confirmation page of delete directory record */ - public String getConfirmRemoveDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String[] listIdsDirectoryRecord = request.getParameterValues( PARAMETER_ID_DIRECTORY_RECORD ); + public String getConfirmRemoveDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { + String[] listIdsDirectoryRecord = request.getParameterValues(PARAMETER_ID_DIRECTORY_RECORD); - if ( ( listIdsDirectoryRecord != null ) && ( listIdsDirectoryRecord.length > 0 ) ) - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); + if ((listIdsDirectoryRecord != null) && (listIdsDirectoryRecord.length > 0)) { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); // If the id directory is not in the parameter, then fetch it from the first record // assuming all records are from the same directory - if ( StringUtils.isBlank( strIdDirectory ) || !StringUtils.isNumeric( strIdDirectory ) ) - { + if (StringUtils.isBlank(strIdDirectory) || !StringUtils.isNumeric(strIdDirectory)) { String strIdDirectoryRecord = listIdsDirectoryRecord[0]; - int nIdDirectoryRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - Record record = _recordService.findByPrimaryKey( nIdDirectoryRecord, getPlugin( ) ); - strIdDirectory = Integer.toString( record.getDirectory( ).getIdDirectory( ) ); + int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + Record record = _recordService.findByPrimaryKey(nIdDirectoryRecord, getPlugin()); + strIdDirectory = Integer.toString(record.getDirectory().getIdDirectory()); } - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); - UrlItem url = new UrlItem( JSP_DO_REMOVE_DIRECTORY_RECORD ); - url.addParameter( DirectoryUtils.PARAMETER_ID_DIRECTORY, nIdDirectory ); + UrlItem url = new UrlItem(JSP_DO_REMOVE_DIRECTORY_RECORD); + url.addParameter(DirectoryUtils.PARAMETER_ID_DIRECTORY, nIdDirectory); - for ( String strIdDirectoryRecord : listIdsDirectoryRecord ) - { - int nIdDirectoryRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - Record record = _recordService.findByPrimaryKey( nIdDirectoryRecord, getPlugin( ) ); + for (String strIdDirectoryRecord : listIdsDirectoryRecord) { + int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + Record record = _recordService.findByPrimaryKey(nIdDirectoryRecord, getPlugin()); - if ( ( record == null ) || ( record.getDirectory( ).getIdDirectory( ) != nIdDirectory ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( record.getDirectory( ).getIdDirectory( ) ), - DirectoryResourceIdService.PERMISSION_DELETE_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((record == null) || (record.getDirectory().getIdDirectory() != nIdDirectory) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(record.getDirectory().getIdDirectory()), + DirectoryResourceIdService.PERMISSION_DELETE_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - url.addParameter( PARAMETER_ID_DIRECTORY_RECORD, nIdDirectoryRecord ); + url.addParameter(PARAMETER_ID_DIRECTORY_RECORD, nIdDirectoryRecord); } - return AdminMessageService.getMessageUrl( request, MESSAGE_CONFIRM_REMOVE_DIRECTORY_RECORD, url.getUrl( ), - AdminMessage.TYPE_CONFIRMATION ); + return AdminMessageService.getMessageUrl(request, MESSAGE_CONFIRM_REMOVE_DIRECTORY_RECORD, url.getUrl(), + AdminMessage.TYPE_CONFIRMATION); } - return AdminMessageService.getMessageUrl( request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP); } /** * Perform the directory record supression + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doRemoveDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String[] listIdsDirectoryRecord = request.getParameterValues( PARAMETER_ID_DIRECTORY_RECORD ); - - if ( ( listIdsDirectoryRecord != null ) && ( listIdsDirectoryRecord.length > 0 ) ) - { - String strIdDirectory = request.getParameter( DirectoryUtils.PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - List listErrors = new ArrayList( ); - - for ( String strIdDirectoryRecord : listIdsDirectoryRecord ) - { - int nIdDirectoryRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - Record record = _recordService.findByPrimaryKey( nIdDirectoryRecord, getPlugin( ) ); - - if ( ( record == null ) || ( record.getDirectory( ).getIdDirectory( ) != nIdDirectory ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( record.getDirectory( ).getIdDirectory( ) ), - DirectoryResourceIdService.PERMISSION_DELETE_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + public String doRemoveDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { + String[] listIdsDirectoryRecord = request.getParameterValues(PARAMETER_ID_DIRECTORY_RECORD); + + if ((listIdsDirectoryRecord != null) && (listIdsDirectoryRecord.length > 0)) { + String strIdDirectory = request.getParameter(DirectoryUtils.PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + List listErrors = new ArrayList(); + + for (String strIdDirectoryRecord : listIdsDirectoryRecord) { + int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + Record record = _recordService.findByPrimaryKey(nIdDirectoryRecord, getPlugin()); + + if ((record == null) || (record.getDirectory().getIdDirectory() != nIdDirectory) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(record.getDirectory().getIdDirectory()), + DirectoryResourceIdService.PERMISSION_DELETE_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - if ( !RecordRemovalListenerService.getService( ) - .checkForRemoval( strIdDirectoryRecord, listErrors, getLocale( ) ) ) - { - String strCause = AdminMessageService.getFormattedList( listErrors, getLocale( ) ); - Object[] args = { strCause }; + if (!RecordRemovalListenerService.getService() + .checkForRemoval(strIdDirectoryRecord, listErrors, getLocale())) { + String strCause = AdminMessageService.getFormattedList(listErrors, getLocale()); + Object[] args = {strCause}; - return AdminMessageService.getMessageUrl( request, MESSAGE_CANNOT_REMOVE_RECORD, args, - AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_CANNOT_REMOVE_RECORD, args, + AdminMessage.TYPE_STOP); } - try - { - _recordService.remove( nIdDirectoryRecord, getPlugin( ) ); - } - catch ( Exception ex ) - { + try { + _recordService.remove(nIdDirectoryRecord, getPlugin()); + } catch (Exception ex) { // something very wrong happened... a database check might be needed - AppLogService.error( ex.getMessage( ) + " when deleting Record " + record.getIdRecord( ), ex ); + AppLogService.error(ex.getMessage() + " when deleting Record " + record.getIdRecord(), ex); // throw a message to the user - return AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_GENERIC_MESSAGE, - AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_GENERIC_MESSAGE, + AdminMessage.TYPE_STOP); } - WorkflowService.getInstance( ) - .doRemoveWorkFlowResource( nIdDirectoryRecord, Record.WORKFLOW_RESOURCE_TYPE ); + WorkflowService.getInstance() + .doRemoveWorkFlowResource(nIdDirectoryRecord, Record.WORKFLOW_RESOURCE_TYPE); } - return DirectoryUtils.getJspManageDirectoryRecord( request, nIdDirectory ); + return DirectoryUtils.getJspManageDirectoryRecord(request, nIdDirectory); } - return AdminMessageService.getMessageUrl( request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP); } /** * copy the directory whose key is specified in the Http request + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doCopyDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectoryRecord = request.getParameter( PARAMETER_ID_DIRECTORY_RECORD ); - int nIdDirectoryRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - Record record = _recordService.findByPrimaryKey( nIdDirectoryRecord, getPlugin( ) ); + public String doCopyDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectoryRecord = request.getParameter(PARAMETER_ID_DIRECTORY_RECORD); + int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + Record record = _recordService.findByPrimaryKey(nIdDirectoryRecord, getPlugin()); - if ( ( record == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( record.getDirectory( ).getIdDirectory( ) ), - DirectoryResourceIdService.PERMISSION_COPY_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((record == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(record.getDirectory().getIdDirectory()), + DirectoryResourceIdService.PERMISSION_COPY_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - record.setDateCreation( DirectoryUtils.getCurrentTimestamp( ) ); + record.setDateCreation(DirectoryUtils.getCurrentTimestamp()); - try - { - _recordService.copy( record, getPlugin( ) ); - } - catch ( Exception ex ) - { + try { + _recordService.copy(record, getPlugin()); + } catch (Exception ex) { // something very wrong happened... a database check might be needed - AppLogService.error( ex.getMessage( ) + " when copying Record " + record.getIdRecord( ), ex ); + AppLogService.error(ex.getMessage() + " when copying Record " + record.getIdRecord(), ex); // Revert - _recordService.remove( record.getIdRecord( ), getPlugin( ) ); + _recordService.remove(record.getIdRecord(), getPlugin()); // throw a message to the user - return AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_GENERIC_MESSAGE, AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_GENERIC_MESSAGE, AdminMessage.TYPE_STOP); } - Directory directory = DirectoryHome.findByPrimaryKey( record.getDirectory( ).getIdDirectory( ), getPlugin( ) ); + Directory directory = DirectoryHome.findByPrimaryKey(record.getDirectory().getIdDirectory(), getPlugin()); - if ( WorkflowService.getInstance( ).isAvailable( ) && - ( directory.getIdWorkflow( ) != DirectoryUtils.CONSTANT_ID_NULL ) ) - { - WorkflowService.getInstance( ) - .getState( record.getIdRecord( ), Record.WORKFLOW_RESOURCE_TYPE, - directory.getIdWorkflow( ), Integer.valueOf( directory.getIdDirectory( ) ) ); - WorkflowService.getInstance( ) - .executeActionAutomatic( record.getIdRecord( ), Record.WORKFLOW_RESOURCE_TYPE, - directory.getIdWorkflow( ), Integer.valueOf( directory.getIdDirectory( ) ) ); + if (WorkflowService.getInstance().isAvailable() + && (directory.getIdWorkflow() != DirectoryUtils.CONSTANT_ID_NULL)) { + WorkflowService.getInstance() + .getState(record.getIdRecord(), Record.WORKFLOW_RESOURCE_TYPE, + directory.getIdWorkflow(), Integer.valueOf(directory.getIdDirectory())); + WorkflowService.getInstance() + .executeActionAutomatic(record.getIdRecord(), Record.WORKFLOW_RESOURCE_TYPE, + directory.getIdWorkflow(), Integer.valueOf(directory.getIdDirectory())); } - return getRedirectUrl( request ); + return getRedirectUrl(request); } /** * Gets the confirmation page of disable directory record + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return the confirmation page of disable directory record */ - public String getConfirmDisableDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectoryRecord = request.getParameter( PARAMETER_ID_DIRECTORY_RECORD ); - int nIdDirectoryRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - Record record = _recordService.findByPrimaryKey( nIdDirectoryRecord, getPlugin( ) ); + public String getConfirmDisableDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectoryRecord = request.getParameter(PARAMETER_ID_DIRECTORY_RECORD); + int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + Record record = _recordService.findByPrimaryKey(nIdDirectoryRecord, getPlugin()); String strMessage; - if ( ( record == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( record.getDirectory( ).getIdDirectory( ) ), - DirectoryResourceIdService.PERMISSION_CHANGE_STATE_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((record == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(record.getDirectory().getIdDirectory()), + DirectoryResourceIdService.PERMISSION_CHANGE_STATE_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } strMessage = MESSAGE_CONFIRM_DISABLE_DIRECTORY_RECORD; - UrlItem url = new UrlItem( JSP_DO_DISABLE_DIRECTORY_RECORD ); - url.addParameter( PARAMETER_ID_DIRECTORY_RECORD, strIdDirectoryRecord ); + UrlItem url = new UrlItem(JSP_DO_DISABLE_DIRECTORY_RECORD); + url.addParameter(PARAMETER_ID_DIRECTORY_RECORD, strIdDirectoryRecord); - return AdminMessageService.getMessageUrl( request, strMessage, url.getUrl( ), AdminMessage.TYPE_CONFIRMATION ); + return AdminMessageService.getMessageUrl(request, strMessage, url.getUrl(), AdminMessage.TYPE_CONFIRMATION); } /** * Perform disable directory record + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doDisableDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectoryRecord = request.getParameter( PARAMETER_ID_DIRECTORY_RECORD ); - int nIdDirectoryRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - Record record = _recordService.findByPrimaryKey( nIdDirectoryRecord, getPlugin( ) ); + public String doDisableDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectoryRecord = request.getParameter(PARAMETER_ID_DIRECTORY_RECORD); + int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + Record record = _recordService.findByPrimaryKey(nIdDirectoryRecord, getPlugin()); - if ( ( record == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( record.getDirectory( ).getIdDirectory( ) ), - DirectoryResourceIdService.PERMISSION_CHANGE_STATE_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((record == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(record.getDirectory().getIdDirectory()), + DirectoryResourceIdService.PERMISSION_CHANGE_STATE_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - record.setEnabled( false ); + record.setEnabled(false); - try - { - _recordService.update( record, getPlugin( ) ); - } - catch ( Exception ex ) - { + try { + _recordService.update(record, getPlugin()); + } catch (Exception ex) { // something very wrong happened... a database check might be needed - AppLogService.error( ex.getMessage( ) + " when disabling Record " + record.getIdRecord( ), ex ); + AppLogService.error(ex.getMessage() + " when disabling Record " + record.getIdRecord(), ex); // throw a message to the user - return AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_GENERIC_MESSAGE, AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_GENERIC_MESSAGE, AdminMessage.TYPE_STOP); } - return getRedirectUrl( request ); + return getRedirectUrl(request); } /** * Perform enable directory record + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doEnableDirectoryRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectoryRecord = request.getParameter( PARAMETER_ID_DIRECTORY_RECORD ); - int nIdDirectoryRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - Record record = _recordService.findByPrimaryKey( nIdDirectoryRecord, getPlugin( ) ); + public String doEnableDirectoryRecord(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectoryRecord = request.getParameter(PARAMETER_ID_DIRECTORY_RECORD); + int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + Record record = _recordService.findByPrimaryKey(nIdDirectoryRecord, getPlugin()); - if ( ( record == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( record.getDirectory( ).getIdDirectory( ) ), - DirectoryResourceIdService.PERMISSION_CHANGE_STATE_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((record == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(record.getDirectory().getIdDirectory()), + DirectoryResourceIdService.PERMISSION_CHANGE_STATE_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - record.setEnabled( true ); + record.setEnabled(true); - try - { - _recordService.update( record, getPlugin( ) ); - } - catch ( Exception ex ) - { + try { + _recordService.update(record, getPlugin()); + } catch (Exception ex) { // something very wrong happened... a database check might be needed - AppLogService.error( ex.getMessage( ) + " when enabling Record " + record.getIdRecord( ), ex ); + AppLogService.error(ex.getMessage() + " when enabling Record " + record.getIdRecord(), ex); // throw a message to the user - return AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_GENERIC_MESSAGE, AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_GENERIC_MESSAGE, AdminMessage.TYPE_STOP); } - return getRedirectUrl( request ); + return getRedirectUrl(request); } /** * return the tasks form + * * @param request the request * @return the tasks form */ - public String getTasksForm( HttpServletRequest request ) - { - String[] listIdsDirectoryRecord = request.getParameterValues( DirectoryUtils.PARAMETER_ID_DIRECTORY_RECORD ); - String strIdAction = request.getParameter( PARAMETER_ID_ACTION ); + public String getTasksForm(HttpServletRequest request) { + String[] listIdsDirectoryRecord = request.getParameterValues(DirectoryUtils.PARAMETER_ID_DIRECTORY_RECORD); + String strIdAction = request.getParameter(PARAMETER_ID_ACTION); - if ( ( listIdsDirectoryRecord != null ) && ( listIdsDirectoryRecord.length > 0 ) && - StringUtils.isNotBlank( strIdAction ) && StringUtils.isNumeric( strIdAction ) ) - { - int nIdAction = DirectoryUtils.convertStringToInt( strIdAction ); + if ((listIdsDirectoryRecord != null) && (listIdsDirectoryRecord.length > 0) + && StringUtils.isNotBlank(strIdAction) && StringUtils.isNumeric(strIdAction)) { + int nIdAction = DirectoryUtils.convertStringToInt(strIdAction); /* * DIRECTORY-126 : Add new direction action : Mass Workflow action @@ -3901,510 +3734,490 @@ public String getTasksForm( HttpServletRequest request ) * relevant when displaying the task form. */ String strIdDirectoryRecord = listIdsDirectoryRecord[0]; - int nIdRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - String strHtmlTasksForm = WorkflowService.getInstance( ) - .getDisplayTasksForm( nIdRecord, Record.WORKFLOW_RESOURCE_TYPE, - nIdAction, request, getLocale( ) ); + int nIdRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + String strHtmlTasksForm = WorkflowService.getInstance() + .getDisplayTasksForm(nIdRecord, Record.WORKFLOW_RESOURCE_TYPE, + nIdAction, request, getLocale()); - Map model = new HashMap( ); + Map model = new HashMap(); - model.put( MARK_TASKS_FORM, strHtmlTasksForm ); - model.put( MARK_ID_ACTION, nIdAction ); - model.put( MARK_LIST_IDS_DIRECTORY_RECORD, listIdsDirectoryRecord ); - model.put( MARK_SHOW_ACTION_RESULT, request.getParameter( DirectoryUtils.PARAMETER_SHOW_ACTION_RESULT ) ); + model.put(MARK_TASKS_FORM, strHtmlTasksForm); + model.put(MARK_ID_ACTION, nIdAction); + model.put(MARK_LIST_IDS_DIRECTORY_RECORD, listIdsDirectoryRecord); + model.put(MARK_SHOW_ACTION_RESULT, request.getParameter(DirectoryUtils.PARAMETER_SHOW_ACTION_RESULT)); - setPageTitleProperty( PROPERTY_TASKS_FORM_WORKFLOW_PAGE_TITLE ); + setPageTitleProperty(PROPERTY_TASKS_FORM_WORKFLOW_PAGE_TITLE); - HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_TASKS_FORM_WORKFLOW, getLocale( ), - model ); + HtmlTemplate templateList = AppTemplateService.getTemplate(TEMPLATE_TASKS_FORM_WORKFLOW, getLocale(), + model); - return getAdminPage( templateList.getHtml( ) ); + return getAdminPage(templateList.getHtml()); } - return getManageDirectory( request ); + return getManageDirectory(request); } /** * save the tasks form + * * @param request the httpRequest * @return The URL to go after performing the action */ - public String doSaveTasksForm( HttpServletRequest request ) - { - String[] listIdsDirectoryRecord = request.getParameterValues( DirectoryUtils.PARAMETER_ID_DIRECTORY_RECORD ); + public String doSaveTasksForm(HttpServletRequest request) { + String[] listIdsDirectoryRecord = request.getParameterValues(DirectoryUtils.PARAMETER_ID_DIRECTORY_RECORD); - if ( ( listIdsDirectoryRecord != null ) && ( listIdsDirectoryRecord.length > 0 ) ) - { - String strIdDirectory = request.getParameter( DirectoryUtils.PARAMETER_ID_DIRECTORY ); + if ((listIdsDirectoryRecord != null) && (listIdsDirectoryRecord.length > 0)) { + String strIdDirectory = request.getParameter(DirectoryUtils.PARAMETER_ID_DIRECTORY); // If the id directory is not in the parameter, then fetch it from the first record // assuming all records are from the same directory - if ( StringUtils.isBlank( strIdDirectory ) || !StringUtils.isNumeric( strIdDirectory ) ) - { + if (StringUtils.isBlank(strIdDirectory) || !StringUtils.isNumeric(strIdDirectory)) { String strIdDirectoryRecord = listIdsDirectoryRecord[0]; - int nIdDirectoryRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - Record record = _recordService.findByPrimaryKey( nIdDirectoryRecord, getPlugin( ) ); - strIdDirectory = Integer.toString( record.getDirectory( ).getIdDirectory( ) ); + int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + Record record = _recordService.findByPrimaryKey(nIdDirectoryRecord, getPlugin()); + strIdDirectory = Integer.toString(record.getDirectory().getIdDirectory()); } - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); - if ( request.getParameter( PARAMETER_CANCEL ) == null ) - { - String strShowActionResult = request.getParameter( DirectoryUtils.PARAMETER_SHOW_ACTION_RESULT ); - boolean bShowActionResult = StringUtils.isNotBlank( strShowActionResult ); + if (request.getParameter(PARAMETER_CANCEL) == null) { + String strShowActionResult = request.getParameter(DirectoryUtils.PARAMETER_SHOW_ACTION_RESULT); + boolean bShowActionResult = StringUtils.isNotBlank(strShowActionResult); // Case when the user is uploading a file - String strUploadAction = DirectoryAsynchronousUploadHandler.getHandler( ).getUploadAction( request ); + String strUploadAction = DirectoryAsynchronousUploadHandler.getHandler().getUploadAction(request); - if ( StringUtils.isNotBlank( strUploadAction ) ) - { + if (StringUtils.isNotBlank(strUploadAction)) { Map> mapRecordFields = null; /** * 1) Case when the user has uploaded a file, the the map is * stored in the session */ - HttpSession session = request.getSession( ); - mapRecordFields = (Map>) session.getAttribute( DirectoryUtils.SESSION_DIRECTORY_TASKS_SUBMITTED_RECORD_FIELDS ); + HttpSession session = request.getSession(); + mapRecordFields = (Map>) session.getAttribute(DirectoryUtils.SESSION_DIRECTORY_TASKS_SUBMITTED_RECORD_FIELDS); - /** 2) The user has not uploaded/delete a file */ - if ( mapRecordFields == null ) - { - mapRecordFields = new HashMap>( ); + /** + * 2) The user has not uploaded/delete a file + */ + if (mapRecordFields == null) { + mapRecordFields = new HashMap>(); } - String strIdAction = request.getParameter( PARAMETER_ID_ACTION ); - int nIdAction = DirectoryUtils.convertStringToInt( strIdAction ); + String strIdAction = request.getParameter(PARAMETER_ID_ACTION); + int nIdAction = DirectoryUtils.convertStringToInt(strIdAction); - try - { - DirectoryAsynchronousUploadHandler.getHandler( ) - .doUploadAction( request, strUploadAction, mapRecordFields, - null, getPlugin( ) ); - } - catch ( DirectoryErrorException error ) - { + try { + DirectoryAsynchronousUploadHandler.getHandler() + .doUploadAction(request, strUploadAction, mapRecordFields, + null, getPlugin()); + } catch (DirectoryErrorException error) { String strErrorMessage = DirectoryUtils.EMPTY_STRING; - if ( error.isMandatoryError( ) ) - { - Object[] tabRequiredFields = { error.getTitleField( ) }; - strErrorMessage = AdminMessageService.getMessageUrl( request, - MESSAGE_DIRECTORY_ERROR_MANDATORY_FIELD, tabRequiredFields, AdminMessage.TYPE_STOP ); - } - else - { - Object[] tabRequiredFields = { error.getTitleField( ), error.getErrorMessage( ) }; - strErrorMessage = AdminMessageService.getMessageUrl( request, MESSAGE_DIRECTORY_ERROR, - tabRequiredFields, AdminMessage.TYPE_STOP ); + if (error.isMandatoryError()) { + Object[] tabRequiredFields = {error.getTitleField()}; + strErrorMessage = AdminMessageService.getMessageUrl(request, + MESSAGE_DIRECTORY_ERROR_MANDATORY_FIELD, tabRequiredFields, AdminMessage.TYPE_STOP); + } else { + Object[] tabRequiredFields = {error.getTitleField(), error.getErrorMessage()}; + strErrorMessage = AdminMessageService.getMessageUrl(request, MESSAGE_DIRECTORY_ERROR, + tabRequiredFields, AdminMessage.TYPE_STOP); } return strErrorMessage; } // Store the map in the session - session.setAttribute( DirectoryUtils.SESSION_DIRECTORY_TASKS_SUBMITTED_RECORD_FIELDS, - mapRecordFields ); + session.setAttribute(DirectoryUtils.SESSION_DIRECTORY_TASKS_SUBMITTED_RECORD_FIELDS, + mapRecordFields); - return getJspTasksForm( request, listIdsDirectoryRecord, nIdAction, bShowActionResult ); + return getJspTasksForm(request, listIdsDirectoryRecord, nIdAction, bShowActionResult); } - String strIdAction = request.getParameter( DirectoryUtils.PARAMETER_ID_ACTION ); - int nIdAction = DirectoryUtils.convertStringToInt( strIdAction ); + String strIdAction = request.getParameter(DirectoryUtils.PARAMETER_ID_ACTION); + int nIdAction = DirectoryUtils.convertStringToInt(strIdAction); - String strError = _directoryActionResult.doSaveTaskForm( nIdDirectory, nIdAction, - listIdsDirectoryRecord, getPlugin( ), getLocale( ), request ); + String strError = _directoryActionResult.doSaveTaskForm(nIdDirectory, nIdAction, + listIdsDirectoryRecord, getPlugin(), getLocale(), request); - if ( StringUtils.isNotBlank( strError ) ) - { + if (StringUtils.isNotBlank(strError)) { return strError; } - if ( bShowActionResult ) - { - return getJspActionResults( request, nIdDirectory, nIdAction ); + if (bShowActionResult) { + return getJspActionResults(request, nIdDirectory, nIdAction); } } - return getRedirectUrl( request ); + return getRedirectUrl(request); } - return getJspManageDirectory( request ); + return getJspManageDirectory(request); } /** * return the resource history + * * @param request the httpRequest * @throws AccessDeniedException AccessDeniedException * @return the resource history */ - public String getResourceHistory( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdRecord = request.getParameter( PARAMETER_ID_DIRECTORY_RECORD ); - int nIdRecord = DirectoryUtils.convertStringToInt( strIdRecord ); + public String getResourceHistory(HttpServletRequest request) + throws AccessDeniedException { + String strIdRecord = request.getParameter(PARAMETER_ID_DIRECTORY_RECORD); + int nIdRecord = DirectoryUtils.convertStringToInt(strIdRecord); - Record record = _recordService.findByPrimaryKey( nIdRecord, getPlugin( ) ); - int nIdDirectory = record.getDirectory( ).getIdDirectory( ); - int nIdWorkflow = ( DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ) ).getIdWorkflow( ); + Record record = _recordService.findByPrimaryKey(nIdRecord, getPlugin()); + int nIdDirectory = record.getDirectory().getIdDirectory(); + int nIdWorkflow = (DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin())).getIdWorkflow(); // Get asynchronous file names boolean bGetFileName = true; - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( record.getDirectory( ).getIdDirectory( ) ), - DirectoryResourceIdService.PERMISSION_HISTORY_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(record.getDirectory().getIdDirectory()), + DirectoryResourceIdService.PERMISSION_HISTORY_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } EntryFilter filter; - filter = new EntryFilter( ); - filter.setIdDirectory( record.getDirectory( ).getIdDirectory( ) ); - filter.setIsShownInHistory( EntryFilter.FILTER_TRUE ); + filter = new EntryFilter(); + filter.setIdDirectory(record.getDirectory().getIdDirectory()); + filter.setIsShownInHistory(EntryFilter.FILTER_TRUE); - List listEntry = EntryHome.getEntryList( filter, getPlugin( ) ); + List listEntry = EntryHome.getEntryList(filter, getPlugin()); - Directory directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); + Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); // List directory actions - List listActionsForDirectoryEnable = DirectoryActionHome.selectActionsRecordByFormState( Directory.STATE_ENABLE, - getPlugin( ), getLocale( ) ); - List listActionsForDirectoryDisable = DirectoryActionHome.selectActionsRecordByFormState( Directory.STATE_DISABLE, - getPlugin( ), getLocale( ) ); - - listActionsForDirectoryEnable = (List) RBACService.getAuthorizedActionsCollection( listActionsForDirectoryEnable, - record.getDirectory( ), getUser( ) ); - listActionsForDirectoryDisable = (List) RBACService.getAuthorizedActionsCollection( listActionsForDirectoryDisable, - record.getDirectory( ), getUser( ) ); - - _searchFields.setRedirectUrl( request ); - _searchFields.setItemNavigatorHistory( nIdRecord, AppPathService.getBaseUrl( request ) + JSP_RESOURCE_HISTORY, - DirectoryUtils.PARAMETER_ID_DIRECTORY_RECORD ); - - boolean bHistoryEnabled = WorkflowService.getInstance( ).isAvailable( ) && - ( directory.getIdWorkflow( ) != DirectoryUtils.CONSTANT_ID_NULL ); - - Map model = new HashMap( ); - - if ( directory != null ) - { - if ( directory.isDateShownInHistory( ) ) - { - model.put( MARK_RECORD_DATE_CREATION, record.getDateCreation( ) ); + List listActionsForDirectoryEnable = DirectoryActionHome.selectActionsRecordByFormState(Directory.STATE_ENABLE, + getPlugin(), getLocale()); + List listActionsForDirectoryDisable = DirectoryActionHome.selectActionsRecordByFormState(Directory.STATE_DISABLE, + getPlugin(), getLocale()); + + listActionsForDirectoryEnable = (List) RBACService.getAuthorizedActionsCollection(listActionsForDirectoryEnable, + record.getDirectory(), getUser()); + listActionsForDirectoryDisable = (List) RBACService.getAuthorizedActionsCollection(listActionsForDirectoryDisable, + record.getDirectory(), getUser()); + + _searchFields.setRedirectUrl(request); + _searchFields.setItemNavigatorHistory(nIdRecord, AppPathService.getBaseUrl(request) + JSP_RESOURCE_HISTORY, + DirectoryUtils.PARAMETER_ID_DIRECTORY_RECORD); + + boolean bHistoryEnabled = WorkflowService.getInstance().isAvailable() + && (directory.getIdWorkflow() != DirectoryUtils.CONSTANT_ID_NULL); + + Map model = new HashMap(); + + if (directory != null) { + if (directory.isDateShownInHistory()) { + model.put(MARK_RECORD_DATE_CREATION, record.getDateCreation()); } - if ( directory.isDateModificationShownInHistory( ) ) - { - model.put( MARK_RECORD_DATE_MODIFICATION, record.getDateModification( ) ); + if (directory.isDateModificationShownInHistory()) { + model.put(MARK_RECORD_DATE_MODIFICATION, record.getDateModification()); } } - model.put( MARK_RECORD, record ); - model.put( MARK_ENTRY_LIST, listEntry ); - model.put( MARK_DIRECTORY, directory ); - model.put( MARK_MAP_ID_ENTRY_LIST_RECORD_FIELD, - DirectoryUtils.getMapIdEntryListRecordField( listEntry, nIdRecord, getPlugin( ), bGetFileName ) ); + model.put(MARK_RECORD, record); + model.put(MARK_ENTRY_LIST, listEntry); + model.put(MARK_DIRECTORY, directory); + model.put(MARK_MAP_ID_ENTRY_LIST_RECORD_FIELD, + DirectoryUtils.getMapIdEntryListRecordField(listEntry, nIdRecord, getPlugin(), bGetFileName)); - model.put( MARK_RESOURCE_HISTORY, - WorkflowService.getInstance( ) - .getDisplayDocumentHistory( nIdRecord, Record.WORKFLOW_RESOURCE_TYPE, nIdWorkflow, request, - getLocale( ) ) ); - model.put( MARK_RESOURCE_ACTIONS, - DirectoryService.getInstance( ) - .getResourceAction( record, directory, listEntry, getUser( ), - listActionsForDirectoryEnable, listActionsForDirectoryDisable, bGetFileName, getPlugin( ) ) ); - model.put( MARK_ITEM_NAVIGATOR, _searchFields.getItemNavigatorHistory( ) ); - model.put( MARK_HISTORY_WORKFLOW_ENABLED, bHistoryEnabled ); + model.put(MARK_RESOURCE_HISTORY, + WorkflowService.getInstance() + .getDisplayDocumentHistory(nIdRecord, Record.WORKFLOW_RESOURCE_TYPE, nIdWorkflow, request, + getLocale())); + model.put(MARK_RESOURCE_ACTIONS, + DirectoryService.getInstance() + .getResourceAction(record, directory, listEntry, getUser(), + listActionsForDirectoryEnable, listActionsForDirectoryDisable, bGetFileName, getPlugin())); + model.put(MARK_ITEM_NAVIGATOR, _searchFields.getItemNavigatorHistory()); + model.put(MARK_HISTORY_WORKFLOW_ENABLED, bHistoryEnabled); - setPageTitleProperty( PROPERTY_RESOURCE_HISTORY_PAGE_TITLE ); + setPageTitleProperty(PROPERTY_RESOURCE_HISTORY_PAGE_TITLE); - HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_RESOURCE_HISTORY, getLocale( ), model ); + HtmlTemplate templateList = AppTemplateService.getTemplate(TEMPLATE_RESOURCE_HISTORY, getLocale(), model); - return getAdminPage( templateList.getHtml( ) ); + return getAdminPage(templateList.getHtml()); } /** * return the record visualisation + * * @param request the Http request * @return the record visualisation * @throws AccessDeniedException AccessDeniedException */ - public String getRecordVisualisation( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdRecord = request.getParameter( PARAMETER_ID_DIRECTORY_RECORD ); - int nIdRecord = DirectoryUtils.convertStringToInt( strIdRecord ); + public String getRecordVisualisation(HttpServletRequest request) + throws AccessDeniedException { + String strIdRecord = request.getParameter(PARAMETER_ID_DIRECTORY_RECORD); + int nIdRecord = DirectoryUtils.convertStringToInt(strIdRecord); EntryFilter filter; - Record record = _recordService.findByPrimaryKey( nIdRecord, getPlugin( ) ); + Record record = _recordService.findByPrimaryKey(nIdRecord, getPlugin()); - if ( ( record == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( record.getDirectory( ).getIdDirectory( ) ), - DirectoryResourceIdService.PERMISSION_VISUALISATION_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((record == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(record.getDirectory().getIdDirectory()), + DirectoryResourceIdService.PERMISSION_VISUALISATION_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - filter = new EntryFilter( ); - filter.setIdDirectory( record.getDirectory( ).getIdDirectory( ) ); - filter.setIsGroup( EntryFilter.FILTER_TRUE ); + filter = new EntryFilter(); + filter.setIdDirectory(record.getDirectory().getIdDirectory()); + filter.setIsGroup(EntryFilter.FILTER_TRUE); - List listEntry = DirectoryUtils.getFormEntries( record.getDirectory( ).getIdDirectory( ), - getPlugin( ), getUser( ) ); - int nIdDirectory = record.getDirectory( ).getIdDirectory( ); - Directory directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); + List listEntry = DirectoryUtils.getFormEntries(record.getDirectory().getIdDirectory(), + getPlugin(), getUser()); + int nIdDirectory = record.getDirectory().getIdDirectory(); + Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); // List directory actions - List listActionsForDirectoryEnable = DirectoryActionHome.selectActionsRecordByFormState( Directory.STATE_ENABLE, - getPlugin( ), getLocale( ) ); - List listActionsForDirectoryDisable = DirectoryActionHome.selectActionsRecordByFormState( Directory.STATE_DISABLE, - getPlugin( ), getLocale( ) ); + List listActionsForDirectoryEnable = DirectoryActionHome.selectActionsRecordByFormState(Directory.STATE_ENABLE, + getPlugin(), getLocale()); + List listActionsForDirectoryDisable = DirectoryActionHome.selectActionsRecordByFormState(Directory.STATE_DISABLE, + getPlugin(), getLocale()); - listActionsForDirectoryEnable = (List) RBACService.getAuthorizedActionsCollection( listActionsForDirectoryEnable, - directory, getUser( ) ); - listActionsForDirectoryDisable = (List) RBACService.getAuthorizedActionsCollection( listActionsForDirectoryDisable, - directory, getUser( ) ); + listActionsForDirectoryEnable = (List) RBACService.getAuthorizedActionsCollection(listActionsForDirectoryEnable, + directory, getUser()); + listActionsForDirectoryDisable = (List) RBACService.getAuthorizedActionsCollection(listActionsForDirectoryDisable, + directory, getUser()); - _searchFields.setRedirectUrl( request ); - _searchFields.setItemNavigatorViewRecords( nIdRecord, - AppPathService.getBaseUrl( request ) + JSP_DO_VISUALISATION_RECORD, - DirectoryUtils.PARAMETER_ID_DIRECTORY_RECORD ); + _searchFields.setRedirectUrl(request); + _searchFields.setItemNavigatorViewRecords(nIdRecord, + AppPathService.getBaseUrl(request) + JSP_DO_VISUALISATION_RECORD, + DirectoryUtils.PARAMETER_ID_DIRECTORY_RECORD); - boolean bHistoryEnabled = WorkflowService.getInstance( ).isAvailable( ) && - ( directory.getIdWorkflow( ) != DirectoryUtils.CONSTANT_ID_NULL ); + boolean bHistoryEnabled = WorkflowService.getInstance().isAvailable() + && (directory.getIdWorkflow() != DirectoryUtils.CONSTANT_ID_NULL); // Get asynchronous file names boolean bGetFileName = true; - Map model = new HashMap( ); - - model.put( MARK_RECORD, record ); - model.put( MARK_ENTRY_LIST, listEntry ); - model.put( MARK_DIRECTORY, directory ); - model.put( MARK_LOCALE, getLocale( ) ); - model.put( MARK_ID_ENTRY_TYPE_GEOLOCATION, - AppPropertiesService.getPropertyInt( PROPERTY_ENTRY_TYPE_GEOLOCATION, 16 ) ); - model.put( MARK_ID_ENTRY_TYPE_IMAGE, AppPropertiesService.getPropertyInt( PROPERTY_ENTRY_TYPE_IMAGE, 10 ) ); - model.put( MARK_ID_ENTRY_TYPE_MYLUTECE_USER, - AppPropertiesService.getPropertyInt( PROPERTY_ENTRY_TYPE_MYLUTECE_USER, 19 ) ); - model.put( MARK_PERMISSION_VISUALISATION_MYLUTECE_USER, - RBACService.isAuthorized( Directory.RESOURCE_TYPE, Integer.toString( nIdDirectory ), - DirectoryResourceIdService.PERMISSION_VISUALISATION_MYLUTECE_USER, getUser( ) ) ); - model.put( MARK_MAP_ID_ENTRY_LIST_RECORD_FIELD, - DirectoryUtils.getMapIdEntryListRecordField( listEntry, nIdRecord, getPlugin( ) ) ); - - model.put( MARK_SHOW_DATE_CREATION_RECORD, directory.isDateShownInResultRecord( ) ); - model.put( MARK_SHOW_DATE_MODIFICATION_RECORD, directory.isDateModificationShownInResultRecord( ) ); - model.put( MARK_RESOURCE_ACTIONS, - DirectoryService.getInstance( ) - .getResourceAction( record, directory, listEntry, getUser( ), - listActionsForDirectoryEnable, listActionsForDirectoryDisable, bGetFileName, getPlugin( ) ) ); - model.put( MARK_ITEM_NAVIGATOR, _searchFields.getItemNavigatorViewRecords( ) ); - model.put( MARK_HISTORY_WORKFLOW_ENABLED, bHistoryEnabled ); - - HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_VIEW_DIRECTORY_RECORD, getLocale( ), model ); - - return getAdminPage( templateList.getHtml( ) ); + Map model = new HashMap(); + + model.put(MARK_RECORD, record); + model.put(MARK_ENTRY_LIST, listEntry); + model.put(MARK_DIRECTORY, directory); + model.put(MARK_LOCALE, getLocale()); + model.put(MARK_ID_ENTRY_TYPE_GEOLOCATION, + AppPropertiesService.getPropertyInt(PROPERTY_ENTRY_TYPE_GEOLOCATION, 16)); + model.put(MARK_ID_ENTRY_TYPE_IMAGE, AppPropertiesService.getPropertyInt(PROPERTY_ENTRY_TYPE_IMAGE, 10)); + model.put(MARK_ID_ENTRY_TYPE_MYLUTECE_USER, + AppPropertiesService.getPropertyInt(PROPERTY_ENTRY_TYPE_MYLUTECE_USER, 19)); + model.put(MARK_PERMISSION_VISUALISATION_MYLUTECE_USER, + RBACService.isAuthorized(Directory.RESOURCE_TYPE, Integer.toString(nIdDirectory), + DirectoryResourceIdService.PERMISSION_VISUALISATION_MYLUTECE_USER, getUser())); + model.put(MARK_MAP_ID_ENTRY_LIST_RECORD_FIELD, + DirectoryUtils.getMapIdEntryListRecordField(listEntry, nIdRecord, getPlugin())); + + model.put(MARK_SHOW_DATE_CREATION_RECORD, directory.isDateShownInResultRecord()); + model.put(MARK_SHOW_DATE_MODIFICATION_RECORD, directory.isDateModificationShownInResultRecord()); + model.put(MARK_RESOURCE_ACTIONS, + DirectoryService.getInstance() + .getResourceAction(record, directory, listEntry, getUser(), + listActionsForDirectoryEnable, listActionsForDirectoryDisable, bGetFileName, getPlugin())); + model.put(MARK_ITEM_NAVIGATOR, _searchFields.getItemNavigatorViewRecords()); + model.put(MARK_HISTORY_WORKFLOW_ENABLED, bHistoryEnabled); + + HtmlTemplate templateList = AppTemplateService.getTemplate(TEMPLATE_VIEW_DIRECTORY_RECORD, getLocale(), model); + + return getAdminPage(templateList.getHtml()); } /** * Get the html for action result + * * @param request the HTTP request * @return the html code */ - public String getActionResult( HttpServletRequest request ) - { - String strIdDirectory = request.getParameter( DirectoryUtils.PARAMETER_ID_DIRECTORY ); - String strIdAction = request.getParameter( DirectoryUtils.PARAMETER_ID_ACTION ); - - if ( StringUtils.isNotBlank( strIdDirectory ) && StringUtils.isNumeric( strIdDirectory ) && - StringUtils.isNotBlank( strIdAction ) && StringUtils.isNumeric( strIdAction ) ) - { - int nIdAction = DirectoryUtils.convertStringToInt( strIdAction ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - Map model = new HashMap( ); + public String getActionResult(HttpServletRequest request) { + String strIdDirectory = request.getParameter(DirectoryUtils.PARAMETER_ID_DIRECTORY); + String strIdAction = request.getParameter(DirectoryUtils.PARAMETER_ID_ACTION); + + if (StringUtils.isNotBlank(strIdDirectory) && StringUtils.isNumeric(strIdDirectory) + && StringUtils.isNotBlank(strIdAction) && StringUtils.isNumeric(strIdAction)) { + int nIdAction = DirectoryUtils.convertStringToInt(strIdAction); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + Map model = new HashMap(); // Add directory to the model - Directory directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); + Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); - if ( directory == null ) - { - return getManageDirectory( request ); + if (directory == null) { + return getManageDirectory(request); } - model.put( MARK_DIRECTORY, directory ); + model.put(MARK_DIRECTORY, directory); // Add the action to the model - for ( Action action : WorkflowService.getInstance( ).getMassActions( directory.getIdWorkflow( ) ) ) - { - if ( action.getId( ) == nIdAction ) - { - model.put( MARK_ACTION, action ); + for (Action action : WorkflowService.getInstance().getMassActions(directory.getIdWorkflow())) { + if (action.getId() == nIdAction) { + model.put(MARK_ACTION, action); break; } } // Add the entries list to show in the model - EntryFilter entryFilter = new EntryFilter( ); - entryFilter.setIdDirectory( nIdDirectory ); - entryFilter.setIsGroup( EntryFilter.FILTER_FALSE ); - entryFilter.setIsComment( EntryFilter.FILTER_FALSE ); - entryFilter.setIsShownInResultList( EntryFilter.FILTER_TRUE ); + EntryFilter entryFilter = new EntryFilter(); + entryFilter.setIdDirectory(nIdDirectory); + entryFilter.setIsGroup(EntryFilter.FILTER_FALSE); + entryFilter.setIsComment(EntryFilter.FILTER_FALSE); + entryFilter.setIsShownInResultList(EntryFilter.FILTER_TRUE); - List listEntries = EntryHome.getEntryList( entryFilter, getPlugin( ) ); - model.put( MARK_ENTRY_LIST, listEntries ); + List listEntries = EntryHome.getEntryList(entryFilter, getPlugin()); + model.put(MARK_ENTRY_LIST, listEntries); - _directoryActionResult.fillModel( model, listEntries, getPlugin( ), getUser( ), directory ); + _directoryActionResult.fillModel(model, listEntries, getPlugin(), getUser(), directory); - model.put( MARK_LOCALE, request.getLocale( ) ); + model.put(MARK_LOCALE, request.getLocale()); - HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_ACTION_RESULT, getLocale( ), model ); + HtmlTemplate templateList = AppTemplateService.getTemplate(TEMPLATE_ACTION_RESULT, getLocale(), model); - return getAdminPage( templateList.getHtml( ) ); + return getAdminPage(templateList.getHtml()); } - return getManageDirectory( request ); + return getManageDirectory(request); } /** * return url of the jsp manage directory + * * @param request The HTTP request * @return url of the jsp manage directory */ - private String getJspManageDirectory( HttpServletRequest request ) - { - return AppPathService.getBaseUrl( request ) + JSP_MANAGE_DIRECTORY; + private String getJspManageDirectory(HttpServletRequest request) { + return AppPathService.getBaseUrl(request) + JSP_MANAGE_DIRECTORY; } /** * return url of the jsp modify directory + * * @param request The HTTP request * @param nIdDirectory the key of directory to modify * @return return url of the jsp modify directorys */ - private String getJspModifyDirectory( HttpServletRequest request, int nIdDirectory ) - { - return AppPathService.getBaseUrl( request ) + JSP_MODIFY_DIRECTORY + "?" + PARAMETER_ID_DIRECTORY + "=" + - nIdDirectory; + private String getJspModifyDirectory(HttpServletRequest request, int nIdDirectory) { + return AppPathService.getBaseUrl(request) + JSP_MODIFY_DIRECTORY + "?" + PARAMETER_ID_DIRECTORY + "=" + + nIdDirectory; } /** * return url of the jsp modify entry + * * @param request The HTTP request * @param nIdEntry the key of the entry to modify * @return return url of the jsp modify entry */ - private String getJspModifyEntry( HttpServletRequest request, int nIdEntry ) - { - return AppPathService.getBaseUrl( request ) + JSP_MODIFY_ENTRY + "?" + PARAMETER_ID_ENTRY + "=" + nIdEntry; + private String getJspModifyEntry(HttpServletRequest request, int nIdEntry) { + return AppPathService.getBaseUrl(request) + JSP_MODIFY_ENTRY + "?" + PARAMETER_ID_ENTRY + "=" + nIdEntry; } /** * return url of the jsp modify field + * * @param request The HTTP request * @param nIdField the key of the field to modify * @return return url of the jsp modify field */ - private String getJspModifyField( HttpServletRequest request, int nIdField ) - { - return AppPathService.getBaseUrl( request ) + JSP_MODIFY_FIELD + "?" + PARAMETER_ID_FIELD + "=" + nIdField; + private String getJspModifyField(HttpServletRequest request, int nIdField) { + return AppPathService.getBaseUrl(request) + JSP_MODIFY_FIELD + "?" + PARAMETER_ID_FIELD + "=" + nIdField; } /** * return url of the jsp print mass + * * @param request The HTTP request * @param nIdDirectory the directory id * @param strIdStateList the list of id state * @return url of the jsp print mass */ - private String getJspPrintMass( HttpServletRequest request, int nIdDirectory, String strIdStateList ) - { - return AppPathService.getBaseUrl( request ) + JSP_DISPLAY_PRINT_HISTORY + "?" + PARAMETER_ID_DIRECTORY + "=" + - nIdDirectory + "&" + PARAMETER_ID_STATE + "=" + strIdStateList; + private String getJspPrintMass(HttpServletRequest request, int nIdDirectory, String strIdStateList) { + return AppPathService.getBaseUrl(request) + JSP_DISPLAY_PRINT_HISTORY + "?" + PARAMETER_ID_DIRECTORY + "=" + + nIdDirectory + "&" + PARAMETER_ID_STATE + "=" + strIdStateList; } /** * return url of the jsp import directory record + * * @param request The HTTP request * @param nIdDirectory the directory id * @return url of the jsp import directory record */ - private String getJspImportDirectoryRecord( HttpServletRequest request, int nIdDirectory ) - { - return AppPathService.getBaseUrl( request ) + JSP_IMPORT_DIRECTORY_RECORD + "?" + PARAMETER_ID_DIRECTORY + "=" + - nIdDirectory + "&" + PARAMETER_SESSION + "=" + PARAMETER_SESSION; + private String getJspImportDirectoryRecord(HttpServletRequest request, int nIdDirectory) { + return AppPathService.getBaseUrl(request) + JSP_IMPORT_DIRECTORY_RECORD + "?" + PARAMETER_ID_DIRECTORY + "=" + + nIdDirectory + "&" + PARAMETER_SESSION + "=" + PARAMETER_SESSION; } /** * return url of the jsp manage directory + * * @param request The HTTP request * @return url of the jsp manage directory */ - private String getJspManageAdvancedParameters( HttpServletRequest request ) - { - return AppPathService.getBaseUrl( request ) + JSP_MANAGE_ADVANCED_PARAMETERS; + private String getJspManageAdvancedParameters(HttpServletRequest request) { + return AppPathService.getBaseUrl(request) + JSP_MANAGE_ADVANCED_PARAMETERS; } /** * Return url of the jsp action results + * * @param request the HTTP request * @param nIdDirectory the id directory * @param nIdAction the id action * @return the JSP */ - private String getJspActionResults( HttpServletRequest request, int nIdDirectory, int nIdAction ) - { - UrlItem url = new UrlItem( AppPathService.getBaseUrl( request ) + JSP_ACTION_RESULT ); - url.addParameter( DirectoryUtils.PARAMETER_ID_DIRECTORY, nIdDirectory ); - url.addParameter( PARAMETER_ID_ACTION, nIdAction ); + private String getJspActionResults(HttpServletRequest request, int nIdDirectory, int nIdAction) { + UrlItem url = new UrlItem(AppPathService.getBaseUrl(request) + JSP_ACTION_RESULT); + url.addParameter(DirectoryUtils.PARAMETER_ID_DIRECTORY, nIdDirectory); + url.addParameter(PARAMETER_ID_ACTION, nIdAction); - return url.getUrl( ); + return url.getUrl(); } /** * return url of the jsp create directory record + * * @param request The HTTP request * @param nIdDirectory the key of directory * @return return url of the jsp create directory record */ - private String getJspCreateDirectoryRecord( HttpServletRequest request, int nIdDirectory ) - { - return AppPathService.getBaseUrl( request ) + JSP_CREATE_DIRECTORY_RECORD + "?" + PARAMETER_ID_DIRECTORY + "=" + - nIdDirectory; + private String getJspCreateDirectoryRecord(HttpServletRequest request, int nIdDirectory) { + return AppPathService.getBaseUrl(request) + JSP_CREATE_DIRECTORY_RECORD + "?" + PARAMETER_ID_DIRECTORY + "=" + + nIdDirectory; } /** * return url of the jsp modify directory record + * * @param request The HTTP request * @param nIdDirectory the key of directory * @param nIdDirectoryRecord the key of directory record to modify * @return return url of the jsp modify directory record */ - private String getJspModifyDirectoryRecord( HttpServletRequest request, int nIdDirectory, int nIdDirectoryRecord ) - { - return AppPathService.getBaseUrl( request ) + JSP_MODIFY_DIRECTORY_RECORD + "?" + PARAMETER_ID_DIRECTORY + "=" + - nIdDirectory + "&" + PARAMETER_ID_DIRECTORY_RECORD + "=" + nIdDirectoryRecord; + private String getJspModifyDirectoryRecord(HttpServletRequest request, int nIdDirectory, int nIdDirectoryRecord) { + return AppPathService.getBaseUrl(request) + JSP_MODIFY_DIRECTORY_RECORD + "?" + PARAMETER_ID_DIRECTORY + "=" + + nIdDirectory + "&" + PARAMETER_ID_DIRECTORY_RECORD + "=" + nIdDirectoryRecord; } /** * return a reference list wich contains the different state of directory + * * @param locale the locale * @return reference list of directory state */ - private ReferenceList getRefListActive( Locale locale ) - { - ReferenceList refListState = new ReferenceList( ); - String strAll = I18nService.getLocalizedString( PROPERTY_ALL, locale ); - String strYes = I18nService.getLocalizedString( PROPERTY_YES, locale ); - String strNo = I18nService.getLocalizedString( PROPERTY_NO, locale ); + private ReferenceList getRefListActive(Locale locale) { + ReferenceList refListState = new ReferenceList(); + String strAll = I18nService.getLocalizedString(PROPERTY_ALL, locale); + String strYes = I18nService.getLocalizedString(PROPERTY_YES, locale); + String strNo = I18nService.getLocalizedString(PROPERTY_NO, locale); - refListState.addItem( -1, strAll ); - refListState.addItem( 1, strYes ); - refListState.addItem( 0, strNo ); + refListState.addItem(-1, strAll); + refListState.addItem(1, strYes); + refListState.addItem(0, strNo); return refListState; } @@ -4412,306 +4225,286 @@ private ReferenceList getRefListActive( Locale locale ) /** * reinit directory recordFilter */ - private void reInitDirectoryRecordFilter( ) - { - _searchFields.setItemsPerPageDirectoryRecord( 0 ); - _searchFields.setCurrentPageIndexDirectory( null ); - _searchFields.setMapQuery( null ); - _searchFields.setItemNavigatorViewRecords( null ); - _searchFields.setItemNavigatorHistory( null ); - _searchFields.setSortEntry( null ); - _searchFields.setSortOrder( RecordFieldFilter.ORDER_NONE ); + private void reInitDirectoryRecordFilter() { + _searchFields.setItemsPerPageDirectoryRecord(0); + _searchFields.setCurrentPageIndexDirectory(null); + _searchFields.setMapQuery(null); + _searchFields.setItemNavigatorViewRecords(null); + _searchFields.setItemNavigatorHistory(null); + _searchFields.setSortEntry(null); + _searchFields.setSortOrder(RecordFieldFilter.ORDER_NONE); } /** * Do process the workflow actions + * * @param request the HTTP request * @return the JSP return */ - public String doProcessAction( HttpServletRequest request ) - { - String[] listIdsDirectoryRecord = request.getParameterValues( DirectoryUtils.PARAMETER_ID_DIRECTORY_RECORD ); + public String doProcessAction(HttpServletRequest request) { + String[] listIdsDirectoryRecord = request.getParameterValues(DirectoryUtils.PARAMETER_ID_DIRECTORY_RECORD); - if ( ( listIdsDirectoryRecord != null ) && ( listIdsDirectoryRecord.length > 0 ) ) - { - String strShowActionResult = request.getParameter( DirectoryUtils.PARAMETER_SHOW_ACTION_RESULT ); - boolean bShowActionResult = StringUtils.isNotBlank( strShowActionResult ); + if ((listIdsDirectoryRecord != null) && (listIdsDirectoryRecord.length > 0)) { + String strShowActionResult = request.getParameter(DirectoryUtils.PARAMETER_SHOW_ACTION_RESULT); + boolean bShowActionResult = StringUtils.isNotBlank(strShowActionResult); - String strIdAction = request.getParameter( DirectoryUtils.PARAMETER_ID_ACTION ); - int nIdAction = DirectoryUtils.convertStringToInt( strIdAction ); + String strIdAction = request.getParameter(DirectoryUtils.PARAMETER_ID_ACTION); + int nIdAction = DirectoryUtils.convertStringToInt(strIdAction); - if ( WorkflowService.getInstance( ).isDisplayTasksForm( nIdAction, getLocale( ) ) ) - { - return getJspTasksForm( request, listIdsDirectoryRecord, nIdAction, bShowActionResult ); + if (WorkflowService.getInstance().isDisplayTasksForm(nIdAction, getLocale())) { + return getJspTasksForm(request, listIdsDirectoryRecord, nIdAction, bShowActionResult); } - String strIdDirectory = request.getParameter( DirectoryUtils.PARAMETER_ID_DIRECTORY ); + String strIdDirectory = request.getParameter(DirectoryUtils.PARAMETER_ID_DIRECTORY); // If the id directory is not in the parameter, then fetch it from the first record // assuming all records are from the same directory - if ( StringUtils.isBlank( strIdDirectory ) || !StringUtils.isNumeric( strIdDirectory ) ) - { + if (StringUtils.isBlank(strIdDirectory) || !StringUtils.isNumeric(strIdDirectory)) { String strIdDirectoryRecord = listIdsDirectoryRecord[0]; - int nIdDirectoryRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - Record record = _recordService.findByPrimaryKey( nIdDirectoryRecord, getPlugin( ) ); - strIdDirectory = Integer.toString( record.getDirectory( ).getIdDirectory( ) ); + int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + Record record = _recordService.findByPrimaryKey(nIdDirectoryRecord, getPlugin()); + strIdDirectory = Integer.toString(record.getDirectory().getIdDirectory()); } - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); - _directoryActionResult.doProcessAction( nIdDirectory, nIdAction, listIdsDirectoryRecord, getPlugin( ), - getLocale( ), request ); + _directoryActionResult.doProcessAction(nIdDirectory, nIdAction, listIdsDirectoryRecord, getPlugin(), + getLocale(), request); - if ( bShowActionResult ) - { - return getJspActionResults( request, nIdDirectory, nIdAction ); + if (bShowActionResult) { + return getJspActionResults(request, nIdDirectory, nIdAction); } - return getRedirectUrl( request ); + return getRedirectUrl(request); } - return getRedirectUrl( request ); + return getRedirectUrl(request); } /** * return url of the jsp manage commentaire + * * @param request The HTTP request * @param listIdsTestResource the list if id resource * @param nIdAction the id action * @param bShowActionResult true if it must show the action result, false - * otherwise + * otherwise * @return url of the jsp manage commentaire */ - private String getJspTasksForm( HttpServletRequest request, String[] listIdsTestResource, int nIdAction, - boolean bShowActionResult ) - { - UrlItem url = new UrlItem( AppPathService.getBaseUrl( request ) + JSP_TASKS_FORM_WORKFLOW ); - url.addParameter( DirectoryUtils.PARAMETER_ID_ACTION, nIdAction ); - - if ( bShowActionResult ) - { - url.addParameter( DirectoryUtils.PARAMETER_SHOW_ACTION_RESULT, DirectoryUtils.CONSTANT_TRUE ); - } - - if ( ( listIdsTestResource != null ) && ( listIdsTestResource.length > 0 ) ) - { - for ( String strIdTestResource : listIdsTestResource ) - { - url.addParameter( DirectoryUtils.PARAMETER_ID_DIRECTORY_RECORD, strIdTestResource ); + private String getJspTasksForm(HttpServletRequest request, String[] listIdsTestResource, int nIdAction, + boolean bShowActionResult) { + UrlItem url = new UrlItem(AppPathService.getBaseUrl(request) + JSP_TASKS_FORM_WORKFLOW); + url.addParameter(DirectoryUtils.PARAMETER_ID_ACTION, nIdAction); + + if (bShowActionResult) { + url.addParameter(DirectoryUtils.PARAMETER_SHOW_ACTION_RESULT, DirectoryUtils.CONSTANT_TRUE); + } + + if ((listIdsTestResource != null) && (listIdsTestResource.length > 0)) { + for (String strIdTestResource : listIdsTestResource) { + url.addParameter(DirectoryUtils.PARAMETER_ID_DIRECTORY_RECORD, strIdTestResource); } } - String strUploadAction = DirectoryAsynchronousUploadHandler.getHandler( ).getUploadAction( request ); + String strUploadAction = DirectoryAsynchronousUploadHandler.getHandler().getUploadAction(request); - if ( StringUtils.isNotBlank( strUploadAction ) ) - { - url.addParameter( strUploadAction, strUploadAction ); + if (StringUtils.isNotBlank(strUploadAction)) { + url.addParameter(strUploadAction, strUploadAction); } - return url.getUrl( ); + return url.getUrl(); } /** * Display the states for print mass + * * @param request la requete * @return The URL to go after performing the action * @throws AccessDeniedException AccessDeniedException */ - public String getMassPrint( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - Directory directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); - Map model = new HashMap( ); + public String getMassPrint(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); + Map model = new HashMap(); - if ( ( directory.getIdWorkflow( ) != DirectoryUtils.CONSTANT_ID_NULL ) && - WorkflowService.getInstance( ).isAvailable( ) ) - { - Collection listState = WorkflowService.getInstance( ) - .getAllStateByWorkflow( directory.getIdWorkflow( ), - AdminUserService.getAdminUser( request ) ); - model.put( MARK_STATE_LIST, listState ); + if ((directory.getIdWorkflow() != DirectoryUtils.CONSTANT_ID_NULL) + && WorkflowService.getInstance().isAvailable()) { + Collection listState = WorkflowService.getInstance() + .getAllStateByWorkflow(directory.getIdWorkflow(), + AdminUserService.getAdminUser(request)); + model.put(MARK_STATE_LIST, listState); } - model.put( MARK_DIRECTORY, directory ); - setPageTitleProperty( PROPERTY_MASS_PRINT_PAGE_TITLE ); + model.put(MARK_DIRECTORY, directory); + setPageTitleProperty(PROPERTY_MASS_PRINT_PAGE_TITLE); - HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MANAGE_MASS_PRINT, getLocale( ), model ); + HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_MANAGE_MASS_PRINT, getLocale(), model); - return getAdminPage( template.getHtml( ) ); + return getAdminPage(template.getHtml()); } /** * Verify Print Mass + * * @param request la requete * @return The URL to go after performing the action * @throws AccessDeniedException AccessDeniedException */ - public String doMassPrint( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - Directory directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); - Map mapIdState = request.getParameterMap( ); - WorkflowService workflowService = WorkflowService.getInstance( ); - - List listAllState = (List) workflowService.getAllStateByWorkflow( directory.getIdWorkflow( ), - AdminUserService.getAdminUser( request ) ); - - List listState = new ArrayList( ); - - for ( State state : listAllState ) - { - if ( mapIdState.containsKey( Integer.toString( state.getId( ) ) ) ) - { - listState.add( state ); + public String doMassPrint(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); + Map mapIdState = request.getParameterMap(); + WorkflowService workflowService = WorkflowService.getInstance(); + + List listAllState = (List) workflowService.getAllStateByWorkflow(directory.getIdWorkflow(), + AdminUserService.getAdminUser(request)); + + List listState = new ArrayList(); + + for (State state : listAllState) { + if (mapIdState.containsKey(Integer.toString(state.getId()))) { + listState.add(state); } } - if ( mapIdState.isEmpty( ) ) - { - return AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_NOT_SELECTED_STATE, AdminMessage.TYPE_STOP ); + if (mapIdState.isEmpty()) { + return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_NOT_SELECTED_STATE, AdminMessage.TYPE_STOP); } - Iterator it = listState.iterator( ); + Iterator it = listState.iterator(); boolean bFind = false; - Integer nIntIdDirectory = Integer.valueOf( directory.getIdDirectory( ) ); + Integer nIntIdDirectory = Integer.valueOf(directory.getIdDirectory()); - while ( !bFind && it.hasNext( ) ) - { - bFind = ( workflowService.getAuthorizedResourceList( Record.WORKFLOW_RESOURCE_TYPE, - directory.getIdWorkflow( ), it.next( ).getId( ), nIntIdDirectory, getUser( ) ).size( ) > 0 ); + while (!bFind && it.hasNext()) { + bFind = (workflowService.getAuthorizedResourceList(Record.WORKFLOW_RESOURCE_TYPE, + directory.getIdWorkflow(), it.next().getId(), nIntIdDirectory, getUser()).size() > 0); } - if ( !bFind ) - { - return AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_NO_RECORD, AdminMessage.TYPE_STOP ); + if (!bFind) { + return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_NO_RECORD, AdminMessage.TYPE_STOP); } - return getJspPrintHistory( request, listState, nIdDirectory ); + return getJspPrintHistory(request, listState, nIdDirectory); } /** * return url of the jsp + * * @param request The HTTP request * @param listState A state list * @param nIdDirectory The directory id * @return url of the jsp */ - private String getJspPrintHistory( HttpServletRequest request, List listState, int nIdDirectory ) - { - String strIdState = new String( ); + private String getJspPrintHistory(HttpServletRequest request, List listState, int nIdDirectory) { + String strIdState = new String(); - for ( State state : listState ) - { - strIdState = strIdState.concat( state.getId( ) + "," ); + for (State state : listState) { + strIdState = strIdState.concat(state.getId() + ","); } - if ( strIdState.length( ) > 0 ) - { - strIdState = strIdState.substring( 0, strIdState.length( ) - 1 ); + if (strIdState.length() > 0) { + strIdState = strIdState.substring(0, strIdState.length() - 1); } - return AppPathService.getBaseUrl( request ) + JSP_DISPLAY_PRINT_HISTORY + "?" + PARAMETER_ID_DIRECTORY + "=" + - nIdDirectory + "&" + PARAMETER_ID_STATE + "=" + strIdState; + return AppPathService.getBaseUrl(request) + JSP_DISPLAY_PRINT_HISTORY + "?" + PARAMETER_ID_DIRECTORY + "=" + + nIdDirectory + "&" + PARAMETER_ID_STATE + "=" + strIdState; } /** * Display Print Mass + * * @param request la requete * @return The URL to go after performing the action * @throws AccessDeniedException AccessDeniedException */ - public String getDisplayMassPrint( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - Directory directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); - String strIdState = request.getParameter( PARAMETER_ID_STATE ); - String[] tabIdState = strIdState.split( "," ); - - WorkflowService workflowService = WorkflowService.getInstance( ); - - Map model = new HashMap( ); + public String getDisplayMassPrint(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); + String strIdState = request.getParameter(PARAMETER_ID_STATE); + String[] tabIdState = strIdState.split(","); + + WorkflowService workflowService = WorkflowService.getInstance(); + + Map model = new HashMap(); List recordList; - List listStrIdState = Arrays.asList( tabIdState ); + List listStrIdState = Arrays.asList(tabIdState); - List listAllState = (List) workflowService.getAllStateByWorkflow( directory.getIdWorkflow( ), - AdminUserService.getAdminUser( request ) ); + List listAllState = (List) workflowService.getAllStateByWorkflow(directory.getIdWorkflow(), + AdminUserService.getAdminUser(request)); - List listIdState = new ArrayList( ); + List listIdState = new ArrayList(); - for ( State state : listAllState ) - { - if ( listStrIdState.contains( Integer.toString( state.getId( ) ) ) ) - { - listIdState.add( Integer.valueOf( state.getId( ) ) ); + for (State state : listAllState) { + if (listStrIdState.contains(Integer.toString(state.getId()))) { + listIdState.add(Integer.valueOf(state.getId())); } } - RecordFieldFilter recordFieldFilter = new RecordFieldFilter( ); - recordFieldFilter.setIdDirectory( directory.getIdDirectory( ) ); + RecordFieldFilter recordFieldFilter = new RecordFieldFilter(); + recordFieldFilter.setIdDirectory(directory.getIdDirectory()); - List listResultRecordId = DirectorySearchService.getInstance( ) - .getSearchResults( directory, - _searchFields.getMapQuery( ), _searchFields.getDateCreationRecord( ), - _searchFields.getDateCreationBeginRecord( ), _searchFields.getDateCreationEndRecord( ), - _searchFields.getDateModificationRecord( ), _searchFields.getDateModificationBeginRecord( ), - _searchFields.getDateModificationEndRecord( ), recordFieldFilter, getPlugin( ) ); + List listResultRecordId = DirectorySearchService.getInstance() + .getSearchResults(directory, + _searchFields.getMapQuery(), _searchFields.getDateCreationRecord(), + _searchFields.getDateCreationBeginRecord(), _searchFields.getDateCreationEndRecord(), + _searchFields.getDateModificationRecord(), _searchFields.getDateModificationBeginRecord(), + _searchFields.getDateModificationEndRecord(), recordFieldFilter, getPlugin()); - List listTmpResultRecordId = workflowService.getAuthorizedResourceList( Record.WORKFLOW_RESOURCE_TYPE, - directory.getIdWorkflow( ), listIdState, Integer.valueOf( directory.getIdDirectory( ) ), getUser( ) ); - List lListResult = DirectoryUtils.retainAll( listResultRecordId, listTmpResultRecordId ); + List listTmpResultRecordId = workflowService.getAuthorizedResourceList(Record.WORKFLOW_RESOURCE_TYPE, + directory.getIdWorkflow(), listIdState, Integer.valueOf(directory.getIdDirectory()), getUser()); + List lListResult = DirectoryUtils.retainAll(listResultRecordId, listTmpResultRecordId); - _searchFields.setCurrentPageIndexPrintMass( Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, - _searchFields.getCurrentPageIndexPrintMass( ) ) ); - _searchFields.setItemsPerPagePrintMass( Paginator.getItemsPerPage( request, Paginator.PARAMETER_ITEMS_PER_PAGE, - _searchFields.getItemsPerPagePrintMass( ), _searchFields.getDefaultItemsPerPage( ) ) ); + _searchFields.setCurrentPageIndexPrintMass(Paginator.getPageIndex(request, Paginator.PARAMETER_PAGE_INDEX, + _searchFields.getCurrentPageIndexPrintMass())); + _searchFields.setItemsPerPagePrintMass(Paginator.getItemsPerPage(request, Paginator.PARAMETER_ITEMS_PER_PAGE, + _searchFields.getItemsPerPagePrintMass(), _searchFields.getDefaultItemsPerPage())); - LocalizedPaginator paginator = new LocalizedPaginator( lListResult, - _searchFields.getItemsPerPagePrintMass( ), getJspPrintMass( request, nIdDirectory, strIdState ), - PARAMETER_PAGE_INDEX, _searchFields.getCurrentPageIndexPrintMass( ), getLocale( ) ); + LocalizedPaginator paginator = new LocalizedPaginator(lListResult, + _searchFields.getItemsPerPagePrintMass(), getJspPrintMass(request, nIdDirectory, strIdState), + PARAMETER_PAGE_INDEX, _searchFields.getCurrentPageIndexPrintMass(), getLocale()); - recordList = paginator.getPageItems( ); + recordList = paginator.getPageItems(); EntryFilter filter; - filter = new EntryFilter( ); - filter.setIdDirectory( nIdDirectory ); - filter.setIsShownInHistory( EntryFilter.FILTER_TRUE ); + filter = new EntryFilter(); + filter.setIdDirectory(nIdDirectory); + filter.setIsShownInHistory(EntryFilter.FILTER_TRUE); - List listEntry = EntryHome.getEntryList( filter, getPlugin( ) ); + List listEntry = EntryHome.getEntryList(filter, getPlugin()); - List> listRecordHistory = new ArrayList>( ); + List> listRecordHistory = new ArrayList>(); - for ( Integer nIdRecord : recordList ) - { - Map resource = new HashMap( ); - resource.put( MARK_MAP_ID_ENTRY_LIST_RECORD_FIELD, - DirectoryUtils.getMapIdEntryListRecordField( listEntry, nIdRecord, getPlugin( ), false ) ); + for (Integer nIdRecord : recordList) { + Map resource = new HashMap(); + resource.put(MARK_MAP_ID_ENTRY_LIST_RECORD_FIELD, + DirectoryUtils.getMapIdEntryListRecordField(listEntry, nIdRecord, getPlugin(), false)); - resource.put( MARK_RESOURCE_HISTORY, - WorkflowService.getInstance( ) - .getDisplayDocumentHistory( nIdRecord, Record.WORKFLOW_RESOURCE_TYPE, - directory.getIdWorkflow( ), request, getLocale( ) ) ); - listRecordHistory.add( resource ); + resource.put(MARK_RESOURCE_HISTORY, + WorkflowService.getInstance() + .getDisplayDocumentHistory(nIdRecord, Record.WORKFLOW_RESOURCE_TYPE, + directory.getIdWorkflow(), request, getLocale())); + listRecordHistory.add(resource); } - model.put( MARK_HISTORY_LIST, listRecordHistory ); - model.put( MARK_ENTRY_LIST, listEntry ); + model.put(MARK_HISTORY_LIST, listRecordHistory); + model.put(MARK_ENTRY_LIST, listEntry); - model.put( MARK_ID_DIRECTORY, strIdDirectory ); - model.put( MARK_ID_STATE, strIdState ); + model.put(MARK_ID_DIRECTORY, strIdDirectory); + model.put(MARK_ID_STATE, strIdState); - model.put( MARK_PAGINATOR, paginator ); - model.put( MARK_NB_ITEMS_PER_PAGE, Integer.toString( _searchFields.getItemsPerPagePrintMass( ) ) ); + model.put(MARK_PAGINATOR, paginator); + model.put(MARK_NB_ITEMS_PER_PAGE, Integer.toString(_searchFields.getItemsPerPagePrintMass())); - HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_DISPLAY_MASS_PRINT, getLocale( ), model ); + HtmlTemplate templateList = AppTemplateService.getTemplate(TEMPLATE_DISPLAY_MASS_PRINT, getLocale(), model); - return getAdminPage( templateList.getHtml( ) ); + return getAdminPage(templateList.getHtml()); } /** @@ -4720,519 +4513,462 @@ public String getDisplayMassPrint( HttpServletRequest request ) * @param request The Http request * @return Html form */ - public String getManageAdvancedParameters( HttpServletRequest request ) - { - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, - DirectoryResourceIdService.PERMISSION_MANAGE_ADVANCED_PARAMETERS, getUser( ) ) ) - { - return getManageDirectory( request ); + public String getManageAdvancedParameters(HttpServletRequest request) { + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, + DirectoryResourceIdService.PERMISSION_MANAGE_ADVANCED_PARAMETERS, getUser())) { + return getManageDirectory(request); } - Map model = DirectoryService.getInstance( ).getManageAdvancedParameters( getUser( ) ); + Map model = DirectoryService.getInstance().getManageAdvancedParameters(getUser()); - model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) ); - model.put( MARK_LOCALE, AdminUserService.getLocale( request ).getLanguage( ) ); + model.put(MARK_WEBAPP_URL, AppPathService.getBaseUrl(request)); + model.put(MARK_LOCALE, AdminUserService.getLocale(request).getLanguage()); - HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MANAGE_ADVANCED_PARAMETERS, getLocale( ), - model ); + HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_MANAGE_ADVANCED_PARAMETERS, getLocale(), + model); - return getAdminPage( template.getHtml( ) ); + return getAdminPage(template.getHtml()); } /** * Modify directory parameter default values + * * @param request HttpServletRequest * @return JSP return * @throws AccessDeniedException AccessDeniedException */ - public String doModifyDirectoryParameterDefaultValues( HttpServletRequest request ) - throws AccessDeniedException - { - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, - DirectoryResourceIdService.PERMISSION_MANAGE_ADVANCED_PARAMETERS, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + public String doModifyDirectoryParameterDefaultValues(HttpServletRequest request) + throws AccessDeniedException { + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, + DirectoryResourceIdService.PERMISSION_MANAGE_ADVANCED_PARAMETERS, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - ReferenceList listParams = DirectoryParameterService.getService( ).findDefaultValueParameters( ); + ReferenceList listParams = DirectoryParameterService.getService().findDefaultValueParameters(); - for ( ReferenceItem param : listParams ) - { - String strParamValue = request.getParameter( param.getCode( ) ); + for (ReferenceItem param : listParams) { + String strParamValue = request.getParameter(param.getCode()); - if ( StringUtils.isBlank( strParamValue ) ) - { + if (StringUtils.isBlank(strParamValue)) { strParamValue = ZERO; } - param.setName( strParamValue ); - DirectoryParameterService.getService( ).update( param ); + param.setName(strParamValue); + DirectoryParameterService.getService().update(param); } - return getJspManageAdvancedParameters( request ); + return getJspManageAdvancedParameters(request); } /** * Modify entry parameter default values + * * @param request HttpServletRequest * @return JSP return * @throws AccessDeniedException AccessDeniedException */ - public String doModifyEntryParameterDefaultValues( HttpServletRequest request ) - throws AccessDeniedException - { - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, - DirectoryResourceIdService.PERMISSION_MANAGE_ADVANCED_PARAMETERS, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + public String doModifyEntryParameterDefaultValues(HttpServletRequest request) + throws AccessDeniedException { + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, + DirectoryResourceIdService.PERMISSION_MANAGE_ADVANCED_PARAMETERS, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - ReferenceList listParams = EntryParameterService.getService( ).findAll( ); + ReferenceList listParams = EntryParameterService.getService().findAll(); - for ( ReferenceItem param : listParams ) - { - String strParamValue = request.getParameter( param.getCode( ) ); + for (ReferenceItem param : listParams) { + String strParamValue = request.getParameter(param.getCode()); - if ( StringUtils.isBlank( strParamValue ) ) - { + if (StringUtils.isBlank(strParamValue)) { strParamValue = ZERO; } - param.setName( strParamValue ); - EntryParameterService.getService( ).update( param ); + param.setName(strParamValue); + EntryParameterService.getService().update(param); } - return getJspManageAdvancedParameters( request ); + return getJspManageAdvancedParameters(request); } /** * Modify directory parameter default values + * * @param request HttpServletRequest * @return JSP return * @throws AccessDeniedException AccessDeniedException */ - public String doModifyExportEncodingParameters( HttpServletRequest request ) - throws AccessDeniedException - { - if ( !RBACService.isAuthorized( Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, - DirectoryResourceIdService.PERMISSION_MANAGE_ADVANCED_PARAMETERS, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + public String doModifyExportEncodingParameters(HttpServletRequest request) + throws AccessDeniedException { + if (!RBACService.isAuthorized(Directory.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, + DirectoryResourceIdService.PERMISSION_MANAGE_ADVANCED_PARAMETERS, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - ReferenceList listParams = DirectoryParameterService.getService( ).findExportEncodingParameters( ); + ReferenceList listParams = DirectoryParameterService.getService().findExportEncodingParameters(); - for ( ReferenceItem param : listParams ) - { - String strParamValue = request.getParameter( param.getCode( ) ); + for (ReferenceItem param : listParams) { + String strParamValue = request.getParameter(param.getCode()); - if ( StringUtils.isNotBlank( strParamValue ) ) - { + if (StringUtils.isNotBlank(strParamValue)) { // Test if the encoding is supported - try - { - strParamValue.getBytes( strParamValue ); - } - catch ( UnsupportedEncodingException e ) - { - Object[] tabRequiredFields = { strParamValue }; + try { + strParamValue.getBytes(strParamValue); + } catch (UnsupportedEncodingException e) { + Object[] tabRequiredFields = {strParamValue}; - return AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_EXPORT_ENCODING_NOT_SUPPORTED, - tabRequiredFields, AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_EXPORT_ENCODING_NOT_SUPPORTED, + tabRequiredFields, AdminMessage.TYPE_STOP); } - } - else - { - return AdminMessageService.getMessageUrl( request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP ); + } else { + return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP); } - param.setName( strParamValue ); - DirectoryParameterService.getService( ).update( param ); + param.setName(strParamValue); + DirectoryParameterService.getService().update(param); } - return getJspManageAdvancedParameters( request ); + return getJspManageAdvancedParameters(request); } /** * return the record visualisation + * * @param request the Http request * @return the record visualisation * @throws AccessDeniedException AccessDeniedException */ - public String getMyLuteceUserVisualisation( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdRecord = request.getParameter( PARAMETER_ID_DIRECTORY_RECORD ); - String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY ); - int nIdRecord = DirectoryUtils.convertStringToInt( strIdRecord ); - int nIdEntry = DirectoryUtils.convertStringToInt( strIdEntry ); - Record record = _recordService.findByPrimaryKey( nIdRecord, getPlugin( ) ); + public String getMyLuteceUserVisualisation(HttpServletRequest request) + throws AccessDeniedException { + String strIdRecord = request.getParameter(PARAMETER_ID_DIRECTORY_RECORD); + String strIdEntry = request.getParameter(PARAMETER_ID_ENTRY); + int nIdRecord = DirectoryUtils.convertStringToInt(strIdRecord); + int nIdEntry = DirectoryUtils.convertStringToInt(strIdEntry); + Record record = _recordService.findByPrimaryKey(nIdRecord, getPlugin()); - if ( ( record == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( record.getDirectory( ).getIdDirectory( ) ), - DirectoryResourceIdService.PERMISSION_VISUALISATION_MYLUTECE_USER, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((record == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(record.getDirectory().getIdDirectory()), + DirectoryResourceIdService.PERMISSION_VISUALISATION_MYLUTECE_USER, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - String strUserGuid = DirectoryService.getInstance( ).getUserGuid( nIdRecord, nIdEntry ); - ReferenceList listUserInfos = DirectoryService.getInstance( ).getUserInfos( strUserGuid, nIdEntry ); + String strUserGuid = DirectoryService.getInstance().getUserGuid(nIdRecord, nIdEntry); + ReferenceList listUserInfos = DirectoryService.getInstance().getUserInfos(strUserGuid, nIdEntry); - Map model = new HashMap( ); - model.put( MARK_MYLUTECE_USER_LOGIN, strUserGuid ); - model.put( MARK_MYLUTECE_USER_INFOS_LIST, listUserInfos ); + Map model = new HashMap(); + model.put(MARK_MYLUTECE_USER_LOGIN, strUserGuid); + model.put(MARK_MYLUTECE_USER_INFOS_LIST, listUserInfos); - HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_VIEW_MYLUTECE_USER, getLocale( ), model ); + HtmlTemplate templateList = AppTemplateService.getTemplate(TEMPLATE_VIEW_MYLUTECE_USER, getLocale(), model); - return getAdminPage( templateList.getHtml( ) ); + return getAdminPage(templateList.getHtml()); } /** * Return the interface for import field + * * @param request The Http request * @throws AccessDeniedException the {@link AccessDeniedException} * @return Html directory */ - public String getImportField( HttpServletRequest request ) - throws AccessDeniedException - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - Directory directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); - String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY ); - int nIdEntry = DirectoryUtils.convertStringToInt( strIdEntry ); - IEntry entry = EntryHome.findByPrimaryKey( nIdEntry, getPlugin( ) ); - - if ( ( directory == null ) || ( entry == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_IMPORT_FIELD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); - } - - Map model = new HashMap( ); - - if ( request.getParameter( PARAMETER_SESSION ) != null ) - { - if ( _searchFields.getError( ) != null ) - { - model.put( MARK_STR_ERROR, _searchFields.getError( ).toString( ) ); + public String getImportField(HttpServletRequest request) + throws AccessDeniedException { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); + String strIdEntry = request.getParameter(PARAMETER_ID_ENTRY); + int nIdEntry = DirectoryUtils.convertStringToInt(strIdEntry); + IEntry entry = EntryHome.findByPrimaryKey(nIdEntry, getPlugin()); + + if ((directory == null) || (entry == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_IMPORT_FIELD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); + } + + Map model = new HashMap(); + + if (request.getParameter(PARAMETER_SESSION) != null) { + if (_searchFields.getError() != null) { + model.put(MARK_STR_ERROR, _searchFields.getError().toString()); } - model.put( MARK_NUMBER_LINES_ERROR, _searchFields.getCountLineFailure( ) ); - model.put( MARK_NUMBER_LINES_IMPORTED, - _searchFields.getCountLine( ) - _searchFields.getCountLineFailure( ) ); - model.put( MARK_FINISH_IMPORT, true ); - _searchFields.setCountLine( 0 ); - _searchFields.setCountLineFailure( 0 ); - _searchFields.setError( null ); + model.put(MARK_NUMBER_LINES_ERROR, _searchFields.getCountLineFailure()); + model.put(MARK_NUMBER_LINES_IMPORTED, + _searchFields.getCountLine() - _searchFields.getCountLineFailure()); + model.put(MARK_FINISH_IMPORT, true); + _searchFields.setCountLine(0); + _searchFields.setCountLineFailure(0); + _searchFields.setError(null); } - model.put( MARK_LOCALE, getLocale( ) ); - model.put( MARK_DIRECTORY, directory ); - model.put( MARK_ENTRY, entry ); - setPageTitleProperty( PROPERTY_IMPORT_FIELD_PAGE_TITLE ); + model.put(MARK_LOCALE, getLocale()); + model.put(MARK_DIRECTORY, directory); + model.put(MARK_ENTRY, entry); + setPageTitleProperty(PROPERTY_IMPORT_FIELD_PAGE_TITLE); - HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_IMPORT_FIELD, getLocale( ), model ); + HtmlTemplate templateList = AppTemplateService.getTemplate(TEMPLATE_IMPORT_FIELD, getLocale(), model); - return getAdminPage( templateList.getHtml( ) ); + return getAdminPage(templateList.getHtml()); } /** * ImportDirectory record + * * @param request the Http Request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doImportField( HttpServletRequest request ) - throws AccessDeniedException - { + public String doImportField(HttpServletRequest request) + throws AccessDeniedException { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; - FileItem fileItem = multipartRequest.getFile( PARAMETER_FILE_IMPORT ); - String strMimeType = FileSystemUtil.getMIMEType( FileUploadService.getFileNameOnly( fileItem ) ); + FileItem fileItem = multipartRequest.getFile(PARAMETER_FILE_IMPORT); + String strMimeType = FileSystemUtil.getMIMEType(FileUploadService.getFileNameOnly(fileItem)); - if ( ( fileItem == null ) || ( fileItem.getName( ) == null ) || - DirectoryUtils.EMPTY_STRING.equals( fileItem.getName( ) ) ) - { - Object[] tabRequiredFields = { I18nService.getLocalizedString( FIELD_FILE_IMPORT, getLocale( ) ) }; + if ((fileItem == null) || (fileItem.getName() == null) + || DirectoryUtils.EMPTY_STRING.equals(fileItem.getName())) { + Object[] tabRequiredFields = {I18nService.getLocalizedString(FIELD_FILE_IMPORT, getLocale())}; - return AdminMessageService.getMessageUrl( request, MESSAGE_MANDATORY_FIELD, tabRequiredFields, - AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, MESSAGE_MANDATORY_FIELD, tabRequiredFields, + AdminMessage.TYPE_STOP); } - if ( ( !strMimeType.equals( CONSTANT_MIME_TYPE_CSV ) && !strMimeType.equals( CONSTANT_MIME_TYPE_OCTETSTREAM ) && - !strMimeType.equals( CONSTANT_MIME_TYPE_TEXT_CSV ) ) || - !fileItem.getName( ).toLowerCase( ).endsWith( CONSTANT_EXTENSION_CSV_FILE ) ) - { - return AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_CSV_FILE_IMPORT, AdminMessage.TYPE_STOP ); + if ((!strMimeType.equals(CONSTANT_MIME_TYPE_CSV) && !strMimeType.equals(CONSTANT_MIME_TYPE_OCTETSTREAM) + && !strMimeType.equals(CONSTANT_MIME_TYPE_TEXT_CSV)) + || !fileItem.getName().toLowerCase().endsWith(CONSTANT_EXTENSION_CSV_FILE)) { + return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_CSV_FILE_IMPORT, AdminMessage.TYPE_STOP); } - String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY ); - int nIdEntry = DirectoryUtils.convertStringToInt( strIdEntry ); - IEntry entry = EntryHome.findByPrimaryKey( nIdEntry, getPlugin( ) ); - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - Directory directory = DirectoryHome.findByPrimaryKey( nIdDirectory, getPlugin( ) ); + String strIdEntry = request.getParameter(PARAMETER_ID_ENTRY); + int nIdEntry = DirectoryUtils.convertStringToInt(strIdEntry); + IEntry entry = EntryHome.findByPrimaryKey(nIdEntry, getPlugin()); + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, getPlugin()); - if ( ( entry == null ) || ( directory == null ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, strIdDirectory, - DirectoryResourceIdService.PERMISSION_MODIFY, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((entry == null) || (directory == null) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, strIdDirectory, + DirectoryResourceIdService.PERMISSION_MODIFY, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - Character strCsvSeparator = AppPropertiesService.getProperty( PROPERTY_IMPORT_CSV_DELIMITER ).charAt( 0 ); - _searchFields.setError( new StringBuffer( ) ); + Character strCsvSeparator = AppPropertiesService.getProperty(PROPERTY_IMPORT_CSV_DELIMITER).charAt(0); + _searchFields.setError(new StringBuffer()); - try - { - InputStreamReader inputStreamReader = new InputStreamReader( fileItem.getInputStream( ) ); - CSVReader csvReader = new CSVReader( inputStreamReader, strCsvSeparator, '\"' ); + try { + InputStreamReader inputStreamReader = new InputStreamReader(fileItem.getInputStream()); + CSVReader csvReader = new CSVReader(inputStreamReader, strCsvSeparator, '\"'); String[] nextLine; - _searchFields.setCountLine( 0 ); - _searchFields.setCountLineFailure( 0 ); - - while ( ( nextLine = csvReader.readNext( ) ) != null ) - { - _searchFields.setCountLine( _searchFields.getCountLine( ) + 1 ); - - if ( nextLine.length != IMPORT_FIELD_NB_COLUMN_MAX ) - { - _searchFields.getError( ).append( I18nService.getLocalizedString( PROPERTY_LINE, getLocale( ) ) ); - _searchFields.getError( ).append( _searchFields.getCountLine( ) ); - _searchFields.getError( ).append( " > " ); - _searchFields.getError( ) - .append( I18nService.getLocalizedString( MESSAGE_ERROR_CSV_NUMBER_SEPARATOR, - getLocale( ) ) ); - _searchFields.getError( ).append( "
" ); - _searchFields.setCountLineFailure( _searchFields.getCountLineFailure( ) + 1 ); - } - else - { - Field field = new Field( ); - field.setEntry( entry ); - - try - { - getImportFieldData( request, field, nextLine ); - FieldHome.create( field, getPlugin( ) ); - } - catch ( DirectoryErrorException error ) - { - _searchFields.getError( ).append( I18nService.getLocalizedString( PROPERTY_LINE, getLocale( ) ) ); - _searchFields.getError( ).append( _searchFields.getCountLine( ) ); - _searchFields.getError( ).append( " > " ); - - if ( error.isMandatoryError( ) ) - { - Object[] tabRequiredFields = { error.getTitleField( ) }; - _searchFields.getError( ) - .append( I18nService.getLocalizedString( - MESSAGE_DIRECTORY_ERROR_MANDATORY_FIELD, tabRequiredFields, getLocale( ) ) ); - } - else - { - Object[] tabRequiredFields = { error.getTitleField( ), error.getErrorMessage( ) }; - _searchFields.getError( ) - .append( I18nService.getLocalizedString( MESSAGE_DIRECTORY_ERROR, - tabRequiredFields, getLocale( ) ) ); + _searchFields.setCountLine(0); + _searchFields.setCountLineFailure(0); + + while ((nextLine = csvReader.readNext()) != null) { + _searchFields.setCountLine(_searchFields.getCountLine() + 1); + + if (nextLine.length != IMPORT_FIELD_NB_COLUMN_MAX) { + _searchFields.getError().append(I18nService.getLocalizedString(PROPERTY_LINE, getLocale())); + _searchFields.getError().append(_searchFields.getCountLine()); + _searchFields.getError().append(" > "); + _searchFields.getError() + .append(I18nService.getLocalizedString(MESSAGE_ERROR_CSV_NUMBER_SEPARATOR, + getLocale())); + _searchFields.getError().append("
"); + _searchFields.setCountLineFailure(_searchFields.getCountLineFailure() + 1); + } else { + Field field = new Field(); + field.setEntry(entry); + + try { + getImportFieldData(request, field, nextLine); + FieldHome.create(field, getPlugin()); + } catch (DirectoryErrorException error) { + _searchFields.getError().append(I18nService.getLocalizedString(PROPERTY_LINE, getLocale())); + _searchFields.getError().append(_searchFields.getCountLine()); + _searchFields.getError().append(" > "); + + if (error.isMandatoryError()) { + Object[] tabRequiredFields = {error.getTitleField()}; + _searchFields.getError() + .append(I18nService.getLocalizedString( + MESSAGE_DIRECTORY_ERROR_MANDATORY_FIELD, tabRequiredFields, getLocale())); + } else { + Object[] tabRequiredFields = {error.getTitleField(), error.getErrorMessage()}; + _searchFields.getError() + .append(I18nService.getLocalizedString(MESSAGE_DIRECTORY_ERROR, + tabRequiredFields, getLocale())); } - _searchFields.getError( ).append( "
" ); - _searchFields.setCountLineFailure( _searchFields.getCountLineFailure( ) + 1 ); + _searchFields.getError().append("
"); + _searchFields.setCountLineFailure(_searchFields.getCountLineFailure() + 1); } } } + } catch (IOException e) { + AppLogService.error(e); } - catch ( IOException e ) - { - AppLogService.error( e ); - } - - return AppPathService.getBaseUrl( request ) + JSP_IMPORT_FIELD + DirectoryUtils.CONSTANT_INTERROGATION_MARK + - PARAMETER_ID_DIRECTORY + DirectoryUtils.CONSTANT_EQUAL + nIdDirectory + DirectoryUtils.CONSTANT_AMPERSAND + - PARAMETER_ID_ENTRY + DirectoryUtils.CONSTANT_EQUAL + nIdEntry + DirectoryUtils.CONSTANT_AMPERSAND + - PARAMETER_SESSION + "=" + PARAMETER_SESSION; + return AppPathService.getBaseUrl(request) + JSP_IMPORT_FIELD + DirectoryUtils.CONSTANT_INTERROGATION_MARK + + PARAMETER_ID_DIRECTORY + DirectoryUtils.CONSTANT_EQUAL + nIdDirectory + DirectoryUtils.CONSTANT_AMPERSAND + + PARAMETER_ID_ENTRY + DirectoryUtils.CONSTANT_EQUAL + nIdEntry + DirectoryUtils.CONSTANT_AMPERSAND + + PARAMETER_SESSION + "=" + PARAMETER_SESSION; } /** * Gets the confirmation page of changing the state of the records + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return the confirmation page of changing the state of the records */ - public String getConfirmChangeStatesRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String[] listIdsDirectoryRecord = request.getParameterValues( PARAMETER_ID_DIRECTORY_RECORD ); + public String getConfirmChangeStatesRecord(HttpServletRequest request) + throws AccessDeniedException { + String[] listIdsDirectoryRecord = request.getParameterValues(PARAMETER_ID_DIRECTORY_RECORD); - if ( ( listIdsDirectoryRecord != null ) && ( listIdsDirectoryRecord.length > 0 ) ) - { - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); + if ((listIdsDirectoryRecord != null) && (listIdsDirectoryRecord.length > 0)) { + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); // If the id directory is not in the parameter, then fetch it from the first record // assuming all records are from the same directory - if ( StringUtils.isBlank( strIdDirectory ) || !StringUtils.isNumeric( strIdDirectory ) ) - { + if (StringUtils.isBlank(strIdDirectory) || !StringUtils.isNumeric(strIdDirectory)) { String strIdDirectoryRecord = listIdsDirectoryRecord[0]; - int nIdDirectoryRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - Record record = _recordService.findByPrimaryKey( nIdDirectoryRecord, getPlugin( ) ); - strIdDirectory = Integer.toString( record.getDirectory( ).getIdDirectory( ) ); + int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + Record record = _recordService.findByPrimaryKey(nIdDirectoryRecord, getPlugin()); + strIdDirectory = Integer.toString(record.getDirectory().getIdDirectory()); } - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); - UrlItem url = new UrlItem( JSP_DO_CHANGE_STATES_RECORD ); - url.addParameter( DirectoryUtils.PARAMETER_ID_DIRECTORY, nIdDirectory ); + UrlItem url = new UrlItem(JSP_DO_CHANGE_STATES_RECORD); + url.addParameter(DirectoryUtils.PARAMETER_ID_DIRECTORY, nIdDirectory); - for ( String strIdDirectoryRecord : listIdsDirectoryRecord ) - { - int nIdDirectoryRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - Record record = _recordService.findByPrimaryKey( nIdDirectoryRecord, getPlugin( ) ); + for (String strIdDirectoryRecord : listIdsDirectoryRecord) { + int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + Record record = _recordService.findByPrimaryKey(nIdDirectoryRecord, getPlugin()); - if ( ( record == null ) || ( record.getDirectory( ).getIdDirectory( ) != nIdDirectory ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( record.getDirectory( ).getIdDirectory( ) ), - DirectoryResourceIdService.PERMISSION_CHANGE_STATE_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + if ((record == null) || (record.getDirectory().getIdDirectory() != nIdDirectory) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(record.getDirectory().getIdDirectory()), + DirectoryResourceIdService.PERMISSION_CHANGE_STATE_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - url.addParameter( PARAMETER_ID_DIRECTORY_RECORD, nIdDirectoryRecord ); + url.addParameter(PARAMETER_ID_DIRECTORY_RECORD, nIdDirectoryRecord); } - return AdminMessageService.getMessageUrl( request, MESSAGE_CONFIRM_CHANGE_STATES_RECORD, url.getUrl( ), - AdminMessage.TYPE_CONFIRMATION ); + return AdminMessageService.getMessageUrl(request, MESSAGE_CONFIRM_CHANGE_STATES_RECORD, url.getUrl(), + AdminMessage.TYPE_CONFIRMATION); } - return AdminMessageService.getMessageUrl( request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP); } /** * Perform the directory record supression + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String doChangeStatesRecord( HttpServletRequest request ) - throws AccessDeniedException - { - String[] listIdsDirectoryRecord = request.getParameterValues( PARAMETER_ID_DIRECTORY_RECORD ); - - if ( ( listIdsDirectoryRecord != null ) && ( listIdsDirectoryRecord.length > 0 ) ) - { - String strIdDirectory = request.getParameter( DirectoryUtils.PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); - - for ( String strIdDirectoryRecord : listIdsDirectoryRecord ) - { - int nIdDirectoryRecord = DirectoryUtils.convertStringToInt( strIdDirectoryRecord ); - Record record = _recordService.findByPrimaryKey( nIdDirectoryRecord, getPlugin( ) ); - - if ( ( record == null ) || ( record.getDirectory( ).getIdDirectory( ) != nIdDirectory ) || - !RBACService.isAuthorized( Directory.RESOURCE_TYPE, - Integer.toString( record.getDirectory( ).getIdDirectory( ) ), - DirectoryResourceIdService.PERMISSION_CHANGE_STATE_RECORD, getUser( ) ) ) - { - throw new AccessDeniedException( MESSAGE_ACCESS_DENIED ); + public String doChangeStatesRecord(HttpServletRequest request) + throws AccessDeniedException { + String[] listIdsDirectoryRecord = request.getParameterValues(PARAMETER_ID_DIRECTORY_RECORD); + + if ((listIdsDirectoryRecord != null) && (listIdsDirectoryRecord.length > 0)) { + String strIdDirectory = request.getParameter(DirectoryUtils.PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); + + for (String strIdDirectoryRecord : listIdsDirectoryRecord) { + int nIdDirectoryRecord = DirectoryUtils.convertStringToInt(strIdDirectoryRecord); + Record record = _recordService.findByPrimaryKey(nIdDirectoryRecord, getPlugin()); + + if ((record == null) || (record.getDirectory().getIdDirectory() != nIdDirectory) + || !RBACService.isAuthorized(Directory.RESOURCE_TYPE, + Integer.toString(record.getDirectory().getIdDirectory()), + DirectoryResourceIdService.PERMISSION_CHANGE_STATE_RECORD, getUser())) { + throw new AccessDeniedException(MESSAGE_ACCESS_DENIED); } - record.setEnabled( !record.isEnabled( ) ); - _recordService.update( record, getPlugin( ) ); + record.setEnabled(!record.isEnabled()); + _recordService.update(record, getPlugin()); } - return DirectoryUtils.getJspManageDirectoryRecord( request, nIdDirectory ); + return DirectoryUtils.getJspManageDirectoryRecord(request, nIdDirectory); } - return AdminMessageService.getMessageUrl( request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP ); + return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP); } /** * Get the request data and if there is no error insert the data in the - * field specified in parameter. - * return null if there is no error or else return the error page url + * field specified in parameter. return null if there is no error or else + * return the error page url + * * @param request the request * @param field field * @param listImportValue the list of imports values * @throws DirectoryErrorException DirectoryErrorException */ - private void getImportFieldData( HttpServletRequest request, Field field, String[] listImportValue ) - throws DirectoryErrorException - { + private void getImportFieldData(HttpServletRequest request, Field field, String[] listImportValue) + throws DirectoryErrorException { String strTitle = listImportValue[0]; String strValue = listImportValue[1]; - if ( ( strTitle == null ) || DirectoryUtils.EMPTY_STRING.equals( strTitle ) ) - { - throw new DirectoryErrorException( I18nService.getLocalizedString( FIELD_TITLE_FIELD, getLocale( ) ) ); - } - else if ( ( strValue == null ) || DirectoryUtils.EMPTY_STRING.equals( strValue ) ) - { - throw new DirectoryErrorException( I18nService.getLocalizedString( FIELD_VALUE_FIELD, getLocale( ) ) ); - } - else if ( !StringUtil.checkCodeKey( strValue ) ) - { - throw new DirectoryErrorException( I18nService.getLocalizedString( FIELD_VALUE_FIELD, getLocale( ) ), - I18nService.getLocalizedString( MESSAGE_FIELD_VALUE_FIELD, getLocale( ) ) ); + if ((strTitle == null) || DirectoryUtils.EMPTY_STRING.equals(strTitle)) { + throw new DirectoryErrorException(I18nService.getLocalizedString(FIELD_TITLE_FIELD, getLocale())); + } else if ((strValue == null) || DirectoryUtils.EMPTY_STRING.equals(strValue)) { + throw new DirectoryErrorException(I18nService.getLocalizedString(FIELD_VALUE_FIELD, getLocale())); + } else if (!StringUtil.checkCodeKey(strValue)) { + throw new DirectoryErrorException(I18nService.getLocalizedString(FIELD_VALUE_FIELD, getLocale()), + I18nService.getLocalizedString(MESSAGE_FIELD_VALUE_FIELD, getLocale())); } - field.setTitle( strTitle ); - field.setValue( strValue ); - field.setDefaultValue( false ); + field.setTitle(strTitle); + field.setValue(strValue); + field.setDefaultValue(false); } /** * Get the redirect url + * * @param request the http servlet request * @return the redirect url */ - public String getRedirectUrl( HttpServletRequest request ) - { - if ( StringUtils.isNotBlank( _searchFields.getRedirectUrl( ) ) ) - { - return _searchFields.getRedirectUrl( ); + public String getRedirectUrl(HttpServletRequest request) { + if (StringUtils.isNotBlank(_searchFields.getRedirectUrl())) { + return _searchFields.getRedirectUrl(); } - return getJspManageDirectory( request ); + return getJspManageDirectory(request); } /** * Fill the directory record with data + * * @param record the record to fill * @param request the HTTP request * @return empty string if there is no redirect (in error cases or upload - * file cases), an url to redirect otherwise + * file cases), an url to redirect otherwise */ - private String getDirectoryRecordData( Record record, HttpServletRequest request ) - { - String strUploadAction = DirectoryAsynchronousUploadHandler.getHandler( ).getUploadAction( request ); + private String getDirectoryRecordData(Record record, HttpServletRequest request) { + String strUploadAction = DirectoryAsynchronousUploadHandler.getHandler().getUploadAction(request); - try - { - DirectoryUtils.getDirectoryRecordData( request, record, getPlugin( ), getLocale( ) ); - } - catch ( DirectoryErrorException error ) - { + try { + DirectoryUtils.getDirectoryRecordData(request, record, getPlugin(), getLocale()); + } catch (DirectoryErrorException error) { // Case if the user does not upload a file, then throw the error message - if ( StringUtils.isBlank( strUploadAction ) ) - { + if (StringUtils.isBlank(strUploadAction)) { String strErrorMessage = DirectoryUtils.EMPTY_STRING; - if ( error.isMandatoryError( ) ) - { - Object[] tabRequiredFields = { error.getTitleField( ) }; - strErrorMessage = AdminMessageService.getMessageUrl( request, - MESSAGE_DIRECTORY_ERROR_MANDATORY_FIELD, tabRequiredFields, AdminMessage.TYPE_STOP ); - } - else - { - Object[] tabRequiredFields = { error.getTitleField( ), error.getErrorMessage( ) }; - strErrorMessage = AdminMessageService.getMessageUrl( request, MESSAGE_DIRECTORY_ERROR, - tabRequiredFields, AdminMessage.TYPE_STOP ); + if (error.isMandatoryError()) { + Object[] tabRequiredFields = {error.getTitleField()}; + strErrorMessage = AdminMessageService.getMessageUrl(request, + MESSAGE_DIRECTORY_ERROR_MANDATORY_FIELD, tabRequiredFields, AdminMessage.TYPE_STOP); + } else { + Object[] tabRequiredFields = {error.getTitleField(), error.getErrorMessage()}; + strErrorMessage = AdminMessageService.getMessageUrl(request, MESSAGE_DIRECTORY_ERROR, + tabRequiredFields, AdminMessage.TYPE_STOP); } return strErrorMessage; @@ -5241,50 +4977,42 @@ private String getDirectoryRecordData( Record record, HttpServletRequest request // Special case for upload fields : if no action is specified, a submit // button associated with an upload might have been pressed : - if ( StringUtils.isNotBlank( strUploadAction ) ) - { - Map> mapListRecordFields = DirectoryUtils.buildMapIdEntryListRecordField( record ); + if (StringUtils.isNotBlank(strUploadAction)) { + Map> mapListRecordFields = DirectoryUtils.buildMapIdEntryListRecordField(record); // Upload the file - try - { - DirectoryAsynchronousUploadHandler.getHandler( ) - .doUploadAction( request, strUploadAction, mapListRecordFields, - record, getPlugin( ) ); - } - catch ( DirectoryErrorException error ) - { + try { + DirectoryAsynchronousUploadHandler.getHandler() + .doUploadAction(request, strUploadAction, mapListRecordFields, + record, getPlugin()); + } catch (DirectoryErrorException error) { String strErrorMessage = DirectoryUtils.EMPTY_STRING; - if ( error.isMandatoryError( ) ) - { - Object[] tabRequiredFields = { error.getTitleField( ) }; - strErrorMessage = AdminMessageService.getMessageUrl( request, - MESSAGE_DIRECTORY_ERROR_MANDATORY_FIELD, tabRequiredFields, AdminMessage.TYPE_STOP ); - } - else - { - Object[] tabRequiredFields = { error.getTitleField( ), error.getErrorMessage( ) }; - strErrorMessage = AdminMessageService.getMessageUrl( request, MESSAGE_DIRECTORY_ERROR, - tabRequiredFields, AdminMessage.TYPE_STOP ); + if (error.isMandatoryError()) { + Object[] tabRequiredFields = {error.getTitleField()}; + strErrorMessage = AdminMessageService.getMessageUrl(request, + MESSAGE_DIRECTORY_ERROR_MANDATORY_FIELD, tabRequiredFields, AdminMessage.TYPE_STOP); + } else { + Object[] tabRequiredFields = {error.getTitleField(), error.getErrorMessage()}; + strErrorMessage = AdminMessageService.getMessageUrl(request, MESSAGE_DIRECTORY_ERROR, + tabRequiredFields, AdminMessage.TYPE_STOP); } return strErrorMessage; } // Put the map in the session - request.getSession( ) - .setAttribute( DirectoryUtils.SESSION_DIRECTORY_LIST_SUBMITTED_RECORD_FIELDS, mapListRecordFields ); + request.getSession() + .setAttribute(DirectoryUtils.SESSION_DIRECTORY_LIST_SUBMITTED_RECORD_FIELDS, mapListRecordFields); // Check whether it is an update or a creation - if ( ( record.getIdRecord( ) != DirectoryUtils.CONSTANT_ID_NULL ) && - ( record.getIdRecord( ) != DirectoryUtils.CONSTANT_ID_ZERO ) ) - { - return getJspModifyDirectoryRecord( request, record.getDirectory( ).getIdDirectory( ), - record.getIdRecord( ) ); + if ((record.getIdRecord() != DirectoryUtils.CONSTANT_ID_NULL) + && (record.getIdRecord() != DirectoryUtils.CONSTANT_ID_ZERO)) { + return getJspModifyDirectoryRecord(request, record.getDirectory().getIdDirectory(), + record.getIdRecord()); } - return getJspCreateDirectoryRecord( request, record.getDirectory( ).getIdDirectory( ) ); + return getJspCreateDirectoryRecord(request, record.getDirectory().getIdDirectory()); } return StringUtils.EMPTY; @@ -5292,15 +5020,14 @@ private String getDirectoryRecordData( Record record, HttpServletRequest request /** * Init the list of the attribute's orders (first level only) + * * @param listEntryFirstLevel the list of all the attributes of the first - * level + * level * @param orderFirstLevel the list to set */ - private void initOrderFirstLevel( List listEntryFirstLevel, List orderFirstLevel ) - { - for ( IEntry entry : listEntryFirstLevel ) - { - orderFirstLevel.add( entry.getPosition( ) ); + private void initOrderFirstLevel(List listEntryFirstLevel, List orderFirstLevel) { + for (IEntry entry : listEntryFirstLevel) { + orderFirstLevel.add(entry.getPosition()); } } @@ -5337,33 +5064,27 @@ private void initOrderFirstLevel( List listEntryFirstLevel, List ) except for entry with * parent null + * * @param listEntry the list of all entry * @param mapIdParentOrdersChildren map with (idParent : List) */ - private void populateEntryMap( List listEntry, Map> mapIdParentOrdersChildren ) - { + private void populateEntryMap(List listEntry, Map> mapIdParentOrdersChildren) { List listOrder; - for ( IEntry entry : listEntry ) - { - if ( entry.getParent( ) != null ) - { - Integer key = Integer.valueOf( entry.getParent( ).getIdEntry( ) ); - String strKey = key.toString( ); - - if ( mapIdParentOrdersChildren.get( strKey ) != null ) - { - mapIdParentOrdersChildren.get( key.toString( ) ).add( entry.getPosition( ) ); - } - else - { - listOrder = new ArrayList( ); - listOrder.add( entry.getPosition( ) ); - mapIdParentOrdersChildren.put( key.toString( ), listOrder ); + for (IEntry entry : listEntry) { + if (entry.getParent() != null) { + Integer key = Integer.valueOf(entry.getParent().getIdEntry()); + String strKey = key.toString(); + + if (mapIdParentOrdersChildren.get(strKey) != null) { + mapIdParentOrdersChildren.get(key.toString()).add(entry.getPosition()); + } else { + listOrder = new ArrayList(); + listOrder.add(entry.getPosition()); + mapIdParentOrdersChildren.put(key.toString(), listOrder); } } } @@ -5371,231 +5092,242 @@ private void populateEntryMap( List listEntry, Map /** * Change the attribute's order to a greater one (move down in the list) + * * @param plugin the plugin * @param nOrderToSet the new order for the attribute * @param entryToChangeOrder the attribute which will change * @param nIdDirectory the id of the directory */ - private void moveDownEntryOrder( Plugin plugin, int nOrderToSet, IEntry entryToChangeOrder, int nIdDirectory ) - { - if ( entryToChangeOrder.getParent( ) == null ) - { + private void moveDownEntryOrder(Plugin plugin, int nOrderToSet, IEntry entryToChangeOrder, int nIdDirectory) { + if (entryToChangeOrder.getParent() == null) { int nNbChild = 0; int nNewOrder = 0; - List listEntryFirstLevel = EntryHome.findEntriesWithoutParent( plugin, nIdDirectory ); + List listEntryFirstLevel = EntryHome.findEntriesWithoutParent(plugin, nIdDirectory); - List orderFirstLevel = new ArrayList( ); - initOrderFirstLevel( listEntryFirstLevel, orderFirstLevel ); + List orderFirstLevel = new ArrayList(); + initOrderFirstLevel(listEntryFirstLevel, orderFirstLevel); Integer nbChildEntryToChangeOrder = 0; - if ( entryToChangeOrder.getChildren( ) != null ) - { - nbChildEntryToChangeOrder = entryToChangeOrder.getChildren( ).size( ); + if (entryToChangeOrder.getChildren() != null) { + nbChildEntryToChangeOrder = entryToChangeOrder.getChildren().size(); } - for ( IEntry entry : listEntryFirstLevel ) - { - for ( int i = 0; i < orderFirstLevel.size( ); i++ ) - { - if ( ( orderFirstLevel.get( i ) == entry.getPosition( ) ) && - ( entry.getPosition( ) > entryToChangeOrder.getPosition( ) ) && - ( entry.getPosition( ) <= nOrderToSet ) ) - { - if ( nNbChild == 0 ) - { - nNewOrder = orderFirstLevel.get( i - 1 ); - - if ( orderFirstLevel.get( i - 1 ) != entryToChangeOrder.getPosition( ) ) - { + for (IEntry entry : listEntryFirstLevel) { + for (int i = 0; i < orderFirstLevel.size(); i++) { + if ((orderFirstLevel.get(i) == entry.getPosition()) + && (entry.getPosition() > entryToChangeOrder.getPosition()) + && (entry.getPosition() <= nOrderToSet)) { + if (nNbChild == 0) { + nNewOrder = orderFirstLevel.get(i - 1); + + if (orderFirstLevel.get(i - 1) != entryToChangeOrder.getPosition()) { nNewOrder -= nbChildEntryToChangeOrder; } - } - else - { - nNewOrder += ( nNbChild + 1 ); + } else { + nNewOrder += (nNbChild + 1); } - entry.setPosition( nNewOrder ); - EntryHome.update( entry, plugin ); + entry.setPosition(nNewOrder); + EntryHome.update(entry, plugin); nNbChild = 0; - if ( entry.getChildren( ) != null ) - { - for ( IEntry child : entry.getChildren( ) ) - { + if (entry.getChildren() != null) { + for (IEntry child : entry.getChildren()) { nNbChild++; - child.setPosition( nNewOrder + nNbChild ); - EntryHome.update( child, plugin ); + child.setPosition(nNewOrder + nNbChild); + EntryHome.update(child, plugin); } } } } } - entryToChangeOrder.setPosition( nNewOrder + nNbChild + 1 ); - EntryHome.update( entryToChangeOrder, plugin ); + entryToChangeOrder.setPosition(nNewOrder + nNbChild + 1); + EntryHome.update(entryToChangeOrder, plugin); nNbChild = 0; - for ( IEntry child : entryToChangeOrder.getChildren( ) ) - { + for (IEntry child : entryToChangeOrder.getChildren()) { nNbChild++; - child.setPosition( entryToChangeOrder.getPosition( ) + nNbChild ); - EntryHome.update( child, plugin ); + child.setPosition(entryToChangeOrder.getPosition() + nNbChild); + EntryHome.update(child, plugin); } - } - else - { - EntryFilter filter = new EntryFilter( ); - filter.setIdDirectory( nIdDirectory ); + } else { + EntryFilter filter = new EntryFilter(); + filter.setIdDirectory(nIdDirectory); - List listAllEntry = EntryHome.getEntryList( filter, plugin ); + List listAllEntry = EntryHome.getEntryList(filter, plugin); - for ( IEntry entry : listAllEntry ) - { - if ( ( entry.getPosition( ) > entryToChangeOrder.getPosition( ) ) && - ( entry.getPosition( ) <= nOrderToSet ) ) - { - entry.setPosition( entry.getPosition( ) - 1 ); - EntryHome.update( entry, plugin ); + for (IEntry entry : listAllEntry) { + if ((entry.getPosition() > entryToChangeOrder.getPosition()) + && (entry.getPosition() <= nOrderToSet)) { + entry.setPosition(entry.getPosition() - 1); + EntryHome.update(entry, plugin); } } - entryToChangeOrder.setPosition( nOrderToSet ); - EntryHome.update( entryToChangeOrder, plugin ); + entryToChangeOrder.setPosition(nOrderToSet); + EntryHome.update(entryToChangeOrder, plugin); } } /** * Change the attribute's order to a lower one (move up in the list) + * * @param plugin the plugin * @param nOrderToSet the new order for the attribute * @param entryToChangeOrder the attribute which will change * @param nIdDirectory the id of the form */ - private void moveUpEntryOrder( Plugin plugin, int nOrderToSet, IEntry entryToChangeOrder, int nIdDirectory ) - { - if ( entryToChangeOrder.getParent( ) == null ) - { - List orderFirstLevel = new ArrayList( ); + private void moveUpEntryOrder(Plugin plugin, int nOrderToSet, IEntry entryToChangeOrder, int nIdDirectory) { + if (entryToChangeOrder.getParent() == null) { + List orderFirstLevel = new ArrayList(); int nNbChild = 0; int nNewOrder = nOrderToSet; - int nEntryToMoveOrder = entryToChangeOrder.getPosition( ); + int nEntryToMoveOrder = entryToChangeOrder.getPosition(); - EntryFilter filter = new EntryFilter( ); - filter.setIdDirectory( nIdDirectory ); + EntryFilter filter = new EntryFilter(); + filter.setIdDirectory(nIdDirectory); - List listEntryFirstLevel = EntryHome.findEntriesWithoutParent( plugin, nIdDirectory ); + List listEntryFirstLevel = EntryHome.findEntriesWithoutParent(plugin, nIdDirectory); //the list of all the orders in the first level - initOrderFirstLevel( listEntryFirstLevel, orderFirstLevel ); - - for ( IEntry entry : listEntryFirstLevel ) - { - Integer entryInitialPosition = entry.getPosition( ); - - for ( int i = 0; i < orderFirstLevel.size( ); i++ ) - { - if ( ( orderFirstLevel.get( i ) == entryInitialPosition ) && - ( entryInitialPosition < nEntryToMoveOrder ) && ( entryInitialPosition >= nOrderToSet ) ) - { - if ( entryToChangeOrder.getPosition( ) == nEntryToMoveOrder ) - { - entryToChangeOrder.setPosition( nNewOrder ); - EntryHome.update( entryToChangeOrder, plugin ); - - for ( IEntry child : entryToChangeOrder.getChildren( ) ) - { + initOrderFirstLevel(listEntryFirstLevel, orderFirstLevel); + + for (IEntry entry : listEntryFirstLevel) { + Integer entryInitialPosition = entry.getPosition(); + + for (int i = 0; i < orderFirstLevel.size(); i++) { + if ((orderFirstLevel.get(i) == entryInitialPosition) + && (entryInitialPosition < nEntryToMoveOrder) && (entryInitialPosition >= nOrderToSet)) { + if (entryToChangeOrder.getPosition() == nEntryToMoveOrder) { + entryToChangeOrder.setPosition(nNewOrder); + EntryHome.update(entryToChangeOrder, plugin); + + for (IEntry child : entryToChangeOrder.getChildren()) { nNbChild++; - child.setPosition( entryToChangeOrder.getPosition( ) + nNbChild ); - EntryHome.update( child, plugin ); + child.setPosition(entryToChangeOrder.getPosition() + nNbChild); + EntryHome.update(child, plugin); } } nNewOrder = nNewOrder + nNbChild + 1; - entry.setPosition( nNewOrder ); - EntryHome.update( entry, plugin ); + entry.setPosition(nNewOrder); + EntryHome.update(entry, plugin); nNbChild = 0; - if ( entry.getChildren( ) != null ) - { - for ( IEntry child : entry.getChildren( ) ) - { + if (entry.getChildren() != null) { + for (IEntry child : entry.getChildren()) { nNbChild++; - child.setPosition( nNewOrder + nNbChild ); - EntryHome.update( child, plugin ); + child.setPosition(nNewOrder + nNbChild); + EntryHome.update(child, plugin); } } } } } - } - else - { - EntryFilter filter = new EntryFilter( ); - filter.setIdDirectory( nIdDirectory ); + } else { + EntryFilter filter = new EntryFilter(); + filter.setIdDirectory(nIdDirectory); - List listAllEntry = EntryHome.getEntryList( filter, plugin ); + List listAllEntry = EntryHome.getEntryList(filter, plugin); - for ( IEntry entry : listAllEntry ) - { - if ( ( entry.getPosition( ) < entryToChangeOrder.getPosition( ) ) && - ( entry.getPosition( ) >= nOrderToSet ) ) - { - entry.setPosition( entry.getPosition( ) + 1 ); - EntryHome.update( entry, plugin ); + for (IEntry entry : listAllEntry) { + if ((entry.getPosition() < entryToChangeOrder.getPosition()) + && (entry.getPosition() >= nOrderToSet)) { + entry.setPosition(entry.getPosition() + 1); + EntryHome.update(entry, plugin); } } - entryToChangeOrder.setPosition( nOrderToSet ); - EntryHome.update( entryToChangeOrder, plugin ); + entryToChangeOrder.setPosition(nOrderToSet); + EntryHome.update(entryToChangeOrder, plugin); } } /** * Updates the entries position for a directory + * * @param request The HTTP request * @throws AccessDeniedException the {@link AccessDeniedException} * @return The URL to go after performing the action */ - public String updateEntryOrder( HttpServletRequest request ) - throws AccessDeniedException - { - Plugin plugin = getPlugin( ); - String strIdDirectory = request.getParameter( PARAMETER_ID_DIRECTORY ); - int nIdDirectory = DirectoryUtils.convertStringToInt( strIdDirectory ); + public String updateEntryOrder(HttpServletRequest request) + throws AccessDeniedException { + Plugin plugin = getPlugin(); + String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); + int nIdDirectory = DirectoryUtils.convertStringToInt(strIdDirectory); - EntryFilter filter = new EntryFilter( ); - filter.setIdDirectory( nIdDirectory ); - filter.setIsEntryParentNull( EntryFilter.FILTER_TRUE ); + EntryFilter filter = new EntryFilter(); + filter.setIdDirectory(nIdDirectory); + filter.setIsEntryParentNull(EntryFilter.FILTER_TRUE); - List listEntryFirstLevel = EntryHome.getEntryList( filter, plugin ); + List listEntryFirstLevel = EntryHome.getEntryList(filter, plugin); int position = 1; - for ( IEntry entry : listEntryFirstLevel ) - { - entry.setPosition( position ); - EntryHome.update( entry, plugin ); + for (IEntry entry : listEntryFirstLevel) { + entry.setPosition(position); + EntryHome.update(entry, plugin); position++; - EntryFilter filterSecondLevel = new EntryFilter( ); - filterSecondLevel.setIdEntryParent( entry.getIdEntry( ) ); + EntryFilter filterSecondLevel = new EntryFilter(); + filterSecondLevel.setIdEntryParent(entry.getIdEntry()); - List listEntrySecondLevel = EntryHome.getEntryList( filterSecondLevel, plugin ); + List listEntrySecondLevel = EntryHome.getEntryList(filterSecondLevel, plugin); - if ( listEntrySecondLevel != null ) - { - for ( IEntry entrySecondLevel : listEntrySecondLevel ) - { - entrySecondLevel.setPosition( position ); - EntryHome.update( entrySecondLevel, plugin ); + if (listEntrySecondLevel != null) { + for (IEntry entrySecondLevel : listEntrySecondLevel) { + entrySecondLevel.setPosition(position); + EntryHome.update(entrySecondLevel, plugin); position++; } } } - return getJspModifyDirectory( request, nIdDirectory ); + return getJspModifyDirectory(request, nIdDirectory); + } + + private boolean populateSynchronousUpload(HttpServletRequest request, String strIdDirectory) { + + if (_directoryAsynchronousUploadHandler == null) { + _directoryAsynchronousUploadHandler = DirectoryAsynchronousUploadHandler.getHandler(); + } + + _listUploadFieldName = new ArrayList(); + _listBoolean = new ArrayList(); + + _listUploadFieldName = getListUploadFieldName(strIdDirectory); + + for (String s : _listUploadFieldName) { + _directoryAsynchronousUploadHandler.doRemoveFile(request, s); + _directoryAsynchronousUploadHandler.addFilesUploadedSynchronously(request, s); + _listBoolean.add(_directoryAsynchronousUploadHandler.hasRemoveFlag(request, s)); + _listBoolean.add(_directoryAsynchronousUploadHandler.hasAddFileFlag(request, s)); + } + boolean resultat = false; + for (int i = 0; i < _listBoolean.size(); i++) { + if (resultat == false) { + resultat |= _listBoolean.get(i); + } else { + break; + } + } + _listBoolean = new ArrayList() ; + + return resultat; + } + + private List getListUploadFieldName(String strIdDirectory) { + List listUploadFieldName = new ArrayList(); + List listEntry = DirectoryUtils.getFormEntries(Integer.parseInt(strIdDirectory), getPlugin(), getUser()); + for (IEntry e : listEntry) { + if (e.getClass().getSimpleName().equals(CONSTANT_ENTRY_TYPE_FILE) || e.getClass().getSimpleName().equals(CONSTANT_ENTRY_TYPE_IMG)) { + listUploadFieldName.add(CONSTANT_PREFIX_FIELD + e.getIdEntry()); + } + } + return listUploadFieldName; + } } diff --git a/webapp/WEB-INF/templates/admin/plugins/directory/create_directory_record.html b/webapp/WEB-INF/templates/admin/plugins/directory/create_directory_record.html index 718cb20..26b9488 100644 --- a/webapp/WEB-INF/templates/admin/plugins/directory/create_directory_record.html +++ b/webapp/WEB-INF/templates/admin/plugins/directory/create_directory_record.html @@ -29,6 +29,7 @@

#i18n{directory.create_directory_record.title}: ' ${entry.getHtmlFormEntry( locale,false )} @@ -51,8 +52,6 @@

#i18n{directory.create_directory_record.title}: ' - - \ No newline at end of file diff --git a/webapp/WEB-INF/templates/admin/plugins/directory/entrytypeimg/html_code_form_entry_type_img.html b/webapp/WEB-INF/templates/admin/plugins/directory/entrytypeimg/html_code_form_entry_type_img.html index 458c58d..1d3be3b 100644 --- a/webapp/WEB-INF/templates/admin/plugins/directory/entrytypeimg/html_code_form_entry_type_img.html +++ b/webapp/WEB-INF/templates/admin/plugins/directory/entrytypeimg/html_code_form_entry_type_img.html @@ -1,63 +1,13 @@ -<#include "/admin/plugins/directory/commons.html" /> -
- -
- - -
- - - - -
- <#if entry.helpMessage?exists&&entry.helpMessage!=''> - ${entry.helpMessage} - - <#-- file removing --> - <#assign has_files = false> - <#if default_values?? && default_values?has_content> - <#assign record_field_error = default_values[0]> - <#if record_field_error.entry.idEntry == entry.idEntry> - <#assign has_files = true> - - -
- -   -
- <#assign file_index = 0> -
- <#if has_files> - <#list default_values as default_value> - <#if !default_value.isLittleThumbnail() && !default_value.isBigThumbnail()> -
- <#if default_value.file?exists> - - - - <#-- Case when the user uploads without JS --> - <#if default_value.file.idFile != -1 && default_value.file.idFile != 0> - - ${default_value.file.title} (${default_value.file.size} O) - <#else> - ${default_value.file.title} (${default_value.file.size} O) - -
- - <#assign file_index = file_index + 1> - - - -
-
-
-
- -
- -
-
+<#include "/skin/plugins/asynchronousupload/upload_commons.html" /> +
+
+ + <#if list_fileuploaded?has_content> + <#assign listFiles = list_fileuploaded> + <#else> + <#assign listFiles = ''> + + <@addFileInputAndfilesBox fieldName="directory_${entry.idEntry}" handler=entry.asynchronousUploadHandler listUploadedFiles=listFiles inputCssClass="" multiple=false /> +
+
+ \ No newline at end of file diff --git a/webapp/WEB-INF/templates/admin/plugins/directory/modify_directory_record.html b/webapp/WEB-INF/templates/admin/plugins/directory/modify_directory_record.html index 42c62ab..49c30d4 100644 --- a/webapp/WEB-INF/templates/admin/plugins/directory/modify_directory_record.html +++ b/webapp/WEB-INF/templates/admin/plugins/directory/modify_directory_record.html @@ -40,6 +40,7 @@

<#assign entryKey=""+entry.idEntry> <#if map_id_entry_list_record_field?? && map_id_entry_list_record_field[entryKey]??> ${entry.getHtmlFormEntry( locale,map_id_entry_list_record_field[entryKey],false )} + <#else> ${entry.getHtmlFormEntry( locale,false )} @@ -51,15 +52,13 @@

+ - + - - <#include "/admin/util/editor/editor.html" /> <@initEditor /> diff --git a/webapp/WEB-INF/templates/admin/plugins/directory/view_directory_record.html b/webapp/WEB-INF/templates/admin/plugins/directory/view_directory_record.html index 4bfe60e..0c69acc 100644 --- a/webapp/WEB-INF/templates/admin/plugins/directory/view_directory_record.html +++ b/webapp/WEB-INF/templates/admin/plugins/directory/view_directory_record.html @@ -1,149 +1,187 @@ -<#-- --- Return true if the given entry is an entry type Image --- @param entry the entry to check --- @return true if the entry is an entry type Image ---> -<#function isEntryTypeImage entry> - <#return entry.entryType?has_content && entry.entryType.idType?has_content && entry.entryType.idType == id_entry_type_image> - - -<#-- --- Return true if the given entry is an entry type MyLuteceUser --- @param entry the entry to check --- @return true if the entry is an entry type MyLuteceUser ---> -<#function isEntryTypeMyLuteceUser entry> - <#return entry.entryType?has_content && entry.entryType.idType?has_content && entry.entryType.idType == id_entry_type_mylutece_user> - - -<#-- --- Return true if the given entry is an entry type Geolocation --- @param entry the entry to check --- @return true if the entry is an entry type Geolocation ---> -<#function isEntryTypeGeolocation entry> - <#return entry.entryType?has_content && entry.entryType.idType?has_content && entry.entryType.idType == id_entry_type_geolocation> - - -<#-- --- Build the HTML of the given record field --- @param entry the entry of the record field --- @param recordfield the recordfield --- @param first true if the record field is the first record field of the list of record fields of the given entry --- @return the HTLM code of the record field ---> -<#macro getRecordFieldHtml entry recordfield first> -<#if isEntryTypeGeolocation( entry )> -${entry.getHtmlRecordFieldValue( locale, recordfield, false )}<#if recordfield.field?? && recordfield.field.title?? && recordfield.field.title == 'address' && recordfield.value?has_content><#include "../../../skin/plugins/directory/" + entry.mapProvider.frontHtmlCode /> -<#else> -<#if !first> - -<#if isEntryTypeImage( entry )> -<#if recordfield.field?? & recordfield.field.isShownInResultRecord( )>${entry.getHtmlRecordFieldValue( locale, recordfield, false )} -<#elseif isEntryTypeMyLuteceUser(entry) && !permission_visualisation_mylutece_user>${record_field.value}<#else> -${entry.getHtmlRecordFieldValue( locale,recordfield, false )} - - - - -<#-- --- Build the HTML code to display the actions --- @param resource_actions the actions to display --- @return the HTML code of the actions ---> -<#macro display_actions resource_actions > -<#if resource_actions.workflow_action_list?exists> - <#list resource_actions.workflow_action_list as action> - - width="${action.icon.width}"<#if action.icon.height!=-1> height="${action.icon.height}" title="${action.name}" alt="${action.name}"/> - - - - <#list resource_actions.record.actions?sort_by("nameKey") as action> - <#if (action.nameKey!="directory.action.history.name") || (action.nameKey=="directory.action.history.name" && history_workflow)> - btn-danger<#elseif action.nameKey="directory.action.enable.name">btn-success<#else>btn-primary" href="${action.url}?id_directory_record=${resource_actions.record.idRecord}&id_directory=${directory.idDirectory}" title="${action.description}"> - - - - - - -
-
-
-
-

#i18n{directory.viewing_directory_record.title} : '${directory.title}' - #i18n{directory.viewing_directory_record.labelRecord} ${record.idRecord} - <#if record.dateCreation?? && show_date_creation_record > - - - #i18n{directory.viewing_directory_record.date_creation} ${record.dateCreation} - <#if record.dateModification?? && show_date_modification_record > - #i18n{directory.viewing_directory_record.date_modification} ${record.dateModification} - -

-
-
- <#if resource_actions.workflow_state?exists> - #i18n{directory.viewing_directory_record.labelState} - ${resource_actions.workflow_state.name} - -
-
- <#if item_navigator??> - <@item_navigation item_navigator=item_navigator /> - -
-
- <@display_actions resource_actions/> -
-
-
-
- - - - <#list entry_list as entry> - <#if entry.entryType.group> -
- ${entry.title} - <#if entry.children?has_content> - <#list entry.children as child > -
- -
- <#assign entryKey=""+child.idEntry><#assign first = true><#list map_id_entry_list_record_field[entryKey] as recordfield><@getRecordFieldHtml entry=child recordfield=recordfield first=first /><#assign first = false> -
-
- - - <#else> - <#assign entryKey=""+entry.idEntry> - <#assign first = true> -
+<#-- +-- Return true if the given entry is an entry type Image +-- @param entry the entry to check +-- @return true if the entry is an entry type Image +--> +<#function isEntryTypeImage entry> + <#return entry.entryType?has_content && entry.entryType.idType?has_content && entry.entryType.idType == id_entry_type_image> + + +<#-- +-- Return true if the given entry is an entry type MyLuteceUser +-- @param entry the entry to check +-- @return true if the entry is an entry type MyLuteceUser +--> +<#function isEntryTypeMyLuteceUser entry> + <#return entry.entryType?has_content && entry.entryType.idType?has_content && entry.entryType.idType == id_entry_type_mylutece_user> + + +<#-- +-- Return true if the given entry is an entry type Geolocation +-- @param entry the entry to check +-- @return true if the entry is an entry type Geolocation +--> +<#function isEntryTypeGeolocation entry> + <#return entry.entryType?has_content && entry.entryType.idType?has_content && entry.entryType.idType == id_entry_type_geolocation> + + +<#-- +-- Build the HTML of the given record field +-- @param entry the entry of the record field +-- @param recordfield the recordfield +-- @param first true if the record field is the first record field of the list of record fields of the given entry +-- @return the HTLM code of the record field +--> +<#macro getRecordFieldHtml entry recordfield first> + <#if isEntryTypeGeolocation( entry )> + ${entry.getHtmlRecordFieldValue( locale, recordfield, false )} + <#if recordfield.field?? && recordfield.field.title?? && recordfield.field.title == 'address' > + <#include "../../../skin/plugins/directory/" + entry.mapProvider.frontHtmlCode /> + + + <#else> + <#if !first> + + <#if isEntryTypeImage( entry )> + <#if recordfield.field?? & recordfield.field.isShownInResultRecord( )>${entry.getHtmlRecordFieldValue( locale, recordfield, false )} + <#elseif isEntryTypeMyLuteceUser(entry) && !permission_visualisation_mylutece_user>${record_field.value}<#else> + ${entry.getHtmlRecordFieldValue( locale,recordfield, false )} + + + + +<#-- +-- Build the HTML code to display the actions +-- @param resource_actions the actions to display +-- @return the HTML code of the actions +--> +<#macro display_actions resource_actions > +<#if resource_actions.workflow_action_list?exists> + <#list resource_actions.workflow_action_list as action> + + width="${action.icon.width}"<#if action.icon.height!=-1> height="${action.icon.height}" title="${action.name}" alt="${action.name}"/> + + + + <#list resource_actions.record.actions?sort_by("nameKey") as action> + <#if (action.nameKey!="directory.action.history.name") || (action.nameKey=="directory.action.history.name" && history_workflow)> + btn-danger<#elseif action.nameKey="directory.action.enable.name">btn-success<#else>btn-primary" href="${action.url}?id_directory_record=${resource_actions.record.idRecord}&id_directory=${directory.idDirectory}" title="${action.description}"> + + + + + + +
+
+
+
+

#i18n{directory.viewing_directory_record.title} : '${directory.title}' - #i18n{directory.viewing_directory_record.labelRecord} ${record.idRecord} + <#if record.dateCreation?? && show_date_creation_record > + + - #i18n{directory.viewing_directory_record.date_creation} ${record.dateCreation} + <#if record.dateModification?? && show_date_modification_record > - #i18n{directory.viewing_directory_record.date_modification} ${record.dateModification} + +

+
+
+ <#if resource_actions.workflow_state?exists> + #i18n{directory.viewing_directory_record.labelState} + ${resource_actions.workflow_state.name} + +
+
+ <#if item_navigator??> + <@item_navigation item_navigator=item_navigator /> + +
+
+ <@display_actions resource_actions/> +
+
+
+ + + + + <#assign editModeValue = "ReadOnly"> + + <#assign viewNumberAttValue = "1"> + + <#list entry_list as entry> + + + <#if entry.fields?? && entry.fields?has_content> + <#list entry.fields as field> + <#if field?? && field.title?has_content && field.title == "viewNumberAtt"> + <#assign viewNumberAttValue = field.value > + <#break> + + + + <#if entry.mapProvider?has_content> + <#if entry.mapProvider.key?has_content && entry.mapProvider.key == "gismap" > + <#if entry.mapProvider.getParameter(viewNumberAttValue?number)?? && entry.mapProvider.getParameter(viewNumberAttValue?number).mapParameter??> + <#assign map_parameter = entry.mapProvider.getParameter(viewNumberAttValue?number).mapParameter > + + + <#if entry.mapProvider.getParameter(viewNumberAttValue?number)?? && entry.mapProvider.getParameter(viewNumberAttValue?number).addressParam??> + <#assign add_parameter = entry.mapProvider.getParameter(viewNumberAttValue?number).addressParam > + + + + <#if entry.entryType.group> +
+ ${entry.title} + <#if entry.children?has_content> + <#list entry.children as child > +
+ +
+ + <#assign entryKey=""+child.idEntry><#assign first = true> + <#list map_id_entry_list_record_field[entryKey] as recordfield> + <@getRecordFieldHtml entry=child recordfield=recordfield first=first /><#assign first = false> + +
+
+ + + <#else> + <#assign entryKey=""+entry.idEntry> + <#assign first = true> +
<#if entry.title?exists> - - - <#list map_id_entry_list_record_field[entryKey] as recordfield> -
- <@getRecordFieldHtml entry=entry recordfield=recordfield first=first /> - <#assign first = false> -
- -
- - -
-
- + + + <#list map_id_entry_list_record_field[entryKey] as recordfield> + <#if recordfield.field?? && recordfield.field.title?? && recordfield.field.title == 'geometry' && recordfield.value?has_content> + + + + <#list map_id_entry_list_record_field[entryKey] as recordfield> +
+ <@getRecordFieldHtml entry=entry recordfield=recordfield first=first /> + <#assign first = false> +
+ +
+ + +
+
+
-
-
-
-
- +
+
+
+
+ \ No newline at end of file diff --git a/webapp/jsp/admin/plugins/directory/CreateDirectoryRecordWithInitialValues.jsp b/webapp/jsp/admin/plugins/directory/CreateDirectoryRecordWithInitialValues.jsp new file mode 100644 index 0000000..0883632 --- /dev/null +++ b/webapp/jsp/admin/plugins/directory/CreateDirectoryRecordWithInitialValues.jsp @@ -0,0 +1,6 @@ +<%@ page errorPage="../../ErrorPage.jsp" %> + + +<% directoryDirectory.init( request, fr.paris.lutece.plugins.directory.web.ManageDirectoryJspBean.RIGHT_MANAGE_DIRECTORY); %> +<%= directoryDirectory.getCreateDirectoryRecordWithInitialValues( request ) %> +<%@ include file="../../AdminFooter.jsp" %> \ No newline at end of file diff --git a/webapp/jsp/admin/plugins/directory/ModifyDirectoryRecord.jsp b/webapp/jsp/admin/plugins/directory/ModifyDirectoryRecord.jsp index 52febf8..2775f79 100644 --- a/webapp/jsp/admin/plugins/directory/ModifyDirectoryRecord.jsp +++ b/webapp/jsp/admin/plugins/directory/ModifyDirectoryRecord.jsp @@ -1,10 +1,6 @@ <%@ page errorPage="../../ErrorPage.jsp" %> - - -<% - directoryDirectory.init( request, fr.paris.lutece.plugins.directory.web.ManageDirectoryJspBean.RIGHT_MANAGE_DIRECTORY); %> +<% directoryDirectory.init( request, fr.paris.lutece.plugins.directory.web.ManageDirectoryJspBean.RIGHT_MANAGE_DIRECTORY); %> <%= directoryDirectory.getModifyDirectoryRecord( request ) %> - <%@ include file="../../AdminFooter.jsp" %> \ No newline at end of file From 3975bfaa85d137c307f130474b2b9f5c3424627b Mon Sep 17 00:00:00 2001 From: Martinez Date: Mon, 8 Aug 2016 17:59:52 +0200 Subject: [PATCH 2/3] DIRECTORY-274 : Update pom.xml --- pom.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b566bd3..c9f1b6b 100644 --- a/pom.xml +++ b/pom.xml @@ -52,7 +52,13 @@ library-image [1.0.0,) - + + fr.paris.lutece.plugins + plugin-asynchronousupload + 1.0.5-SNAPSHOT + lutece-plugin + + fr.paris.lutece.plugins library-blobstore From 0a93c5e692cd7f4a62c244d3a774e2c1cf2fd0ae Mon Sep 17 00:00:00 2001 From: Martinez Date: Fri, 9 Sep 2016 15:32:07 +0200 Subject: [PATCH 3/3] Modify create_directory_record template --- .../directory/create_directory_record.html | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/webapp/WEB-INF/templates/admin/plugins/directory/create_directory_record.html b/webapp/WEB-INF/templates/admin/plugins/directory/create_directory_record.html index 26b9488..ab82f87 100644 --- a/webapp/WEB-INF/templates/admin/plugins/directory/create_directory_record.html +++ b/webapp/WEB-INF/templates/admin/plugins/directory/create_directory_record.html @@ -52,20 +52,4 @@

#i18n{directory.create_directory_record.title}: ' - -