Skip to content

Commit

Permalink
LUT-28584 : use GenericAttributeFileService
Browse files Browse the repository at this point in the history
  • Loading branch information
seboo committed Sep 26, 2024
1 parent 22298ba commit 8ddd62c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 60 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<properties>
<componentName>appointment</componentName>
<core.version>[7.0.10,)</core.version>
<genericattributes.version>[2.4.5-SNAPSHOT,)</genericattributes.version>
<genericattributes.version>[2.4.6-SNAPSHOT,)</genericattributes.version>
<jiraComponentId>12273</jiraComponentId>
<jiraProjectName>RENDEZVOUS</jiraProjectName>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
import fr.paris.lutece.plugins.genericattributes.business.GenAttFileItem;
import fr.paris.lutece.plugins.genericattributes.business.Response;
import fr.paris.lutece.plugins.genericattributes.business.ResponseHome;
import fr.paris.lutece.plugins.genericattributes.service.entrytype.AbstractEntryTypeFile;
import fr.paris.lutece.plugins.genericattributes.service.entrytype.IEntryTypeService;
import fr.paris.lutece.plugins.genericattributes.service.file.GenericAttributeFileService;

/**
* Service Class for the appointment Response
Expand Down Expand Up @@ -144,23 +146,16 @@ public static List<Response> findAndBuildListResponse( int nIdAppointment, HttpS
}
if ( response.getFile( ) != null )
{
IFileStoreServiceProvider fileStoreService = FileService.getInstance( ).getFileStoreServiceProvider( );
File file = null;
try
{
file = fileStoreService.getFile( response.getFile( ).getFileKey( ) );
}
catch( FileServiceException e )
{
AppLogService.error( "Error get file: " + response.getFile( ).getFileKey( ), e );
}
// load from default generic attribute file service
File file = GenericAttributeFileService.getInstance().load( response.getFile( ).getFileKey( ), null);

response.setFile( file );
String strIdEntry = Integer.toString( response.getEntry( ).getIdEntry( ) );
FileItem fileItem = null;
if ( file != null )
{
fileItem = new GenAttFileItem( file.getPhysicalFile( ).getValue( ), file.getTitle( ), IEntryTypeService.PREFIX_ATTRIBUTE + strIdEntry,
response.getIdResponse( ) );
response.getIdResponse( ), GenericAttributeFileService.getInstance().getFileStoreProviderName() );
}
AppointmentAsynchronousUploadHandler.getHandler( ).addFileItemToUploadedFilesList( fileItem, IEntryTypeService.PREFIX_ATTRIBUTE + strIdEntry,
request );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@
import javax.servlet.http.HttpServletRequest;

import fr.paris.lutece.portal.business.file.File;
import fr.paris.lutece.portal.service.file.FileService;
import fr.paris.lutece.portal.service.file.FileServiceException;
import fr.paris.lutece.portal.service.file.IFileStoreServiceProvider;
import fr.paris.lutece.portal.service.security.SecurityTokenService;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections.CollectionUtils;
Expand Down Expand Up @@ -95,6 +92,7 @@
import fr.paris.lutece.plugins.genericattributes.business.Entry;
import fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError;
import fr.paris.lutece.plugins.genericattributes.business.Response;
import fr.paris.lutece.plugins.genericattributes.service.file.GenericAttributeFileService;
import fr.paris.lutece.plugins.workflowcore.service.task.ITask;
import fr.paris.lutece.plugins.workflowcore.service.task.ITaskService;
import fr.paris.lutece.plugins.workflowcore.service.task.TaskService;
Expand Down Expand Up @@ -1234,16 +1232,9 @@ public synchronized XPage getViewChangeDateAppointment( HttpServletRequest reque
{
if ( response.getFile( ) != null )
{
IFileStoreServiceProvider fileStoreService = FileService.getInstance( ).getFileStoreServiceProvider( );
File file = null;
try
{
file = fileStoreService.getFile( response.getFile( ).getFileKey( ) );
}
catch( FileServiceException e )
{
AppLogService.error( "Error get file: " + response.getFile( ).getFileKey( ), e );
}
// load from default generic attribute file service
File file = GenericAttributeFileService.getInstance().load( response.getFile( ).getFileKey( ), null);

response.setFile( file );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import fr.paris.lutece.portal.service.file.FileService;
import fr.paris.lutece.portal.service.file.FileServiceException;
import fr.paris.lutece.portal.service.file.IFileStoreServiceProvider;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -104,6 +101,7 @@
import fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError;
import fr.paris.lutece.plugins.genericattributes.business.Response;
import fr.paris.lutece.plugins.genericattributes.business.ResponseHome;
import fr.paris.lutece.plugins.genericattributes.service.file.GenericAttributeFileService;
import fr.paris.lutece.plugins.workflowcore.business.state.State;
import fr.paris.lutece.plugins.workflowcore.business.state.StateFilter;
import fr.paris.lutece.plugins.workflowcore.service.state.StateService;
Expand Down Expand Up @@ -754,7 +752,7 @@ public synchronized String doRemoveMassAppointment( HttpServletRequest request )
* If there is an error with the file service
*/
@View( VIEW_VIEW_APPOINTMENT )
public synchronized String getViewAppointment( HttpServletRequest request ) throws AccessDeniedException, FileServiceException
public synchronized String getViewAppointment( HttpServletRequest request ) throws AccessDeniedException
{
String strIdAppointment = request.getParameter( PARAMETER_ID_APPOINTMENT );
String strIdForm = request.getParameter( PARAMETER_ID_FORM );
Expand Down Expand Up @@ -803,16 +801,9 @@ public synchronized String getViewAppointment( HttpServletRequest request ) thro
{
if ( response.getFile( ) != null )
{
IFileStoreServiceProvider fileStoreService = FileService.getInstance( ).getFileStoreServiceProvider( );
File file = null;
try
{
file = fileStoreService.getFile( response.getFile( ).getFileKey( ) );
}
catch( FileServiceException e )
{
AppLogService.error( "Error get file: " + response.getFile( ).getFileKey( ), e );
}
// load from default generic attribute file service
File file = GenericAttributeFileService.getInstance().load( response.getFile( ).getFileKey( ), null);


response.setFile( file );
}
Expand Down Expand Up @@ -1256,16 +1247,9 @@ public synchronized String getViewChangeDateAppointment( HttpServletRequest requ
{
if ( response.getFile( ) != null )
{
IFileStoreServiceProvider fileStoreService = FileService.getInstance( ).getFileStoreServiceProvider( );
File file = null;
try
{
file = fileStoreService.getFile( response.getFile( ).getFileKey( ) );
}
catch( FileServiceException e )
{
AppLogService.error( "Error get file: " + response.getFile( ).getFileKey( ), e );
}
// load from default generic attribute file service
File file = GenericAttributeFileService.getInstance().load( response.getFile( ).getFileKey( ), null);

response.setFile( file );
}
}
Expand Down Expand Up @@ -1445,7 +1429,7 @@ public synchronized String getDownloadFileFromSession( HttpServletRequest reques
* @throws FileServiceException
* If there is an error with the file service
*/
public synchronized String getDownloadFile( HttpServletRequest request, HttpServletResponse httpResponse ) throws AccessDeniedException, FileServiceException
public synchronized String getDownloadFile( HttpServletRequest request, HttpServletResponse httpResponse ) throws AccessDeniedException
{
String strIdResponse = request.getParameter( PARAMETER_ID_RESPONSE );

Expand All @@ -1456,16 +1440,10 @@ public synchronized String getDownloadFile( HttpServletRequest request, HttpServ

int nIdResponse = Integer.parseInt( strIdResponse );
Response response = ResponseHome.findByPrimaryKey( nIdResponse );
IFileStoreServiceProvider fileStoreService = FileService.getInstance( ).getFileStoreServiceProvider( );
File file = null;
try
{
file = fileStoreService.getFile( response.getFile( ).getFileKey( ) );
}
catch( FileServiceException e )
{
AppLogService.error( "Error get file: " + response.getFile( ).getFileKey( ), e );
}

// load from default generic attribute file service
File file = GenericAttributeFileService.getInstance().load( response.getFile( ).getFileKey( ), null);

httpResponse.setHeader( "Content-Disposition", "attachment; filename=\"" + file.getTitle( ) + "\";" );
httpResponse.setHeader( "Content-type", file.getMimeType( ) );
httpResponse.addHeader( "Content-Encoding", "UTF-8" );
Expand Down

0 comments on commit 8ddd62c

Please sign in to comment.