CPD Results

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

Duplications

FileLine
org/deegree/protocol/ows/capabilities/OWSCommon100CapabilitiesAdapter.java107
org/deegree/protocol/ows/capabilities/OWSCommon110CapabilitiesAdapter.java117
        List<Domain> params = new ArrayList<Domain>( paramEls.size() );
        if ( paramEls != null ) {
            for ( OMElement paramEl : paramEls ) {
                Domain parameter = parseDomain( paramEl );
                params.add( parameter );
            }
        }

        xpath = new XPath( "ows:Constraint", nsContext );
        List<OMElement> constaintEls = getElements( opMetadataEl, xpath );
        List<Domain> constraints = new ArrayList<Domain>( constaintEls.size() );
        if ( constaintEls != null ) {
            for ( OMElement constaintEl : constaintEls ) {
                Domain constraint = parseDomain( constaintEl );
                constraints.add( constraint );
            }
        }

        List<OMElement> extendedCaps = new ArrayList<OMElement>();
        xpath = new XPath( "ows:ExtendedCapabilities", nsContext );
        OMElement extededCapab = getElement( opMetadataEl, xpath );
        if ( extededCapab != null ) {
            extendedCaps.add( extededCapab );
        }

        return new OperationsMetadata( operations, params, constraints, extendedCaps );
    }

    /**
     * @param opEl
     *            context {@link OMElement}
     * @return an {@link Operation} instance, never <code>null</code>
     */
    private Operation parseOperation( OMElement opEl ) {

        XPath xpath = new XPath( "@name", nsContext );
        String name = getNodeAsString( opEl, xpath, null );

        xpath = new XPath( "ows:DCP", nsContext );
        List<OMElement> dcpEls = getElements( opEl, xpath );
        List<DCP> dcps = new ArrayList<DCP>( dcpEls.size() );
        if ( dcpEls != null ) {
            for ( OMElement dcpEl : dcpEls ) {
                DCP dcp = parseDCP( dcpEl );
                dcps.add( dcp );
            }
        }

        xpath = new XPath( "ows:Parameter", nsContext );
        List<OMElement> paramEls = getElements( opEl, xpath );
        List<Domain> params = new ArrayList<Domain>( paramEls.size() );
        if ( paramEls != null ) {
            for ( OMElement paramEl : paramEls ) {
                Domain parameter = parseDomain( paramEl );
                params.add( parameter );
            }
        }

        xpath = new XPath( "ows:Constraint", nsContext );
        List<OMElement> constaintEls = getElements( opEl, xpath );
        List<Domain> constraints = new ArrayList<Domain>( constaintEls.size() );
        if ( constaintEls != null ) {
            for ( OMElement constaintEl : constaintEls ) {
                Domain constraint = parseDomain( constaintEl );
                constraints.add( constraint );
            }
        }
FileLine
org/deegree/protocol/wps/client/process/ProcessExecution.java316
org/deegree/protocol/wps/client/process/RawProcessExecution.java130
        responseFormat = new ResponseFormat( false, async, false, async, outputDefs );

        // TODO what if server only supports Get?
        URL url = client.getExecuteURL( true );

        URLConnection conn = url.openConnection();
        conn.setDoOutput( true );
        conn.setUseCaches( false );
        // TODO does this need configurability?
        conn.setRequestProperty( "Content-Type", "application/xml" );

        XMLOutputFactory outFactory = XMLOutputFactory.newInstance();

        OutputStream os = conn.getOutputStream();
        XMLInputFactory inFactory = XMLInputFactory.newInstance();

        if ( LOG.isDebugEnabled() ) {
            File logFile = File.createTempFile( "wpsclient", "request.xml" );
            XMLStreamWriter logWriter = outFactory.createXMLStreamWriter( new FileOutputStream( logFile ), "UTF-8" );
            ExecuteRequest100Writer executer = new ExecuteRequest100Writer( logWriter );
            executer.write100( process.getId(), inputs, responseFormat );
            logWriter.close();
            LOG.debug( "WPS request can be found at " + logFile );

            InputStream is = new FileInputStream( logFile );
            byte[] buffer = new byte[1024];
            int read = 0;
            while ( ( read = is.read( buffer ) ) != -1 ) {
                os.write( buffer, 0, read );
            }
            is.close();
            os.close();
        } else {
            XMLStreamWriter writer = outFactory.createXMLStreamWriter( os, "UTF-8" );
            ExecuteRequest100Writer executer = new ExecuteRequest100Writer( writer );
            executer.write100( process.getId(), inputs, responseFormat );
            writer.close();
        }

        InputStream responseStream = conn.getInputStream();

        if ( LOG.isDebugEnabled() ) {
            File logFile = File.createTempFile( "wpsclient", "response" );
            OutputStream logStream = new FileOutputStream( logFile );

            byte[] buffer = new byte[1024];
            int read = 0;
            while ( ( read = responseStream.read( buffer ) ) != -1 ) {
                logStream.write( buffer, 0, read );
            }
            logStream.close();

            responseStream = new FileInputStream( logFile );
            LOG.debug( "WPS response can be found at " + logFile );
        }
FileLine
org/deegree/protocol/ows/OWSCommonXMLAdapter.java135
org/deegree/protocol/ows/capabilities/OWSCommon100CapabilitiesAdapter.java223
        return geomFac.createEnvelope( lowerCorner, upperCorner, crs );
    }

    private double[] parseDoubleList( OMElement positionElement )
                            throws XMLParsingException {
        String s = positionElement.getText();
        // don't use String.split(regex) here (speed)
        StringTokenizer st = new StringTokenizer( s );
        List<String> tokens = new ArrayList<String>();
        while ( st.hasMoreTokens() ) {
            tokens.add( st.nextToken() );
        }
        double[] doubles = new double[tokens.size()];
        for ( int i = 0; i < doubles.length; i++ ) {
            try {
                doubles[i] = Double.parseDouble( tokens.get( i ) );
            } catch ( NumberFormatException e ) {
                String msg = "Value '" + tokens.get( i ) + "' cannot be parsed as a double.";
                throw new XMLParsingException( this, positionElement, msg );
            }
        }
        return doubles;
    }
FileLine
org/deegree/protocol/ows/capabilities/OWSCommon100CapabilitiesAdapter.java84
org/deegree/protocol/ows/capabilities/OWSCommon110CapabilitiesAdapter.java94
        super( OWS_NS );
    }

    @Override
    public OperationsMetadata parseOperationsMetadata() {

        OMElement opMetadataEl = getElement( getRootElement(), new XPath( "ows:OperationsMetadata", nsContext ) );
        if ( opMetadataEl == null ) {
            return null;
        }

        XPath xpath = new XPath( "ows:Operation", nsContext );
        List<OMElement> opEls = getElements( opMetadataEl, xpath );
        List<Operation> operations = new ArrayList<Operation>( opEls.size() );
        if ( opEls != null ) {
            for ( OMElement opEl : opEls ) {
                Operation op = parseOperation( opEl );
                operations.add( op );
            }
        }

        xpath = new XPath( "ows:Parameter", nsContext );
        List<OMElement> paramEls = getElements( opMetadataEl, xpath );
        List<Domain> params = new ArrayList<Domain>( paramEls.size() );
FileLine
org/deegree/protocol/ows/getcapabilities/GetCapabilitiesXMLParser.java108
org/deegree/protocol/ows/getcapabilities/GetCapabilitiesXMLParser.java147
        List<OMElement> formatElements = getElements( rootElement, new XPath( "ows:AcceptFormats/ows:OutputFormat",
                                                                              nsContext ) );
        List<String> formats = new ArrayList<String>( formatElements.size() );
        for ( OMElement formatElement : formatElements ) {
            formats.add( formatElement.getText() );
        }

        // @language (optional)
        List<String> languages = null;
        String languageString = rootElement.getAttributeValue( new QName( "language" ) );
        if ( languageString != null ) {
            languages = Arrays.asList( languageString.split( "," ) );
        }

        return new GetCapabilities( null, Arrays.asList( versions ), sections, formats, updateSequence, languages );
    }