CPD Results

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

Duplications

FileLine
org/deegree/services/wms/controller/capabilities/WmsCapabilities111LegacyWriter.java176
org/deegree/services/wms/controller/capabilities/WmsCapabilities130LegacyWriter.java177
            writer.writeNamespace( XLINK_PREFIX, XLNNS );
            writer.writeAttribute( XLNNS, "type", "simple" );
            writer.writeAttribute( XLNNS, "href", mdUrl );
            writer.writeEndElement();
            writer.writeEndElement();
        }
    }

    private String getMetadataUrl( Layer layer ) {
        String mdUrl = null;
        if ( layer.getName() != null && metadata != null ) {
            DatasetMetadata dsMd = metadata.getDatasetMetadata( new QName( layer.getName() ) );
            if ( dsMd != null ) {
                mdUrl = dsMd.getUrl();
            }
        }

        if ( mdUrl == null && controller.getMetadataURLTemplate() != null ) {
            String id = layer.getDataMetadataSetId();
            if ( id == null ) {
                return null;
            }
            String mdurlTemplate = controller.getMetadataURLTemplate();
            if ( mdurlTemplate.isEmpty() ) {
                mdurlTemplate = getUrl;
                if ( !( mdurlTemplate.endsWith( "?" ) || mdurlTemplate.endsWith( "&" ) ) ) {
                    mdurlTemplate += "?";
                }
                mdurlTemplate += "service=CSW&request=GetRecordById&version=2.0.2&outputSchema=http://www.isotc211.org/2005/gmd&elementSetName=full&id=${metadataSetId}";
            }

            mdUrl = StringUtils.replaceAll( mdurlTemplate, "${metadataSetId}", id );
        }
        return mdUrl;
    }

    private void writeStyles( XMLStreamWriter writer, Layer layer )
                            throws XMLStreamException {
        Style def = service.getStyles().get( layer.getName(), null );
        if ( def != null ) {
            if ( def.getName() != null && !def.getName().isEmpty() ) {
                capWriter.writeStyle( writer, "default", def.getName(), service.getLegendSize( def ), layer.getName(),
                                      def ); // TODO
                // title/description/whatever
            } else {
                capWriter.writeStyle( writer, "default", "default", service.getLegendSize( def ), layer.getName(), def ); // TODO
                // title/description/whatever
            }
        }
        HashSet<Style> visited = new HashSet<Style>();
        for ( Style s : service.getStyles().getAll( layer.getName() ) ) {
            if ( visited.contains( s ) ) {
                continue;
            }
            visited.add( s );
            String name = s.getName();
            if ( name != null && !name.isEmpty() ) {
                capWriter.writeStyle( writer, name, name, service.getLegendSize( s ), layer.getName(), s ); // TODO
                // title/description/whatever
            }
        }
    }

    private void writeScaleHints( XMLStreamWriter writer, Layer layer )
                            throws XMLStreamException {
        DoublePair hint = layer.getScaleHint();
        if ( hint.first != NEGATIVE_INFINITY || hint.second != POSITIVE_INFINITY ) {
FileLine
org/deegree/services/wms/controller/capabilities/WmsCapabilities111MetadataWriter.java178
org/deegree/services/wms/controller/capabilities/WmsCapabilities130MetadataWriter.java175
        writer.writeNamespace( XLINK_PREFIX, XLNNS );
        writer.writeAttribute( XLNNS, "type", "simple" );
        writer.writeAttribute( XLNNS, "href", getServiceUrl() );
        writer.writeEndElement();

        writeServiceProvider( writer );

        writer.writeEndElement();
    }

    private String getServiceUrl() {
        String url = getUrl;
        if ( provider != null && provider.getServiceContact() != null
             && provider.getServiceContact().getContactInfo() != null
             && provider.getServiceContact().getContactInfo().getOnlineResource() != null ) {
            url = provider.getServiceContact().getContactInfo().getOnlineResource().toExternalForm();
        }
        return url;
    }

    private void writeKeywords( XMLStreamWriter writer )
                            throws XMLStreamException {
        List<Pair<List<LanguageString>, CodeType>> keywords = identification == null ? null
                                                                                    : identification.getKeywords();
        if ( keywords != null && !keywords.isEmpty() ) {
            writer.writeStartElement( "KeywordList" );
FileLine
org/deegree/services/wms/controller/capabilities/Capabilities111XMLAdapter.java164
org/deegree/services/wms/controller/capabilities/Capabilities130XMLAdapter.java195
            writeElement( writer, "Title", "Root" );

            // TODO think about a push approach instead of a pull approach
            LayerMetadata lmd = null;
            for ( Theme t : themes ) {
                for ( org.deegree.layer.Layer l : Themes.getAllLayers( t ) ) {
                    if ( lmd == null ) {
                        lmd = l.getMetadata();
                    } else {
                        lmd.merge( l.getMetadata() );
                    }
                }
            }
            if ( lmd != null ) {
                SpatialMetadata smd = lmd.getSpatialMetadata();
                writeSrsAndEnvelope( writer, smd.getCoordinateSystems(), smd.getEnvelope() );
            }

            for ( Theme t : themes ) {
                themeWriter.writeTheme( writer, t );
            }
            writer.writeEndElement();
        }
    }

    static void writeDimensions( XMLStreamWriter writer, Map<String, Dimension<?>> dims )
                            throws XMLStreamException {
        for ( Entry<String, Dimension<?>> entry : dims.entrySet() ) {
FileLine
org/deegree/services/wms/controller/capabilities/WmsCapabilities111ThemeWriter.java198
org/deegree/services/wms/controller/capabilities/WmsCapabilities130ThemeWriter.java249
    private void writeStyles( XMLStreamWriter writer, LayerMetadata md )
                            throws XMLStreamException {
        Map<String, Style> legends = md.getLegendStyles();
        for ( Entry<String, Style> e : md.getStyles().entrySet() ) {
            if ( e.getKey() == null || e.getKey().isEmpty() ) {
                continue;
            }
            Style ls = e.getValue();
            if ( legends.get( e.getKey() ) != null ) {
                ls = legends.get( e.getKey() );
            }
            Pair<Integer, Integer> p = new Legends().getLegendSize( ls );
            capWriter.writeStyle( writer, e.getKey(), e.getKey(), p, md.getName(), e.getValue() );
        }
    }

    private void writeScaleDenominators( XMLStreamWriter writer, LayerMetadata md, Theme theme )
FileLine
org/deegree/services/wms/model/layers/StatisticsLayer.java161
org/deegree/services/wms/model/layers/StatisticsLayer.java221
        GenericFeatureCollection col = new GenericFeatureCollection();
        for ( ComparablePair<Long, String> req : FrontControllerStats.getKVPRequests() ) {
            if ( req.second.toUpperCase().indexOf( "REQUEST=GETMAP" ) != -1 ) {
                String srs = null;
                try {
                    Map<String, String> map = KVPUtils.getNormalizedKVPMap( req.second, "UTF-8" );
                    if ( map.get( "LAYERS" ).equals( "statistics" ) ) {
                        continue;
                    }
                    double[] vals = splitAsDoubles( map.get( "BBOX" ), "," );
                    srs = map.get( "SRS" );
                    Envelope box = fac.createEnvelope( vals[0], vals[1], vals[2], vals[3], CRSManager.lookup( srs ) );
                    if ( !box.intersects( fi.getClickBox() ) ) {
FileLine
org/deegree/services/wms/model/layers/StatisticsLayer.java173
org/deegree/services/wms/model/layers/StatisticsLayer.java234
                    if ( !box.intersects( fi.getClickBox() ) ) {
                        continue;
                    }
                    List<Property> props = new ArrayList<Property>();
                    props.add( new SimpleProperty( queryProp, req.second ) );
                    props.add( new SimpleProperty( timeProp, formatDateTime( new Date( req.first ) ) ) );
                    props.add( new GenericProperty( boxProp, box ) );

                    GenericFeature f = new GenericFeature( featureType, null, props, null );
                    try {
                        if ( filter.first != null && !filter.first.evaluate( f, evaluator ) ) {
                            continue;
                        }
                    } catch ( FilterEvaluationException e ) {
                        LOG.debug( "Filter could not be evaluated: '{}'", e.getLocalizedMessage() );
                        LOG.trace( "Stack trace:", e );
                    }
FileLine
org/deegree/services/wms/controller/ops/GetFeatureInfo.java343
org/deegree/services/wms/controller/ops/GetMap.java673
        String box = map.get( "BBOX" );
        if ( box == null || box.trim().isEmpty() ) {
            throw new OWSException( get( "WMS.PARAM_MISSING", "BBOX" ), OWSException.MISSING_PARAMETER_VALUE );
        }

        double[] vals = splitAsDoubles( box, "," );
        if ( vals.length != 4 ) {
            throw new OWSException( get( "WMS.BBOX_WRONG_FORMAT", box ), OWSException.INVALID_PARAMETER_VALUE );
        }

        if ( vals[2] <= vals[0] ) {
            throw new OWSException( get( "WMS.MAXX_MINX" ), OWSException.INVALID_PARAMETER_VALUE );
        }
        if ( vals[3] <= vals[1] ) {
            throw new OWSException( get( "WMS.MAXY_MINY" ), OWSException.INVALID_PARAMETER_VALUE );
        }
FileLine
org/deegree/services/wms/controller/ops/GetFeatureInfo.java265
org/deegree/services/wms/controller/ops/GetMap.java388
        String w = map.get( "WIDTH" );
        if ( w == null ) {
            throw new OWSException( get( "WMS.PARAM_MISSING", "WIDTH" ), OWSException.MISSING_PARAMETER_VALUE );
        }
        try {
            width = parseInt( w );
        } catch ( NumberFormatException e ) {
            throw new OWSException( get( "WMS.NOT_A_NUMBER", "WIDTH", w ), OWSException.INVALID_PARAMETER_VALUE );
        }

        String h = map.get( "HEIGHT" );
        if ( h == null ) {
            throw new OWSException( get( "WMS.PARAM_MISSING", "HEIGHT" ), OWSException.MISSING_PARAMETER_VALUE );
        }
        try {
            height = parseInt( h );
        } catch ( NumberFormatException e ) {
            throw new OWSException( get( "WMS.NOT_A_NUMBER", "HEIGHT", h ), OWSException.INVALID_PARAMETER_VALUE );
        }
FileLine
org/deegree/services/wms/controller/capabilities/WmsCapabilities111ThemeWriter.java214
org/deegree/services/wms/controller/capabilities/WmsCapabilities130ThemeWriter.java265
    private void writeScaleDenominators( XMLStreamWriter writer, LayerMetadata md, Theme theme )
                            throws XMLStreamException {
        DoublePair hint = md.getScaleDenominators();
        // use layers' settings only if not set for theme
        if ( hint.first.isInfinite() && hint.second.isInfinite() ) {
            hint = new DoublePair( hint.second, hint.first );
            for ( org.deegree.layer.Layer l : theme.getLayers() ) {
                hint.first = Math.min( l.getMetadata().getScaleDenominators().first, hint.first );
                hint.second = Math.max( l.getMetadata().getScaleDenominators().second, hint.second );
            }
        }
        if ( !hint.first.isInfinite() || !hint.second.isInfinite() ) {
FileLine
org/deegree/services/wms/controller/capabilities/WmsCapabilities111ThemeWriter.java147
org/deegree/services/wms/controller/capabilities/WmsCapabilities130ThemeWriter.java154
    private void writeKeywords( XMLStreamWriter writer, LayerMetadata md, LayerMetadata lmd )
                            throws XMLStreamException {
        List<Pair<List<LanguageString>, CodeType>> kws = md.getDescription().getKeywords();
        if ( lmd != null && ( kws == null || kws.isEmpty() || kws.get( 0 ).first.isEmpty() ) ) {
            kws = lmd.getDescription().getKeywords();
        }
        if ( kws != null && !kws.isEmpty() && !kws.get( 0 ).first.isEmpty() ) {
            writer.writeStartElement( "KeywordList" );
FileLine
org/deegree/services/jaxb/wms/DirectStyleType.java163
org/deegree/services/jaxb/wms/SLDStyleType.java158
    }


    /**
     * <p>Java class for anonymous complex type.
     * 
     * <p>The following schema fragment specifies the expected content contained within this class.
     * 
     * <pre>
     * &lt;complexType>
     *   &lt;simpleContent>
     *     &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">
     *       &lt;attribute name="outputGetLegendGraphicUrl" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" />
     *     &lt;/extension>
     *   &lt;/simpleContent>
     * &lt;/complexType>
     * </pre>
     * 
     * 
     */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "value"
    })
    public static class LegendGraphicFile {

        @XmlValue
        protected String value;
        @XmlAttribute(name = "outputGetLegendGraphicUrl")
        protected Boolean outputGetLegendGraphicUrl;

        /**
         * Gets the value of the value property.
         * 
         * @return
         *     possible object is
         *     {@link String }
         *     
         */
        public String getValue() {
            return value;
        }

        /**
         * Sets the value of the value property.
         * 
         * @param value
         *     allowed object is
         *     {@link String }
         *     
         */
        public void setValue(String value) {
            this.value = value;
        }

        /**
         * Gets the value of the outputGetLegendGraphicUrl property.
         * 
         * @return
         *     possible object is
         *     {@link Boolean }
         *     
         */
        public boolean isOutputGetLegendGraphicUrl() {
            if (outputGetLegendGraphicUrl == null) {
                return true;
            } else {
                return outputGetLegendGraphicUrl;
            }
        }

        /**
         * Sets the value of the outputGetLegendGraphicUrl property.
         * 
         * @param value
         *     allowed object is
         *     {@link Boolean }
         *     
         */
        public void setOutputGetLegendGraphicUrl(Boolean value) {
            this.outputGetLegendGraphicUrl = value;
        }

    }

}