Package net.opengis.wfs

Examples of net.opengis.wfs.TransactionResponseType


                    ioException);
            }
        }

        // result
        TransactionResponseType result = WfsFactory.eINSTANCE.createTransactionResponseType();
        result.setTransactionResults(WfsFactory.eINSTANCE.createTransactionResultsType());
        result.getTransactionResults().setHandle(request.getHandle());
        result.setTransactionSummary(WfsFactory.eINSTANCE.createTransactionSummaryType());
        result.getTransactionSummary().setTotalInserted(BigInteger.valueOf(0));
        result.getTransactionSummary().setTotalUpdated(BigInteger.valueOf(0));
        result.getTransactionSummary().setTotalDeleted(BigInteger.valueOf(0));

        result.setInsertResults(WfsFactory.eINSTANCE.createInsertResultsType());

        // execute elements in order, recording results as we go
        // I will need to record the damaged area for pre commit validation
        // checks
        // Envelope envelope = new Envelope();
        boolean exception = false;

        try {
            for (Iterator it = elementHandlers.entrySet().iterator(); it.hasNext();) {
                Map.Entry entry = (Map.Entry) it.next();
                EObject element = (EObject) entry.getKey();
                TransactionElementHandler handler = (TransactionElementHandler) entry.getValue();

                handler.execute(element, request, stores, result, multiplexer);
            }
        } catch (WFSTransactionException e) {
            exception = true;
            LOGGER.log(Level.SEVERE, "Transaction failed", e);

            // transaction failed, rollback
            ActionType action = WfsFactory.eINSTANCE.createActionType();

            if (e.getCode() != null) {
                action.setCode(e.getCode());
            } else {
                action.setCode("InvalidParameterValue");
            }

            action.setLocator(e.getLocator());
            action.setMessage(e.getMessage());
            result.getTransactionResults().getAction().add(action);
        }

        // commit
        boolean committed = false;

        try {
            if (exception) {
                transaction.rollback();
            } else {
                // inform plugins we're about to commit
                for (Iterator it = transactionPlugins.iterator(); it.hasNext();) {
                    TransactionPlugin tp = (TransactionPlugin) it.next();
                    tp.beforeCommit(request);
                }

                transaction.commit();
                committed = true;

                //                 
                // Lets deal with the locks
                //
                // Q: Why talk to Data you ask
                // A: Only class that knows all the DataStores
                //
                // We really need to ask all DataStores to release/refresh
                // because we may have locked Features with this Authorizations
                // on them, even though we did not refer to them in this
                // transaction.
                //
                // Q: Why here, why now?
                // A: The opperation was a success, and we have completed the
                // opperation
                //
                // We also need to do this if the opperation is not a success,
                // you can find this same code in the abort method
                //
                if (request.getLockId() != null) {
                    if (request.getReleaseAction() == AllSomeType.ALL_LITERAL) {
                        lockRelease(request.getLockId());
                    } else if (request.getReleaseAction() == AllSomeType.SOME_LITERAL) {
                        lockRefresh(request.getLockId());
                    }
                }
            }
        } finally {
            transaction.close();
            transaction = null;
        }

        // inform plugins we're done
        for (Iterator it = transactionPlugins.iterator(); it.hasNext();) {
            TransactionPlugin tp = (TransactionPlugin) it.next();
            tp.afterTransaction(request, committed);
        }

        //       
        // if ( result.getTransactionResult().getStatus().getPARTIAL() != null )
        // {
        // throw new WFSException("Canceling PARTIAL response");
        // }
        //       
        // try {
        // if ( result.getTransactionResult().getStatus().getFAILED() != null )
        // {
        // //transaction failed, roll it back
        // transaction.rollback();
        // }
        // else {
        // transaction.commit();
        // result.getTransactionResult().getStatus().setSUCCESS(
        // WfsFactory.eINSTANCE.createEmptyType() );
        // }
        //         
        // }
        // finally {
        // transaction.close();
        // transaction = null;
        // }

        // JD: this is an issue with the spec, InsertResults must be present,
        // even if no insert
        // occured, howwever insert results needs to have at least one
        // "FeatureId" eliement, sp
        // we create an FeatureId with an empty fid
        if (result.getInsertResults().getFeature().isEmpty()) {
            InsertedFeatureType insertedFeature = WfsFactory.eINSTANCE.createInsertedFeatureType();
            insertedFeature.getFeatureId().add(filterFactory.featureId("none"));

            result.getInsertResults().getFeature().add(insertedFeature);
        }

        return result;

        // we will commit in the writeTo method
View Full Code Here


        return "text/xml";
    }

    public void write(Object value, OutputStream output, Operation operation)
        throws IOException, ServiceException {
        TransactionResponseType response = (TransactionResponseType) value;

        if (new Version("1.0.0").equals(operation.getService().getVersion())) {
            v_1_0(response, output, operation);
        } else {
            v_1_1(response, output, operation);
View Full Code Here

        Object parsed = parser.parse(getClass().getResourceAsStream("transactionResponse.xml"));

        assertNotNull(parsed);
        assertTrue(parsed.getClass().getName(), parsed instanceof TransactionResponseType);
       
        TransactionResponseType response = (TransactionResponseType) parsed;
       
        InsertResultsType insert = response.getInsertResults();
       
        assertEquals(0, insert.getFeature().size());
       
        parsed = parser.parse(getClass().getResourceAsStream("transactionResponse2.xml"));

        assertNotNull(parsed);
        assertTrue(parsed.getClass().getName(), parsed instanceof TransactionResponseType);
       
        response = (TransactionResponseType) parsed;
       
        insert = response.getInsertResults();
       
        assertEquals(2, insert.getFeature().size());
        assertEquals("fid1", ((InsertedFeatureType) insert.getFeature().get(0)).getFeatureId().get(0).toString());
        assertEquals("fid2", ((InsertedFeatureType) insert.getFeature().get(1)).getFeatureId().get(0).toString());
    }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    @Override
    public void testEncode() throws Exception {
        final TransactionResponseType tr = factory.createTransactionResponseType();
        {
            tr.setVersion("1.1.0");

            TransactionSummaryType summary = factory.createTransactionSummaryType();
            summary.setTotalDeleted(BigInteger.valueOf(2));
            summary.setTotalInserted(BigInteger.valueOf(3));
            summary.setTotalUpdated(BigInteger.valueOf(4));
            tr.setTransactionSummary(summary);

            TransactionResultsType results = factory.createTransactionResultsType();
            ActionType action = factory.createActionType();
            action.setCode("actionCode");
            action.setLocator("actionLocator");
            action.setMessage("actionMessage");
            results.getAction().add(action);
            tr.setTransactionResults(results);

            InsertResultsType insertResults = factory.createInsertResultsType();
            InsertedFeatureType feature = factory.createInsertedFeatureType();
            feature.setHandle("handle1");
            feature.getFeatureId().add(filterFac.featureId("fid1"));
            feature.getFeatureId().add(filterFac.featureId("fid2"));
            insertResults.getFeature().add(feature);
            tr.setInsertResults(insertResults);
        }

        final Document dom = encode(tr, WFS.TransactionResponse);
        final Element root = dom.getDocumentElement();
View Full Code Here

        buildDocument(resource);

        Object parsed = parse(WFS.LockFeatureType);
        assertTrue(parsed instanceof TransactionResponseType);

        final TransactionResponseType tr = (TransactionResponseType) parsed;
        assertEquals("1.1.0", tr.getVersion());
        {
            TransactionSummaryType summary = tr.getTransactionSummary();

            assertNotNull(summary);

            assertNotNull(summary.getTotalInserted());
            assertNotNull(summary.getTotalDeleted());
            assertNotNull(summary.getTotalUpdated());

            assertEquals(3, summary.getTotalInserted().intValue());
            assertEquals(2, summary.getTotalUpdated().intValue());
            assertEquals(1, summary.getTotalDeleted().intValue());
        }

        {
            TransactionResultsType results = tr.getTransactionResults();
            assertEquals(2, results.getAction().size());
            {
                ActionType action1 = (ActionType) results.getAction().get(0);
                assertEquals("locator.1", action1.getLocator());
                assertNull(action1.getCode());
                assertEquals("success", action1.getMessage());
            }
            {
                ActionType action2 = (ActionType) results.getAction().get(1);
                assertEquals("locator.2", action2.getLocator());
                assertEquals("errorCode", action2.getCode());
                assertEquals("failure", action2.getMessage());
            }
        }
        {
            InsertResultsType insertResults = tr.getInsertResults();
            assertEquals(2, insertResults.getFeature().size());
            InsertedFeatureType feature1 = (InsertedFeatureType) insertResults.getFeature().get(0);
            assertEquals("handle1", feature1.getHandle());
            assertEquals(2, feature1.getFeatureId().size());
View Full Code Here

        } finally {
            response.dispose();
        }

        if (parsed instanceof TransactionResponseType) {
            TransactionResponseType tr = (TransactionResponseType) parsed;
            InsertResultsType insertResults = tr.getInsertResults();
            if (insertResults != null) {
                @SuppressWarnings("unchecked")
                List<InsertedFeatureType> inserted = insertResults.getFeature();
                for (InsertedFeatureType i : inserted) {
                    @SuppressWarnings("unchecked")
                    List<FeatureId> featureIds = i.getFeatureId();
                    if (null != featureIds) {
                        this.inserted.addAll(featureIds);
                    }
                }
            }
            TransactionSummaryType ts = tr.getTransactionSummary();
            if (ts != null) {
                BigInteger totalInserted = ts.getTotalInserted();
                BigInteger totalDeleted = ts.getTotalDeleted();
                BigInteger totalUpdated = ts.getTotalUpdated();
                this.updatedCount = totalUpdated == null ? -1 : totalUpdated.intValue();
View Full Code Here

    @SuppressWarnings("unchecked")
    private String createTransactionResponseXml(List<String> added, int updated, int deleted)
            throws IOException {
        WfsFactory factory = WfsFactory.eINSTANCE;

        TransactionResponseType tr = factory.createTransactionResponseType();
        tr.setVersion(getStrategy().getVersion());

        tr.setTransactionSummary(factory.createTransactionSummaryType());
        tr.getTransactionSummary().setTotalInserted(BigInteger.valueOf(added.size()));
        tr.getTransactionSummary().setTotalUpdated(BigInteger.valueOf(updated));
        tr.getTransactionSummary().setTotalDeleted(BigInteger.valueOf(deleted));
        tr.setTransactionResults(factory.createTransactionResultsType());
        tr.setInsertResults(factory.createInsertResultsType());

        if (!added.isEmpty()) {
            FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
            InsertedFeatureType inserted = factory.createInsertedFeatureType();
            tr.getInsertResults().getFeature().add(inserted);
            for (String addedId : added) {
                FeatureId featureId = ff.featureId(addedId);
                inserted.getFeatureId().add(featureId);
            }
        }
View Full Code Here

        Object parsed = parser.parse(getClass().getResourceAsStream("transactionResponse.xml"));

        assertNotNull(parsed);
        assertTrue(parsed.getClass().getName(), parsed instanceof TransactionResponseType);
       
        TransactionResponseType response = (TransactionResponseType) parsed;
       
        InsertResultsType insert = response.getInsertResults();
       
        assertEquals(0, insert.getFeature().size());
       
        parsed = parser.parse(getClass().getResourceAsStream("transactionResponse2.xml"));

        assertNotNull(parsed);
        assertTrue(parsed.getClass().getName(), parsed instanceof TransactionResponseType);
       
        response = (TransactionResponseType) parsed;
       
        insert = response.getInsertResults();
       
        assertEquals(2, insert.getFeature().size());
        assertEquals("fid1", ((InsertedFeatureType) insert.getFeature().get(0)).getFeatureId().get(0).toString());
        assertEquals("fid2", ((InsertedFeatureType) insert.getFeature().get(1)).getFeatureId().get(0).toString());
    }
View Full Code Here

        return "text/xml";
    }

    public void write(Object value, OutputStream output, Operation operation)
        throws IOException, ServiceException {
        TransactionResponseType response = (TransactionResponseType) value;

        if (new Version("1.0.0").equals(operation.getService().getVersion())) {
            v_1_0(response, output, operation);
        } else {
            v_1_1(response, output, operation);
View Full Code Here

        return "text/xml";
    }

    public void write(Object value, OutputStream output, Operation operation)
        throws IOException, ServiceException {
        TransactionResponseType response = (TransactionResponseType) value;

        if (new Version("1.0.0").equals(operation.getService().getVersion())) {
            v_1_0(response, output, operation);
        } else {
            v_1_1(response, output, operation);
View Full Code Here

TOP

Related Classes of net.opengis.wfs.TransactionResponseType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.