Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LUT-29143 : Removal of obsolete API calls #487

Open
wants to merge 3 commits into
base: develop8.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import fr.paris.lutece.util.ReferenceList;
import jakarta.enterprise.inject.spi.CDI;

import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.List;

Expand Down Expand Up @@ -73,11 +74,11 @@ public static Portlet findByPrimaryKey( int nKey )

try
{
PortletHomeInterface home = (PortletHomeInterface) Class.forName( strHomeClass ).newInstance( );
PortletHomeInterface home = (PortletHomeInterface) Class.forName( strHomeClass ).getDeclaredConstructor().newInstance( );
p = home.getDAO( ).load( nKey );
p.copy( portlet );
}
catch( IllegalAccessException | InstantiationException | ClassNotFoundException e )
catch( IllegalAccessException | InstantiationException | ClassNotFoundException | InvocationTargetException | NoSuchMethodException e )
{
AppLogService.error( e.getMessage( ), e );
}
Expand Down
3 changes: 2 additions & 1 deletion src/java/fr/paris/lutece/portal/business/role/RoleHome.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
*/
package fr.paris.lutece.portal.business.role;

import fr.paris.lutece.api.user.User;
import fr.paris.lutece.portal.business.user.AdminUser;
import fr.paris.lutece.portal.service.util.AppLogService;
import fr.paris.lutece.portal.service.util.AppPropertiesService;
Expand Down Expand Up @@ -201,7 +202,7 @@ private static Role getDefaultRole( )
public static ReferenceList getRolesList( AdminUser user )
{
Collection<Role> listRoles = RoleHome.findAll( );
listRoles = AdminWorkgroupService.getAuthorizedCollection( listRoles, user );
listRoles = AdminWorkgroupService.getAuthorizedCollection( listRoles, ( User ) user );

ReferenceList roleList = new ReferenceList( );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public void setAccountMaxValidDate( Timestamp accountMaxValidDate )
/**
* Returns user's roles
*
* @deprecated use getRBACRoles( )
* @deprecated use getUserRoles( )
* @return Returns user's roles
*/
@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import fr.paris.lutece.util.sql.DAOUtil;
import jakarta.enterprise.context.ApplicationScoped;

import java.lang.reflect.InvocationTargetException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -289,9 +290,9 @@ public List<AdminUserField> selectUserFieldsByIdUserIdAttribute( int nIdUser, in

try
{
attribute = (IAttribute) Class.forName( daoUtil.getString( 7 ) ).newInstance( );
attribute = (IAttribute) Class.forName( daoUtil.getString( 7 ) ).getDeclaredConstructor( ).newInstance( );
}
catch( IllegalAccessException | InstantiationException | ClassNotFoundException e )
catch( IllegalAccessException | InstantiationException | ClassNotFoundException | InvocationTargetException | NoSuchMethodException e )
{
AppLogService.error( e );
}
Expand Down Expand Up @@ -521,9 +522,9 @@ private AdminUserField dataToObject( DAOUtil daoUtil )

try
{
attribute = (IAttribute) Class.forName( daoUtil.getString( 14 ) ).newInstance( );
attribute = (IAttribute) Class.forName( daoUtil.getString( 14 ) ).getDeclaredConstructor( ).newInstance( );
}
catch( ClassNotFoundException | InstantiationException | IllegalAccessException e )
catch( ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e )
{
AppLogService.error( e );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import java.util.List;
import java.util.Locale;

import jakarta.enterprise.inject.spi.CDI;
import jakarta.servlet.http.HttpServletRequest;

/**
Expand Down Expand Up @@ -204,7 +205,8 @@ public void setAdminUserFieldFilter( HttpServletRequest request, Locale locale )

if ( strIsSearch != null )
{
List<IAttribute> listAttributes = AttributeService.getInstance( ).getAllAttributesWithoutFields( locale );
AttributeService attributeService = CDI.current( ).select( AttributeService.class ).get( );
List<IAttribute> listAttributes = attributeService.getAllAttributesWithoutFields( locale );

for ( IAttribute attribute : listAttributes )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import fr.paris.lutece.portal.business.user.AdminUser;
import fr.paris.lutece.portal.service.message.AdminMessage;
import fr.paris.lutece.portal.service.message.AdminMessageService;
import fr.paris.lutece.portal.service.user.attribute.AttributeFieldService;
import fr.paris.lutece.portal.web.constants.Messages;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -80,6 +79,7 @@ public class AttributeCheckBox extends AbstractAttribute implements ISimpleValue
private static final String TEMPLATE_HTML_FORM_SEARCH_ATTRIBUTE = "admin/user/attribute/checkbox/html_code_form_search_attribute_checkbox.html";
private static final String TEMPLATE_HTML_VALUE = "admin/user/attribute/checkbox/html_code_value_attribute_checkbox.html";


/**
* Constructor
*/
Expand Down Expand Up @@ -254,7 +254,8 @@ public List<AdminUserField> getUserFieldsData( String [ ] strValues, AdminUser u
if ( StringUtils.isNotBlank( strValue ) && StringUtils.isNumeric( strValue ) )
{
int nIdField = Integer.parseInt( strValue );
attributeField = AttributeFieldService.getInstance( ).getAttributeField( nIdField );
attributeField = AttributeFieldHome.findByPrimaryKey( nIdField );

}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import fr.paris.lutece.portal.business.user.AdminUser;
import fr.paris.lutece.portal.service.message.AdminMessage;
import fr.paris.lutece.portal.service.message.AdminMessageService;
import fr.paris.lutece.portal.service.user.attribute.AttributeFieldService;
import fr.paris.lutece.portal.web.constants.Messages;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -80,6 +79,7 @@ public class AttributeComboBox extends AbstractAttribute implements ISimpleValue
private static final String TEMPLATE_HTML_FORM_SEARCH_ATTRIBUTE = "admin/user/attribute/combobox/html_code_form_search_attribute_combobox.html";
private static final String TEMPLATE_HTML_VALUE = "admin/user/attribute/combobox/html_code_value_attribute_combobox.html";


/**
* Constructor
*/
Expand Down Expand Up @@ -263,7 +263,7 @@ public List<AdminUserField> getUserFieldsData( String [ ] strValues, AdminUser u
if ( StringUtils.isNotBlank( strValue ) && StringUtils.isNumeric( strValue ) )
{
int nIdField = Integer.parseInt( strValue );
attributeField = AttributeFieldService.getInstance( ).getAttributeField( nIdField );
attributeField = AttributeFieldHome.findByPrimaryKey( nIdField );
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import fr.paris.lutece.util.sql.DAOUtil;
import jakarta.enterprise.context.ApplicationScoped;

import java.lang.reflect.InvocationTargetException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -124,9 +125,9 @@ public IAttribute load( int nIdAttribute, Locale locale )

try
{
attribute = (IAttribute) Class.forName( daoUtil.getString( nIndex++ ) ).newInstance( );
attribute = (IAttribute) Class.forName( daoUtil.getString( nIndex++ ) ).getDeclaredConstructor().newInstance( );
}
catch( InstantiationException | IllegalAccessException | ClassNotFoundException e )
catch( InstantiationException | IllegalAccessException | ClassNotFoundException | InvocationTargetException | NoSuchMethodException e )
{
AppLogService.error( e.getMessage( ), e );
}
Expand Down Expand Up @@ -246,9 +247,9 @@ public List<IAttribute> selectAll( Locale locale )

try
{
attribute = (IAttribute) Class.forName( daoUtil.getString( nIndex++ ) ).newInstance( );
attribute = (IAttribute) Class.forName( daoUtil.getString( nIndex++ ) ).getDeclaredConstructor().newInstance( );
}
catch( InstantiationException | IllegalAccessException | ClassNotFoundException e )
catch( InstantiationException | IllegalAccessException | ClassNotFoundException | InvocationTargetException | NoSuchMethodException e )
{
AppLogService.error( e.getMessage( ), e );
}
Expand Down Expand Up @@ -304,9 +305,9 @@ public List<IAttribute> selectPluginAttributes( String strPluginName, Locale loc

try
{
attribute = (IAttribute) Class.forName( daoUtil.getString( nIndex++ ) ).newInstance( );
attribute = (IAttribute) Class.forName( daoUtil.getString( nIndex++ ) ).getDeclaredConstructor().newInstance( );
}
catch( InstantiationException | IllegalAccessException | ClassNotFoundException e )
catch( InstantiationException | IllegalAccessException | ClassNotFoundException | InvocationTargetException | NoSuchMethodException e )
{
AppLogService.error( e.getMessage( ), e );
}
Expand Down Expand Up @@ -356,9 +357,9 @@ public List<IAttribute> selectCoreAttributes( Locale locale )

try
{
attribute = (IAttribute) Class.forName( daoUtil.getString( nIndex++ ) ).newInstance( );
attribute = (IAttribute) Class.forName( daoUtil.getString( nIndex++ ) ).getDeclaredConstructor().newInstance( );
}
catch( InstantiationException | IllegalAccessException | ClassNotFoundException e )
catch( InstantiationException | IllegalAccessException | ClassNotFoundException | InvocationTargetException | NoSuchMethodException e )
{
AppLogService.error( e.getMessage( ), e );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import fr.paris.lutece.util.sql.DAOUtil;
import jakarta.enterprise.context.ApplicationScoped;

import java.lang.reflect.InvocationTargetException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -155,9 +156,9 @@ public IAttribute selectAttributeByIdField( int nIdField )
{
try
{
attribute = (IAttribute) Class.forName( daoUtil.getString( 1 ) ).newInstance( );
attribute = (IAttribute) Class.forName( daoUtil.getString( 1 ) ).getDeclaredConstructor().newInstance( );
}
catch( IllegalAccessException | InstantiationException | ClassNotFoundException e )
catch( IllegalAccessException | InstantiationException | ClassNotFoundException | InvocationTargetException | NoSuchMethodException e )
{
AppLogService.error( e.getMessage( ), e );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import fr.paris.lutece.portal.service.fileupload.FileUploadService;
import fr.paris.lutece.portal.service.message.AdminMessage;
import fr.paris.lutece.portal.service.message.AdminMessageService;
import fr.paris.lutece.portal.service.user.attribute.AttributeService;
import fr.paris.lutece.portal.service.util.AppLogService;
import fr.paris.lutece.portal.web.constants.Messages;
import fr.paris.lutece.portal.web.upload.MultipartHttpServletRequest;
Expand All @@ -62,6 +61,7 @@
import javax.imageio.ImageIO;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.spi.CDI;
import jakarta.servlet.http.HttpServletRequest;

/**
Expand Down Expand Up @@ -100,6 +100,7 @@ public class AttributeImage extends AbstractAttribute
private static final String TEMPLATE_HTML_VALUE = "admin/user/attribute/image/html_code_value_attribute_image.html";
private static final String REGEX_ID = "-?[0-9]+";


/**
* Constructor
*/
Expand Down Expand Up @@ -306,7 +307,7 @@ public List<AdminUserField> getUserFieldsData( HttpServletRequest request, Admin
userField.setUser( user );
userField.setAttribute( this );

AttributeService.getInstance( ).setAttributeField( this );
this.setListAttributeFields(AttributeFieldHome.selectAttributeFieldsByIdAttribute( this.getIdAttribute( ) ));

if ( CollectionUtils.isNotEmpty( getListAttributeFields( ) ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import fr.paris.lutece.portal.business.user.AdminUser;
import fr.paris.lutece.portal.service.message.AdminMessage;
import fr.paris.lutece.portal.service.message.AdminMessageService;
import fr.paris.lutece.portal.service.user.attribute.AttributeFieldService;
import fr.paris.lutece.portal.web.constants.Messages;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -80,6 +79,7 @@ public class AttributeRadioButton extends AbstractAttribute implements ISimpleVa
private static final String TEMPLATE_HTML_FORM_SEARCH_ATTRIBUTE = "admin/user/attribute/radiobutton/html_code_form_search_attribute_radio_button.html";
private static final String TEMPLATE_HTML_VALUE = "admin/user/attribute/radiobutton/html_code_value_attribute_radio_button.html";


/**
* Constructor
*/
Expand Down Expand Up @@ -248,7 +248,7 @@ public List<AdminUserField> getUserFieldsData( String [ ] strValues, AdminUser u
if ( StringUtils.isNotBlank( strValue ) && StringUtils.isNumeric( strValue ) )
{
int nIdField = Integer.parseInt( strValue );
attributeField = AttributeFieldService.getInstance( ).getAttributeField( nIdField );
attributeField = AttributeFieldHome.findByPrimaryKey( nIdField );
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import fr.paris.lutece.portal.business.user.AdminUser;
import fr.paris.lutece.portal.service.message.AdminMessage;
import fr.paris.lutece.portal.service.message.AdminMessageService;
import fr.paris.lutece.portal.service.user.attribute.AttributeService;
import fr.paris.lutece.portal.web.constants.Messages;

import org.apache.commons.collections.CollectionUtils;
Expand Down Expand Up @@ -86,6 +85,7 @@ public class AttributeText extends AbstractAttribute implements ISimpleValuesAtt
private static final String TEMPLATE_HTML_VALUE = "admin/user/attribute/text/html_code_value_attribute_text.html";
private static final String REGEX_ID = "-?[0-9]+";


/**
* Constructor
*/
Expand Down Expand Up @@ -286,7 +286,7 @@ public List<AdminUserField> getUserFieldsData( String [ ] strValues, AdminUser u
{
List<AdminUserField> listUserFields = new ArrayList<>( );
AdminUserField userField = new AdminUserField( );
AttributeService.getInstance( ).setAttributeField( this );
this.setListAttributeFields( AttributeFieldHome.selectAttributeFieldsByIdAttribute( this.getIdAttribute( ) ) );

if ( strValues != null )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.List;
import java.util.Locale;

import jakarta.enterprise.inject.spi.CDI;
import jakarta.servlet.http.HttpServletRequest;

/**
Expand Down Expand Up @@ -99,7 +100,8 @@ public abstract class SimpleAdminUserFieldListener implements AdminUserFieldList
@Override
public void doCreateUserFields( AdminUser user, HttpServletRequest request, Locale locale )
{
List<IAttribute> listAttributes = AttributeService.getInstance( ).getPluginAttributesWithoutFields( getPlugin( ).getName( ), locale );
AttributeService attributeService = CDI.current( ).select( AttributeService.class ).get( );
List<IAttribute> listAttributes = attributeService.getPluginAttributesWithoutFields( getPlugin( ).getName( ), locale );
List<AdminUserField> listUserFields = new ArrayList<>( );

for ( IAttribute attribute : listAttributes )
Expand Down Expand Up @@ -129,7 +131,8 @@ public void doCreateUserFields( AdminUser user, HttpServletRequest request, Loca
@Override
public void doModifyUserFields( AdminUser user, HttpServletRequest request, Locale locale, AdminUser currentUser )
{
List<IAttribute> listAttributes = AttributeService.getInstance( ).getPluginAttributesWithoutFields( getPlugin( ).getName( ), locale );
AttributeService attributeService = CDI.current( ).select( AttributeService.class ).get( );
List<IAttribute> listAttributes = attributeService.getPluginAttributesWithoutFields( getPlugin( ).getName( ), locale );
List<AdminUserField> listUserFields = new ArrayList<>( );

for ( IAttribute attribute : listAttributes )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
import java.util.Map;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.servlet.http.HttpServletRequest;

import fr.paris.lutece.portal.business.user.AdminUser;
import fr.paris.lutece.portal.service.admin.AdminUserService;
import fr.paris.lutece.portal.service.security.ISecurityTokenService;
import fr.paris.lutece.portal.service.security.SecurityTokenService;
import fr.paris.lutece.portal.service.template.AppTemplateService;
import fr.paris.lutece.util.html.HtmlTemplate;
Expand All @@ -53,6 +55,10 @@ public class AccessibilityModeAdminUserMenuItemProvider extends AbstractAdminUse
{
public static final String TEMPLATE = "admin/user/menu/modify_accessibility_mode.html";
private static final String MARK_USER = "user";

@Inject
private transient ISecurityTokenService _securityTokenService;


@Override
protected boolean isItemProviderInvoked( HttpServletRequest request )
Expand All @@ -66,7 +72,7 @@ public AdminUserMenuItem getItem( HttpServletRequest request )
AdminUser user = AdminUserService.getAdminUser( request );

Map<String, Object> model = new HashMap<>( );
model.put( SecurityTokenService.MARK_TOKEN, SecurityTokenService.getInstance( ).getToken( request, TEMPLATE ) );
model.put( SecurityTokenService.MARK_TOKEN, _securityTokenService.getToken( request, TEMPLATE ) );
model.put( MARK_USER, user );

HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE, user.getLocale( ), model );
Expand Down
Loading