I have a connection with basicAuthentication, the getCapabilities and getFeatureStore return me correct data but when i try to commit a transaction I get the next exception: "HTTP response code:401 for url ...."
Here's my code:
public boolean anadirIncidencia(String getCapabilities, String capa, SimpleFeature incidencia, String username, String password) throws Exception { boolean b = false; Map connectionParameters = new HashMap();connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL", getCapabilities);connectionParameters.put("WFSDataStoreFactory:USERNAME",username);connectionParameters.put("WFSDataStoreFactoryASSWORD",password); System.out.println("Connexion Parameters: " + connectionParameters); DataStore data = DataStoreFinder.getDataStore(connectionParameters); SimpleFeatureSource source = data.getFeatureSource(capa); List features = new ArrayList(); features.add(incidencia); Transaction transaction = new DefaultTransaction("add"); SimpleFeatureStore featureStore = (SimpleFeatureStore) source; featureStore.setTransaction(transaction); System.out.println("FeatureStore:" + featureStore.getDataStore().getNames()); try { System.out.println("ADD: addFeatures"); List added = featureStore.addFeatures(DataUtilities .collection(features)); System.out.println("added: " + added.toString()); transaction.commit(); b = true; } catch (Exception problem) { problem.printStackTrace(); transaction.rollback(); b = false; error = problem.getLocalizedMessage(); System.out.println("ADD: rollback ----->" + error); } finally { transaction.close(); } return b;}And the error happens in transaction.commit(); and then after commit fails, transaction.rollback() throws the same error.
Someone can help me?
Thanks,
أكثر...
Here's my code:
public boolean anadirIncidencia(String getCapabilities, String capa, SimpleFeature incidencia, String username, String password) throws Exception { boolean b = false; Map connectionParameters = new HashMap();connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL", getCapabilities);connectionParameters.put("WFSDataStoreFactory:USERNAME",username);connectionParameters.put("WFSDataStoreFactoryASSWORD",password); System.out.println("Connexion Parameters: " + connectionParameters); DataStore data = DataStoreFinder.getDataStore(connectionParameters); SimpleFeatureSource source = data.getFeatureSource(capa); List features = new ArrayList(); features.add(incidencia); Transaction transaction = new DefaultTransaction("add"); SimpleFeatureStore featureStore = (SimpleFeatureStore) source; featureStore.setTransaction(transaction); System.out.println("FeatureStore:" + featureStore.getDataStore().getNames()); try { System.out.println("ADD: addFeatures"); List added = featureStore.addFeatures(DataUtilities .collection(features)); System.out.println("added: " + added.toString()); transaction.commit(); b = true; } catch (Exception problem) { problem.printStackTrace(); transaction.rollback(); b = false; error = problem.getLocalizedMessage(); System.out.println("ADD: rollback ----->" + error); } finally { transaction.close(); } return b;}And the error happens in transaction.commit(); and then after commit fails, transaction.rollback() throws the same error.
Someone can help me?
Thanks,
أكثر...