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/announce/service/AnnounceSubscriptionProvider.java 128
fr/paris/lutece/plugins/announce/service/AnnounceSubscriptionProvider.java 189
            model.put( MARK_USER, subscribedUser );

            HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_USER_SUBSCRIPTION_DESCRIPTION, locale, model );

            return template.getHtml( );
        }
        else
            if ( StringUtils.equals( SUBSCRIPTION_CATEGORY, strSubscriptionKey ) )
            {
                Map<String, Object> model = new HashMap<>( );

                int nIdCategory = Integer.parseInt( strIdSubscribedResource );

                model.put( MARK_CATEGORY, CategoryHome.findByPrimaryKey( nIdCategory ) );

                HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_CATEGORY_SUBSCRIPTION_DESCRIPTION, locale, model );

                return template.getHtml( );
            }
            else
                if ( StringUtils.equals( SUBSCRIPTION_FILTER, strSubscriptionKey ) )
                {
                    AnnounceSearchFilter filter = AnnounceSearchFilterHome.findByPrimaryKey( Integer.parseInt( strIdSubscribedResource ) );
                    Map<String, Object> model = new HashMap<>( );
                    model.put( MARK_FILTER, filter );

                    if ( filter.getIdCategory( ) > 0 )
                    {
                        model.put( MARK_CATEGORY, CategoryHome.findByPrimaryKey( filter.getIdCategory( ) ) );
                    }

                    HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_FILTER_SUBSCRIPTION_DESCRIPTION, locale, model );

                    return template.getHtml( );
                }

        return StringUtils.EMPTY;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getSubscriptionHtmlDescriptionBis( LuteceUser user, String strSubscriptionKey, String strIdSubscribedResource, Locale locale, String userSub )
File Line
fr/paris/lutece/plugins/announce/web/AnnounceApp.java 1077
fr/paris/lutece/plugins/announce/web/AnnounceApp.java 1205
        EntryFilter filter = new EntryFilter( );
        filter.setIdResource( category.getId( ) );
        filter.setResourceType( Category.RESOURCE_TYPE );
        filter.setEntryParentNull( EntryFilter.FILTER_TRUE );
        filter.setFieldDependNull( EntryFilter.FILTER_TRUE );
        filter.setIdIsComment( EntryFilter.FILTER_FALSE );

        List<Entry> listEntryFirstLevel = EntryHome.getEntryList( filter );
        List<GenericAttributeError> listErrors = new ArrayList<>( );

        AnnounceDTO announceDTO = new AnnounceDTO( announce );

        for ( Entry entry : listEntryFirstLevel )
        {
            listErrors.addAll( _announceService.getResponseEntry( request, entry.getIdEntry( ), request.getLocale( ), announceDTO ) );
        }

        if ( category.getDisplayCaptcha( ) && _captchaSecurityService.isAvailable( ) && !_captchaSecurityService.validate( request ) )
        {
            GenericAttributeError genAttError = new GenericAttributeError( );
            genAttError.setErrorMessage( I18nService.getLocalizedString( ERROR_MESSAGE_WRONG_CAPTCHA, request.getLocale( ) ) );
            listErrors.add( genAttError );
        }
File Line
fr/paris/lutece/plugins/announce/web/AnnounceApp.java 710
fr/paris/lutece/plugins/announce/web/AnnounceJspBean.java 249
            Collection<Entry> listGeolocalisation = new ArrayList<>( );

            for ( Response response : listResponses )
            {
                if ( response.getEntry( ) != null && response.getEntry( ).getEntryType( ) != null
                        && "announce.entryTypeGeolocation".equals( response.getEntry( ).getEntryType( ).getBeanName( ) ) )
                {
                    Entry entry = EntryHome.findByPrimaryKey( response.getEntry( ).getIdEntry( ) );
                    for ( Field filed : entry.getFields( ) )
                    {

                        if ( response.getField( ) != null && filed.getIdField( ) == response.getField( ).getIdField( ) )
                        {
                            response.setField( filed );
                        }
                    }

                    boolean bool = true;

                    for ( Entry ent : listGeolocalisation )
                    {
                        if ( ent.getIdEntry( ) == ( entry.getIdEntry( ) ) )
                        {
                            bool = false;
                        }
                    }
                    if ( bool )
                    {
                        listGeolocalisation.add( entry );
                    }
                }

            }
File Line
fr/paris/lutece/plugins/announce/business/CategoryDAO.java 86
fr/paris/lutece/plugins/announce/business/CategoryDAO.java 107
    public void insert( Category category, Plugin plugin )
    {
        try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_INSERT, plugin ) )
        {
            category.setId( newPrimaryKey( plugin ) );

            int nIndex = 1;
            daoUtil.setInt( nIndex++, category.getId( ) );
            daoUtil.setInt( nIndex++, category.getIdSector( ) );
            daoUtil.setString( nIndex++, category.getLabel( ) );
            daoUtil.setBoolean( nIndex++, category.getDisplayPrice( ) );
            daoUtil.setBoolean( nIndex++, category.getPriceMandatory( ) );
            daoUtil.setInt( nIndex++, category.getAnnouncesValidation( ) );
            daoUtil.setInt( nIndex++, category.getIdMailingList( ) );
            daoUtil.setBoolean( nIndex++, category.getDisplayCaptcha( ) );
            daoUtil.setInt( nIndex, category.getIdWorkflow( ) );
            daoUtil.executeUpdate( );
        }
File Line
fr/paris/lutece/plugins/announce/web/AnnounceApp.java 1034
fr/paris/lutece/plugins/announce/web/AnnounceApp.java 1163
        String strTitleAnnounce = request.getParameter( PARAMETER_TITLE_ANNOUNCE );
        String strDescriptionAnnounce = request.getParameter( PARAMETER_DESCRIPTION_ANNOUNCE );
        String strContactInformation = request.getParameter( PARAMETER_CONTACT_INFORMATION );
        String strTags = request.getParameter( PARAMETER_TAGS );
        Double nPriceAnnounce = ( request.getParameter( PARAMETER_PRICE_ANNOUNCE ) == null ) ? 0.0
                : Double.parseDouble( request.getParameter( PARAMETER_PRICE_ANNOUNCE ) );

        if ( StringUtils.isEmpty( strTitleAnnounce ) || StringUtils.isEmpty( strDescriptionAnnounce ) || StringUtils.isEmpty( strContactInformation )
                || ( category.getDisplayPrice( ) && category.getPriceMandatory( ) && ( nPriceAnnounce == 0.0 ) ) )
        {
            SiteMessageService.setMessage( request, Messages.MANDATORY_FIELDS, SiteMessage.TYPE_STOP );

            return new ArrayList<>( );
File Line
fr/paris/lutece/plugins/announce/web/CategoryJspBean.java 276
fr/paris/lutece/plugins/announce/web/CategoryJspBean.java 403
        String strCategoryLabel = request.getParameter( PARAMETER_CATEGORY_LABEL );
        int nIdSector = Integer.parseInt( request.getParameter( PARAMETER_CATEGORY_SECTOR_ID ) );
        int nAnnouncesValidation = Integer.parseInt( request.getParameter( PARAMETER_CATEGORY_ANNOUNCES_VALIDATION ) );
        String strDisplayPrice = request.getParameter( PARAMETER_DISPLAY_PRICE );
        int nIdMailingList = Integer.parseInt( request.getParameter( PARAMETER_MAILING_LIST_ID ) );
        int nIdWorkflow = Integer.parseInt( request.getParameter( PARAMETER_ID_WORKFLOW ) != null ? request.getParameter( PARAMETER_ID_WORKFLOW ) : "-1" );
        boolean bDisplayCaptcha = Boolean.parseBoolean( request.getParameter( PARAMETER_DISPLAY_CAPTCHA ) );
        boolean bPriceMandatory = Boolean.parseBoolean( request.getParameter( PARAMETER_PRICE_MANDATORY ) );

        // Mandatory sectors
        if ( ( nIdSector == 0 ) || StringUtils.isEmpty( strCategoryLabel ) )
File Line
fr/paris/lutece/plugins/announce/business/AnnounceHome.java 298
fr/paris/lutece/plugins/announce/business/AnnounceHome.java 329
        _dao.setPublished( announce, _plugin );

        if ( announce.getPublished( ) && !announce.getSuspended( ) && !announce.getSuspendedByUser( ) )
        {
            AnnounceSearchService.getInstance( ).addIndexerAction( announce.getId( ), IndexerAction.TASK_CREATE, _plugin );
        }
        else
        {
            AnnounceSearchService.getInstance( ).addIndexerAction( announce.getId( ), IndexerAction.TASK_DELETE, _plugin );
        }

        AnnounceCacheService.getService( ).removeKey( AnnounceCacheService.getListIdPublishedAnnouncesCacheKey( ) );
        AnnounceCacheService.getService( ).removeKey( AnnounceCacheService.getAnnounceCacheKey( announce.getId( ) ) );
    }

    public static void setHasNotifed( Announce announce )
File Line
fr/paris/lutece/plugins/announce/business/AnnounceHome.java 298
fr/paris/lutece/plugins/announce/business/AnnounceHome.java 329
fr/paris/lutece/plugins/announce/business/AnnounceHome.java 353
        _dao.setPublished( announce, _plugin );

        if ( announce.getPublished( ) && !announce.getSuspended( ) && !announce.getSuspendedByUser( ) )
        {
            AnnounceSearchService.getInstance( ).addIndexerAction( announce.getId( ), IndexerAction.TASK_CREATE, _plugin );
        }
        else
        {
            AnnounceSearchService.getInstance( ).addIndexerAction( announce.getId( ), IndexerAction.TASK_DELETE, _plugin );
        }

        AnnounceCacheService.getService( ).removeKey( AnnounceCacheService.getListIdPublishedAnnouncesCacheKey( ) );
        AnnounceCacheService.getService( ).removeKey( AnnounceCacheService.getAnnounceCacheKey( announce.getId( ) ) );
    }

    public static void setHasNotifed( Announce announce )