Fork me on GitHub

CPD Results

The following document contains the results of PMD's CPD 6.13.0.

Duplications

File Line
fr/paris/lutece/plugins/identitystore/v1/web/service/HttpAccessTransport.java 102
fr/paris/lutece/plugins/identitystore/v2/web/service/HttpAccessTransport.java 135
            oResponse = mapper.readValue( strResponseJSON, responseJsonClass );
        }
        catch( Exception e )
        {
            handleException( e );
        }

        return oResponse;
    }

    @Override
    public <T> T doGet( String strEndPointUrl, Map<String, String> mapParams, Map<String, String> mapHeadersRequest, Class<T> responseJsonClass,
            ObjectMapper mapper ) throws IdentityStoreException
    {
        HttpAccess clientHttp = new HttpAccess( );
        T oResponse = null;

        try
        {
            URIBuilder uriBuilder = new URIBuilder( strEndPointUrl );

            if ( ( mapParams != null ) && !mapParams.isEmpty( ) )
            {
                for ( String strParamKey : mapParams.keySet( ) )
                {
                    uriBuilder.addParameter( strParamKey, mapParams.get( strParamKey ) );
                }
            }

            String strResponseJSON = clientHttp.doGet( uriBuilder.toString( ), null, null, mapHeadersRequest );

            oResponse = mapper.readValue( strResponseJSON, responseJsonClass );
        }
        catch( Exception e )
        {
            handleException( e );
        }

        return oResponse;
    }

    @Override
    public <T> T doPostMultiPart( String strEndPointUrl, Map<String, String> mapParams, Map<String, String> mapHeadersRequest, Map<String, FileItem> mapFiles,
            Class<T> responseJsonClass, ObjectMapper mapper ) throws IdentityStoreException
    {
        HttpAccess clientHttp = new HttpAccess( );
        T oResponse = null;

        try
        {
            Map<String, List<String>> params = new HashMap<String, List<String>>( );

            if ( mapParams != null )
            {
                for ( String strParamKey : mapParams.keySet( ) )
                {
                    // HttpAccess allow to post for a given param a list of value
                    List<String> listParam = new ArrayList<String>( );
                    listParam.add( mapParams.get( strParamKey ) );
                    params.put( strParamKey, listParam );
                }
            }

            String strResponseJSON = clientHttp.doPostMultiPart( strEndPointUrl, params, mapFiles, null, null, mapHeadersRequest );

            oResponse = mapper.readValue( strResponseJSON, responseJsonClass );
        }
        catch( Exception e )
        {
            handleException( e );
        }

        return oResponse;
    }

    @Override
    public <T> T doDelete( String strEndPointUrl, Map<String, String> mapParams, Map<String, String> mapHeadersRequest, Class<T> responseJsonClass,
            ObjectMapper mapper ) throws IdentityStoreException
    {
        HttpAccess clientHttp = new HttpAccess( );
        T oResponse = null;

        try
        {
            URIBuilder uriBuilder = new URIBuilder( strEndPointUrl );

            if ( ( mapParams != null ) && !mapParams.isEmpty( ) )
            {
                for ( String strParamKey : mapParams.keySet( ) )
                {
                    uriBuilder.addParameter( strParamKey, mapParams.get( strParamKey ) );
                }
            }

            String strResponseJSON = clientHttp.doDelete( uriBuilder.toString( ), null, null, mapHeadersRequest, null );

            oResponse = mapper.readValue( strResponseJSON, responseJsonClass );
        }
        catch( Exception e )
        {
            handleException( e );
        }

        return oResponse;
    }

    /**
     * add error log and throw correct Exception depending on the specified Exception
     * 
     * @param e
     *            root exception
     * @throws IdentityNotFoundException
     *             if the specified Exception is an HttpAccessException with HTTP code 404
     * @throws IdentityStoreException
     *             otherwise
     */
    private void handleException( Exception e ) throws IdentityStoreException
    {
        String strError = "LibraryIdentityStore - Error HttpAccessTransport :";
        AppLogService.error( strError + e.getMessage( ), e );

        if ( e instanceof InvalidResponseStatus && HttpStatus.SC_NOT_FOUND == ( (InvalidResponseStatus) e ).getResponseStatus( ) )
File Line
fr/paris/lutece/plugins/identitystore/v1/web/rs/service/AbstractIdentityTransportRest.java 308
fr/paris/lutece/plugins/identitystore/v2/web/rs/service/AbstractIdentityTransportRest.java 295
    }

    /**
     * check input parameters to get an identity
     * 
     * @param strIdConnection
     *            connection id
     * @param strCustomerId
     *            customer id
     * @param strClientCode
     *            client code
     * @throws AppException
     *             if the parameters are not valid
     */
    private void checkFetchParameters( String strIdConnection, String strCustomerId, String strClientCode ) throws AppException
    {
        checkIdentity( strIdConnection, strCustomerId );
        checkClientApplication( strClientCode );
    }

    /**
     * check input parameters to create an identity
     * 
     * @param identityChange
     *            identity change, ensure that author and identity are filled
     * @throws AppException
     *             if the parameters are not valid
     */
    private void checkCreateParameters( IdentityChangeDto identityChange ) throws AppException
    {
        checkIdentityChange( identityChange );
        checkClientApplication( identityChange.getAuthor( ).getApplicationCode( ) );
    }

    /**
     * check input parameters to update an identity
     * 
     * @param identityChange
     *            identity change, ensure that author and identity are filled
     * @throws AppException
     *             if the parameters are not valid
     */
    private void checkUpdateParameters( IdentityChangeDto identityChange ) throws AppException
    {
        checkIdentityChange( identityChange );
        checkIdentity( identityChange.getIdentity( ).getConnectionId( ), identityChange.getIdentity( ).getCustomerId( ) );
        checkClientApplication( identityChange.getAuthor( ).getApplicationCode( ) );
    }

    /**
     * check input parameters to delete an identity
     * 
     * @param strClientCode
     *            client code
     * @throws AppException
     *             if the parameters are not valid
     */
    private void checkDeleteParameters( String strClientCode ) throws AppException
    {
        checkClientApplication( strClientCode );
    }

    /**
     * check that parameters are valid, otherwise throws an AppException
     * 
     * @param strIdConnection
     *            connection id
     * @param strCustomerId
     *            customer id
     * @param strAttributeKey
     *            attribute Key
     * @param strClientCode
     *            client code
     * @throws AppException
     *             if the parameters are not valid
     */
    private void checkDownloadFileAttributeParams( String strIdConnection, String strCustomerId, String strAttributeKey, String strClientCode )
            throws AppException
    {
        if ( StringUtils.isEmpty( strAttributeKey ) )
        {
            throw new AppException( "missing parameters : attribute key must be provided" );
        }

        checkIdentity( strIdConnection, strCustomerId );
        checkClientApplication( strClientCode );
    }

    /**
     * check whether the parameters related to the identity are valid or not
     * 
     * @param strIdConnection
     *            the connection id
     * @param strCustomerId
     *            the customer id
     * @throws AppException
     *             if the parameters are not valid
     */
    private void checkIdentity( String strIdConnection, String strCustomerId ) throws AppException
    {
        if ( StringUtils.isEmpty( strIdConnection ) && Constants.NO_CUSTOMER_ID.equals( strCustomerId ) )
        {
            throw new AppException( "missing parameters : connection Id or customer Id must be provided" );
        }
    }

    /**
     * check whether the parameters related to the application are valid or not
     * 
     * @param strClientCode
     *            the client code
     * @throws AppException
     *             if the parameters are not valid
     */
    private void checkClientApplication( String strClientCode ) throws AppException
    {
        if ( StringUtils.isEmpty( strClientCode ) )
        {
            throw new AppException( "missing parameters : client Application Code is mandatory" );
        }
    }

    /**
     * check whether the parameters related to the identity change are valid or not
     * 
     * @param identityChange
     *            the identity change
     * @throws AppException
     *             if the parameters are not valid
     */
    private void checkIdentityChange( IdentityChangeDto identityChange ) throws AppException
    {
        if ( ( identityChange == null ) || ( identityChange.getAuthor( ) == null ) || ( identityChange.getIdentity( ) == null ) )
        {
            throw new AppException( "missing parameters : provided identityChange object is invalid, check author and identity are filled" );
        }
    }
}
File Line
fr/paris/lutece/plugins/identitystore/v1/web/service/HttpAccessTransport.java 55
fr/paris/lutece/plugins/identitystore/v2/web/service/HttpAccessTransport.java 57
public class HttpAccessTransport implements IHttpTransportProvider
{
    /**
     * {@inheritDoc}
     * 
     * @throws IdentityStoreException
     */
    @Override
    public String doPost( String strUrl, Map<String, String> mapParams, Map<String, String> mapHeadersRequest ) throws IdentityStoreException
    {
        HttpAccess clientHttp = new HttpAccess( );
        Map<String, String> mapHeadersResponse = new HashMap<String, String>( );

        String strOutput = StringUtils.EMPTY;

        try
        {
            strOutput = clientHttp.doPost( strUrl, mapParams, null, null, mapHeadersRequest, mapHeadersResponse );
        }
        catch( Exception e )
        {
            handleException( e );
        }

        return strOutput;
    }

    /**
     * {@inheritDoc}
     * 
     * @throws IdentityStoreException
     */
    @Override
    public <T> T doPostJSON( String strUrl, Map<String, String> mapParams, Map<String, String> mapHeadersRequest, Object json, Class<T> responseJsonClass,
            ObjectMapper mapper ) throws IdentityStoreException
    {
        HttpAccess clientHttp = new HttpAccess( );
        Map<String, String> mapHeadersResponse = new HashMap<String, String>( );
        mapHeadersRequest.put( Constants.ACCEPT, Constants.APPLICATION_JSON );
        mapHeadersRequest.put( Constants.CONTENT_TYPE, Constants.CONTENT_FORMAT_CHARSET );

        T oResponse = null;

        try
        {
            String strJSON = mapper.writeValueAsString( json );
            String strResponseJSON = clientHttp.doPostJSON( strUrl, strJSON, mapHeadersRequest, mapHeadersResponse );
            oResponse = mapper.readValue( strResponseJSON, responseJsonClass );
        }
        catch( Exception e )
        {
            handleException( e );
        }

        return oResponse;
    }

    @Override
    public <T> T doGet( String strEndPointUrl, Map<String, String> mapParams, Map<String, String> mapHeadersRequest, Class<T> responseJsonClass,
File Line
fr/paris/lutece/plugins/identitystore/v1/web/rs/service/AbstractIdentityTransportRest.java 73
fr/paris/lutece/plugins/identitystore/v2/web/rs/service/AbstractIdentityTransportRest.java 71
        _mapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES );
    }

    /** HTTP transport provider */
    private IHttpTransportProvider _httpTransport;

    /** URL for identityStore REST service */
    private String _strIdentityStoreEndPoint;

    /**
     * setter of identityStoreEndPoint
     * 
     * @param strIdentityStoreEndPoint
     *            value to use
     */
    public void setIdentityStoreEndPoint( String strIdentityStoreEndPoint )
    {
        this._strIdentityStoreEndPoint = strIdentityStoreEndPoint;
    }

    /**
     * setter of httpTransport
     * 
     * @param httpTransport
     *            IHttpTransportProvider to use
     */
    public void setHttpTransport( IHttpTransportProvider httpTransport )
    {
        this._httpTransport = httpTransport;
    }

    /**
     * @return the httpTransport
     */
    protected IHttpTransportProvider getHttpTransport( )
    {
        return _httpTransport;
    }

    /**
     * add specific authentication to request
     * 
     * @param mapHeadersRequest
     *            map of headers to add
     * @throws IdentityStoreException
     */
    protected abstract void addAuthentication( Map<String, String> mapHeadersRequest ) throws IdentityStoreException;

    /**
     * {@inheritDoc}
     * 
     * @throws IdentityStoreException
     */
    @Override
    public IdentityDto getIdentity( String strIdConnection, String strCustomerId, String strClientCode ) throws AppException, IdentityStoreException
    {

        checkFetchParameters( strIdConnection, strCustomerId, strClientCode );

        Map<String, String> mapHeadersRequest = new HashMap<String, String>( );
        addAuthentication( mapHeadersRequest );
        mapHeadersRequest.put( Constants.PARAM_CLIENT_CODE, strClientCode );

        Map<String, String> mapParams = new HashMap<String, String>( );
        mapParams.put( Constants.PARAM_ID_CONNECTION, strIdConnection );
        mapParams.put( Constants.PARAM_ID_CUSTOMER, strCustomerId );

        IdentityDto identityDto = _httpTransport.doGet( _strIdentityStoreEndPoint + Constants.VERSION_PATH_V1 + Constants.IDENTITY_PATH, mapParams,
File Line
fr/paris/lutece/plugins/identitystore/v1/web/service/IHttpTransportProvider.java 83
fr/paris/lutece/plugins/identitystore/v2/web/service/IHttpTransportProvider.java 106
    <T> T doPostJSON( String strUrl, Map<String, String> mapParams, Map<String, String> mapHeadersRequest, Object json, Class<T> responseJsonClass,
            ObjectMapper mapper ) throws IdentityStoreException;

    /**
     * make a Get request on given url with parameters
     * 
     * @param strEndPointUrl
     *            url
     * @param mapParams
     *            param to add to url
     * @param mapHeadersRequest
     *            request header
     * @param responseJsonClass
     *            the class
     * @param <T>
     *            of the response
     * @param mapper
     *            mapper for JSON serialize / deserialize
     * @return response list
     * @throws IdentityStoreException
     */
    <T> T doGet( String strEndPointUrl, Map<String, String> mapParams, Map<String, String> mapHeadersRequest, Class<T> responseJsonClass, ObjectMapper mapper )
            throws IdentityStoreException;

    /**
     * make a multipart Post request
     * 
     * @param strEndPointUrl
     *            url
     * @param mapParams
     *            param to add to request
     * @param mapHeadersRequest
     *            request header
     * @param mapFiles
     *            file to add to multipart request
     * @param responseJsonClass
     *            the class
     * @param <T>
     *            of the response
     * @param mapper
     *            mapper for JSON serialize / deserialize
     * @return response list
     * @throws IdentityStoreException
     */
    <T> T doPostMultiPart( String strEndPointUrl, Map<String, String> mapParams, Map<String, String> mapHeadersRequest, Map<String, FileItem> mapFiles,
            Class<T> responseJsonClass, ObjectMapper mapper ) throws IdentityStoreException;

    /**
     * make a Delete request on given url with parameters
     * 
     * @param strEndPointUrl
     *            url
     * @param mapParams
     *            param to add to url
     * @param mapHeadersRequest
     *            request header
     * @param responseJsonClass
     *            the class
     * @param <T>
     *            of the response
     * @param mapper
     *            mapper for JSON serialize / deserialize
     * @return response list
     * @throws IdentityStoreException
     */
    <T> T doDelete( String strEndPointUrl, Map<String, String> mapParams, Map<String, String> mapHeadersRequest, Class<T> responseJsonClass,
            ObjectMapper mapper ) throws IdentityStoreException;
}
File Line
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/MockIdentityTransportRest.java 140
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/MockIdentityTransportRest.java 167
        AppLogService.debug( "MockIdentityTransportRest.createIdentity always return ok" );

        IdentityDto identity = identityChange.getIdentity( );

        if ( StringUtils.isEmpty( identity.getConnectionId( ) ) )
        {
            identity.setConnectionId( CONNECTION_ID_PREFIX + _listIdentities.size( ) );
        }
        if ( StringUtils.isEmpty( identity.getCustomerId( ) ) )
        {
            identity.setCustomerId( CUSTOMER_ID_PREFIX + _listIdentities.size( ) );
        }
        _listIdentities.add( identity );

        IdentityChangeResponse response = new IdentityChangeResponse( );
        response.setStatus( ResponseStatusFactory.success( ).setMessage( "OK" ).setMessageKey( Constants.PROPERTY_REST_INFO_SUCCESSFUL_OPERATION ) );
        response.setCustomerId( identity.getCustomerId( ) );
        response.setConnectionId( identity.getConnectionId( ) );
        response.setCreationDate( new Timestamp( new Date( ).getTime( ) ) );

        return response;
    }

    @Override
    public IdentityChangeResponse importIdentity( IdentityChangeRequest identityChange, String strClientCode, RequestAuthor author )
File Line
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/ServiceContractTransportRest.java 160
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/ServiceContractTransportRest.java 179
    public ServiceContractChangeResponse updateServiceContract( final ServiceContractDto serviceContract, final Integer nServiceContractId,
            final String strClientCode, final RequestAuthor author ) throws IdentityStoreException
    {
        this.checkCommonHeaders( strClientCode, author );
        IdentityRequestValidator.instance( ).checkServiceContract( serviceContract );
        IdentityRequestValidator.instance( ).checkContractId( nServiceContractId );

        final Map<String, String> mapHeadersRequest = new HashMap<>( );
        mapHeadersRequest.put( Constants.PARAM_CLIENT_CODE, strClientCode );
        mapHeadersRequest.put( Constants.PARAM_AUTHOR_NAME, author.getName( ) );
        mapHeadersRequest.put( Constants.PARAM_AUTHOR_TYPE, author.getType( ).name( ) );

        final Map<String, String> mapParams = new HashMap<>( );

        final String url = _strIdentityStoreEndPoint + _strIdentityPath + Constants.VERSION_PATH_V3 + Constants.SERVICECONTRACTS_PATH + "/" + nServiceContractId;
File Line
fr/paris/lutece/plugins/identitystore/v2/web/rs/service/AbstractIdentityTransportRest.java 151
fr/paris/lutece/plugins/identitystore/v2/web/rs/service/AbstractIdentityTransportRest.java 197
        checkUpdateParameters( identityChange );

        Map<String, String> mapHeadersRequest = new HashMap<String, String>( );
        addAuthentication( mapHeadersRequest );

        Map<String, String> mapParams = new HashMap<String, String>( );

        String strJsonReq;

        try
        {
            strJsonReq = _mapper.writeValueAsString( identityChange );
            mapParams.put( Constants.PARAM_IDENTITY_CHANGE, strJsonReq );
        }
        catch( JsonProcessingException e )
        {
            String strError = "AbstractIdentityTransportRest - Error serializing IdentityChangeDto : ";
            AppLogService.error( strError + e.getMessage( ), e );
            throw new IdentityStoreException( strError, e );
        }

        IdentityDto identityDto = _httpTransport.doPostMultiPart(
                _strIdentityStoreEndPoint + Constants.VERSION_PATH_V2 + Constants.IDENTITY_PATH + Constants.UPDATE_IDENTITY_PATH, mapParams, mapHeadersRequest,
File Line
fr/paris/lutece/plugins/identitystore/v1/web/service/IdentityService.java 53
fr/paris/lutece/plugins/identitystore/v2/web/service/IdentityService.java 54
public class IdentityService
{
    /** transport provider */
    private IIdentityTransportProvider _transportProvider;

    /**
     * Simple Constructor
     */
    public IdentityService( )
    {
        super( );
    }

    /**
     * Constructor with IIdentityTransportProvider in parameters
     * 
     * @param transportProvider
     *            IIdentityTransportProvider
     */
    public IdentityService( IIdentityTransportProvider transportProvider )
    {
        super( );
        this._transportProvider = transportProvider;
    }

    /**
     * setter of transportProvider parameter
     * 
     * @param transportProvider
     *            IIdentityTransportProvider
     */
    public void setTransportProvider( IIdentityTransportProvider transportProvider )
    {
        this._transportProvider = transportProvider;
    }

    /**
     * get identity matching connectionId for provided application code
     *
     * @param strConnectionId
     *            connection Id
     * @param strApplicationCode
     *            application code of calling application
     * @return identity if found
     * @throws AppException
     *             if inconsitent parmeters provided, or errors occurs...
     * @throws IdentityStoreException
     *
     */
    public IdentityDto getIdentityByConnectionId( String strConnectionId, String strApplicationCode ) throws AppException, IdentityStoreException
    {
        return getIdentity( strConnectionId, Constants.NO_CUSTOMER_ID, strApplicationCode );
    }

    /**
     * get identity matching customerId for provided application code
     *
     * @param strCustomerId
     *            customer Id
     * @param strApplicationCode
     *            application code of calling application
     * @return identity if found
     * @throws AppException
     *             if inconsitent parmeters provided, or errors occurs...
     * @throws IdentityStoreException
     *
     */
    public IdentityDto getIdentityByCustomerId( String strCustomerId, String strApplicationCode ) throws AppException, IdentityStoreException
    {
        return getIdentity( StringUtils.EMPTY, strCustomerId, strApplicationCode );
    }

    /**
     * get identity matching connectionId and customerId for provided application code
     *
     * @param strConnectionId
     *            connection Id (can be null if strCustomerId is provided)
     * @param strCustomerId
     *            customer Id (can be null if strConnectionId is provided)
     * @param strApplicationCode
     *            application code of calling application
     * @return identity if found
     * @throws AppException
     *             if inconsitent parmeters provided, or errors occurs...
     * @throws IdentityStoreException
     *
     */
    public IdentityDto getIdentity( String strConnectionId, String strCustomerId, String strApplicationCode ) throws IdentityStoreException
File Line
fr/paris/lutece/plugins/identitystore/v1/web/rs/service/AbstractIdentityTransportRest.java 140
fr/paris/lutece/plugins/identitystore/v2/web/rs/service/AbstractIdentityTransportRest.java 137
        IdentityDto identityDto = _httpTransport.doGet( _strIdentityStoreEndPoint + Constants.VERSION_PATH_V1 + Constants.IDENTITY_PATH, mapParams,
                mapHeadersRequest, IdentityDto.class, _mapper );

        return identityDto;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public IdentityDto updateIdentity( IdentityChangeDto identityChange, Map<String, FileItem> mapFileItem ) throws IdentityStoreException
    {
        checkUpdateParameters( identityChange );

        Map<String, String> mapHeadersRequest = new HashMap<String, String>( );
        addAuthentication( mapHeadersRequest );

        Map<String, String> mapParams = new HashMap<String, String>( );

        String strJsonReq;

        try
        {
            strJsonReq = _mapper.writeValueAsString( identityChange );
            mapParams.put( Constants.PARAM_IDENTITY_CHANGE, strJsonReq );
        }
        catch( JsonProcessingException e )
        {
File Line
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/IdentityTransportRest.java 178
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/IdentityTransportRest.java 338
    public IdentityChangeResponse deleteIdentity( final String strCustomerId, final String strClientCode, final RequestAuthor author )
            throws IdentityStoreException
    {
        this.checkCommonHeaders( strClientCode, author );
        IdentityRequestValidator.instance( ).checkCustomerId( strCustomerId );

        final Map<String, String> mapHeadersRequest = new HashMap<>( );
        mapHeadersRequest.put( Constants.PARAM_CLIENT_CODE, strClientCode );
        mapHeadersRequest.put( Constants.PARAM_AUTHOR_NAME, author.getName( ) );
        mapHeadersRequest.put( Constants.PARAM_AUTHOR_TYPE, author.getType( ).name( ) );

        final String url = _strIdentityStoreEndPoint + _strIdentityPath + Constants.VERSION_PATH_V3 + Constants.IDENTITY_PATH + "/" + strCustomerId;
File Line
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/IdentityTransportRest.java 403
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/IdentityTransportRest.java 417
    public IdentityTaskGetStatusResponse getIdentityTaskStatus( final String taskCode, final String strClientCode, final RequestAuthor author ) throws IdentityStoreException {
        this.checkCommonHeaders( strClientCode, author );
        IdentityTaskRequestValidator.instance( ).validateTaskCode( taskCode );

        final Map<String, String> mapHeadersRequest = new HashMap<>( );
        mapHeadersRequest.put( Constants.PARAM_CLIENT_CODE, strClientCode );
        mapHeadersRequest.put( Constants.PARAM_AUTHOR_NAME, author.getName( ) );
        mapHeadersRequest.put( Constants.PARAM_AUTHOR_TYPE, author.getType( ).name( ) );

        final String url = _strIdentityStoreEndPoint + _strTaskStackPath + Constants.VERSION_PATH_V1 + Constants.TASK_PATH + Constants.TASK_STATUS_PATH + "/" + taskCode;
File Line
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/IdentityTransportRest.java 159
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/IdentityTransportRest.java 236
    public IdentityChangeResponse createIdentity( IdentityChangeRequest identityChange, final String strClientCode, final RequestAuthor author )
            throws IdentityStoreException
    {
        this.checkCommonHeaders( strClientCode, author );
        IdentityRequestValidator.instance( ).checkIdentityChange( identityChange, false );

        final Map<String, String> mapHeadersRequest = new HashMap<>( );
        mapHeadersRequest.put( Constants.PARAM_CLIENT_CODE, strClientCode );
        mapHeadersRequest.put( Constants.PARAM_AUTHOR_NAME, author.getName( ) );
        mapHeadersRequest.put( Constants.PARAM_AUTHOR_TYPE, author.getType( ).name( ) );

        final String url = _strIdentityStoreEndPoint + _strIdentityPath + Constants.VERSION_PATH_V3 + Constants.IDENTITY_PATH;
File Line
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/IdentityTransportRest.java 178
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/IdentityTransportRest.java 290
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/IdentityTransportRest.java 338
    public IdentityChangeResponse deleteIdentity( final String strCustomerId, final String strClientCode, final RequestAuthor author )
            throws IdentityStoreException
    {
        this.checkCommonHeaders( strClientCode, author );
        IdentityRequestValidator.instance( ).checkCustomerId( strCustomerId );

        final Map<String, String> mapHeadersRequest = new HashMap<>( );
        mapHeadersRequest.put( Constants.PARAM_CLIENT_CODE, strClientCode );
        mapHeadersRequest.put( Constants.PARAM_AUTHOR_NAME, author.getName( ) );
        mapHeadersRequest.put( Constants.PARAM_AUTHOR_TYPE, author.getType( ).name( ) );

        final String url = _strIdentityStoreEndPoint + _strIdentityPath + Constants.VERSION_PATH_V3 + Constants.IDENTITY_PATH + "/" + strCustomerId;
File Line
fr/paris/lutece/plugins/identitystore/v1/web/rs/service/IdentityTransportApiManagerRest.java 74
fr/paris/lutece/plugins/identitystore/v2/web/rs/service/IdentityTransportApiManagerRest.java 73
        this.setHttpTransport( new fr.paris.lutece.plugins.identitystore.v1.web.service.HttpAccessTransport( ) );
    }

    /**
     * setter of apiManagerEndPoint
     * 
     * @param strApiManagerEndPoint
     *            value to use
     */
    public void setApiManagerEndPoint( String strApiManagerEndPoint )
    {
        this._strApiManagerEndPoint = strApiManagerEndPoint;
    }

    /**
     * Sets the API Manager credentials
     * 
     * @param strApiManagerCredentials
     *            the API Manager credentials
     */
    public void setApiManagerCredentials( String strApiManagerCredentials )
    {
        this._strApiManagerCredentials = strApiManagerCredentials;
    }

    /**
     * Gets the security token from API Manager
     * 
     * @return the token
     * @throws IdentityStoreException
     */
    private String getToken( ) throws IdentityStoreException
    {
        String strToken = StringUtils.EMPTY;

        Map<String, String> mapHeadersRequest = new HashMap<String, String>( );
        Map<String, String> mapParams = new HashMap<String, String>( );

        mapParams.put( PARAMS_GRANT_TYPE, PARAMS_GRANT_TYPE_VALUE );

        mapHeadersRequest.put( Constants.ACCEPT, "application/json" );
File Line
fr/paris/lutece/plugins/identitystore/v1/web/service/HttpAccessTransport.java 113
fr/paris/lutece/plugins/identitystore/v1/web/service/HttpAccessTransport.java 178
fr/paris/lutece/plugins/identitystore/v2/web/service/HttpAccessTransport.java 146
fr/paris/lutece/plugins/identitystore/v2/web/service/HttpAccessTransport.java 211
    public <T> T doGet( String strEndPointUrl, Map<String, String> mapParams, Map<String, String> mapHeadersRequest, Class<T> responseJsonClass,
            ObjectMapper mapper ) throws IdentityStoreException
    {
        HttpAccess clientHttp = new HttpAccess( );
        T oResponse = null;

        try
        {
            URIBuilder uriBuilder = new URIBuilder( strEndPointUrl );

            if ( ( mapParams != null ) && !mapParams.isEmpty( ) )
            {
                for ( String strParamKey : mapParams.keySet( ) )
                {
                    uriBuilder.addParameter( strParamKey, mapParams.get( strParamKey ) );
                }
            }

            String strResponseJSON = clientHttp.doGet( uriBuilder.toString( ), null, null, mapHeadersRequest );
File Line
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/HttpAccessTransport.java 103
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/HttpAccessTransport.java 134
    public <T extends ResponseDto> T doPostJSON( String strUrl, Map<String, String> mapParams, Map<String, String> mapHeadersRequest, Object json,
            Class<T> responseJsonClass, ObjectMapper mapper ) throws IdentityStoreException
    {
        final Map<String, String> mapHeadersResponse = new HashMap<>( );
        mapHeadersRequest.put( Constants.ACCEPT, Constants.APPLICATION_JSON );
        mapHeadersRequest.put( Constants.CONTENT_TYPE, Constants.CONTENT_FORMAT_CHARSET );

        T oResponse = null;

        try
        {
            addAuthentication( mapHeadersRequest );

            String strJSON = mapper.writeValueAsString( json );
            String strResponseJSON = this._httpClient.doPostJSON( strUrl, strJSON, mapHeadersRequest, mapHeadersResponse );
File Line
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/HttpAccessTransport.java 191
fr/paris/lutece/plugins/identitystore/v3/web/rs/service/HttpAccessTransport.java 223
    public <T extends ResponseDto> T doGet( String strEndPointUrl, Map<String, String> mapParams, Map<String, String> mapHeadersRequest,
            Class<T> responseJsonClass, ObjectMapper mapper ) throws IdentityStoreException
    {
        T oResponse = null;

        try
        {
            URIBuilder uriBuilder = new URIBuilder( strEndPointUrl );

            if ( ( mapParams != null ) && !mapParams.isEmpty( ) )
            {
                for ( String strParamKey : mapParams.keySet( ) )
                {
                    uriBuilder.addParameter( strParamKey, mapParams.get( strParamKey ) );
                }
            }

            addAuthentication( mapHeadersRequest );

            String strResponseJSON = this._httpClient.doGet( uriBuilder.toString( ), null, null, mapHeadersRequest );