Fix keyring on active environments and a few bugs
authorBruno Sinou <bsinou@argeo.org>
Sat, 16 Nov 2013 12:40:52 +0000 (12:40 +0000)
committerBruno Sinou <bsinou@argeo.org>
Sat, 16 Nov 2013 12:40:52 +0000 (12:40 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6620 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

plugins/org.argeo.slc.akb.ui/src/main/java/org/argeo/slc/akb/ui/views/AkbTemplatesTreeView.java
plugins/org.argeo.slc.akb.ui/src/main/java/org/argeo/slc/akb/ui/wizards/ActiveConnectorWizard.java
runtime/org.argeo.slc.akb/src/main/java/org/argeo/slc/akb/core/AkbServiceImpl.java

index 7028663b54e9aa0ae95585442372df4da5f0491a..2686a486de780adb3f154431be3c69fc68230ed6 100644 (file)
@@ -320,7 +320,7 @@ public class AkbTemplatesTreeView extends ViewPart implements Refreshable {
                if (currItem != null)\r
                        subMenu.remove(currItem);\r
                subMenu.add(AkbUiUtils.createContributionItem(menuManager, locator,\r
-                               currItemId, OpenAkbNodeEditor.ID, "JDBC", null, tmpParams));\r
+                               currItemId, OpenAkbNodeEditor.ID, "JDBC Query", null, tmpParams));\r
 \r
                // SSH COMMAND\r
                tmpParams = new HashMap<String, String>();\r
index 5d907278e261acf663183253467b366f6ed7cad4..0867a68029e6e77dc41be439891d9c6d28e2a90e 100644 (file)
@@ -51,23 +51,24 @@ public class ActiveConnectorWizard extends Wizard {
 
        @Override
        public boolean performFinish() {
-               return doUpdate();
-       }
-
-       private boolean doUpdate() {
                if (!canFinish())
                        return false;
+               doUpdate();
+               return true;
+       }
+
+       private void doUpdate() {
                try {
-                       boolean changed = true;
-                       changed &= AkbUiUtils.setJcrProperty(activeConnector,
+                       boolean changed = false;
+                       changed |= AkbUiUtils.setJcrProperty(activeConnector,
                                        AkbNames.AKB_CONNECTOR_URL, PropertyType.STRING,
                                        editConnectorPage.getUrl());
-                       changed &= AkbUiUtils.setJcrProperty(activeConnector,
+                       changed |= AkbUiUtils.setJcrProperty(activeConnector,
                                        AkbNames.AKB_CONNECTOR_USER, PropertyType.STRING,
                                        editConnectorPage.getUser());
                        if (changed)
                                activeConnector.getSession().save();
-                       return changed;
+                       // return changed;
                } catch (RepositoryException re) {
                        throw new AkbException("Unable to update active connector", re);
                }
@@ -98,9 +99,9 @@ public class ActiveConnectorWizard extends Wizard {
        public boolean canFinish() {
                if (AkbJcrUtils.isEmptyString(editConnectorPage.getUrl())
                                || AkbJcrUtils.isEmptyString(editConnectorPage.getUser()))
-                       return true;
-               else
                        return false;
+               else
+                       return true;
        }
 
        // //////////////////////
index df24ef108fc427f3a24cf7f6c95ea029956d3ee7..0f45c5b6c4968001112b70a93dd58fc13f3a75de 100644 (file)
@@ -141,7 +141,7 @@ public class AkbServiceImpl implements AkbService, AkbNames {
                        if (currNode.isNodeType(AkbTypes.AKB_CONNECTOR_ALIAS)) {
                                String connType = currNode.getProperty(AKB_CONNECTOR_TYPE)
                                                .getString();
-                               
+
                                if (AkbJcrUtils.isEmptyString(connType))
                                        // Cannot create an instance if the type is undefined
                                        continue activeConns;
@@ -343,8 +343,15 @@ public class AkbServiceImpl implements AkbService, AkbNames {
                                Node connectorNode = getActiveConnectorByAlias(activeEnv,
                                                connectorAliasStr);
 
-                               String sqlQuery = node.getProperty(AKB_QUERY_TEXT).getString();
+                               // Sanity check
+                               if (connectorNode == null)
+                                       // should never happen
+                                       return null;
+                               // FIXME hack to force saving of password in keyring on never
+                               // used connector instance for active env
+                               testConnector(connectorNode);
 
+                               String sqlQuery = AkbJcrUtils.get(node, AKB_QUERY_TEXT);
                                String connectorUrl = AkbJcrUtils.get(connectorNode,
                                                AKB_CONNECTOR_URL);
                                String connectorUser = AkbJcrUtils.get(connectorNode,
@@ -352,7 +359,8 @@ public class AkbServiceImpl implements AkbService, AkbNames {
 
                                // Sanity check
                                if (AkbJcrUtils.isEmptyString(connectorUrl)
-                                               || AkbJcrUtils.isEmptyString(connectorUser))
+                                               || AkbJcrUtils.isEmptyString(connectorUser)
+                                               || AkbJcrUtils.isEmptyString(sqlQuery))
                                        return null;
 
                                String pwdPath = getPasswordPath(connectorNode);
@@ -381,18 +389,24 @@ public class AkbServiceImpl implements AkbService, AkbNames {
 
        public String executeCommand(Node activeEnv, Node node) {
                try {
-
                        String connectorAliasStr = node.getProperty(AKB_USED_CONNECTOR)
                                        .getString();
                        // in case of a template passed env can be null
                        if (activeEnv == null) {
                                activeEnv = AkbJcrUtils.getCurrentTemplate(node);
                        }
+
                        Node connectorNode = getActiveConnectorByAlias(activeEnv,
                                        connectorAliasStr);
-                       String command = node.getProperty(AkbNames.AKB_COMMAND_TEXT)
-                                       .getString();
+                       // Sanity check
+                       if (connectorNode == null)
+                               // should never happen
+                               return null;
+                       // FIXME hack to force saving of password in keyring on never used
+                       // connector instance for active env
+                       testConnector(connectorNode);
 
+                       String command = AkbJcrUtils.get(node, AKB_COMMAND_TEXT);
                        String connectorUrl = AkbJcrUtils.get(connectorNode,
                                        AKB_CONNECTOR_URL);
                        String connectorUser = AkbJcrUtils.get(connectorNode,
@@ -400,7 +414,8 @@ public class AkbServiceImpl implements AkbService, AkbNames {
 
                        // Sanity check
                        if (AkbJcrUtils.isEmptyString(connectorUrl)
-                                       || AkbJcrUtils.isEmptyString(connectorUser))
+                                       || AkbJcrUtils.isEmptyString(connectorUser)
+                                       || AkbJcrUtils.isEmptyString(command))
                                return null;
 
                        String pwdPath = getPasswordPath(connectorNode);
@@ -457,6 +472,14 @@ public class AkbServiceImpl implements AkbService, AkbNames {
                        Node connectorNode = getActiveConnectorByAlias(activeEnv,
                                        connectorAliasStr);
 
+                       // Sanity check
+                       if (connectorNode == null)
+                               // should never happen
+                               return null;
+                       // FIXME hack to force saving of password in keyring on never used
+                       // connector instance for active env
+                       testConnector(connectorNode);
+
                        // TODO do a proper scp
                        String connectorUrl = AkbJcrUtils.get(connectorNode,
                                        AKB_CONNECTOR_URL);