You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2015/02/02 15:25:02 UTC

[3/6] incubator-nifi git commit: NIFI-250: - Updating REST API for managing controller services. - Starting to add a dialog for disabling a controller service.

NIFI-250:
- Updating REST API for managing controller services.
- Starting to add a dialog for disabling a controller service.

Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/d1caa7ee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/d1caa7ee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/d1caa7ee

Branch: refs/heads/NIFI-250
Commit: d1caa7ee3e2e8662eeb2b368b2ed81fface22711
Parents: 2de754a
Author: Matt Gilman <ma...@gmail.com>
Authored: Mon Feb 2 07:52:32 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Mon Feb 2 07:52:32 2015 -0500

----------------------------------------------------------------------
 .../nifi/web/StandardNiFiServiceFacade.java     | 14 ++-
 .../nifi/web/api/ControllerServiceResource.java |  7 +-
 .../dao/impl/StandardControllerServiceDAO.java  |  2 +-
 .../spring/ControllerServiceDAOFactoryBean.java | 71 +++++++++++++++
 .../src/main/resources/nifi-web-api-context.xml |  4 +-
 .../nifi-framework/nifi-web/nifi-web-ui/pom.xml |  1 +
 .../src/main/webapp/WEB-INF/pages/canvas.jsp    |  1 +
 .../disable-controller-service-dialog.jsp       | 27 ++++++
 .../nifi-web-ui/src/main/webapp/css/canvas.css  |  1 +
 .../css/disable-controller-service-dialog.css   | 29 +++++++
 .../src/main/webapp/js/nf/canvas/nf-settings.js | 91 +++++++++++++++-----
 11 files changed, 218 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
index a7fa12f..41cdb58 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
@@ -1289,8 +1289,10 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
         final Revision updatedRevision = updateRevision(revision);
         final ConfigurationSnapshot<ControllerServiceDTO> response = new ConfigurationSnapshot<>(updatedRevision.getVersion(), dtoFactory.createControllerServiceDto(controllerService));
 
-        // save the flow
-        controllerFacade.save();
+        // save the flow on the node
+        if (properties.isNode()) {
+            controllerFacade.save();
+        }
 
         return response;
     }
@@ -1312,7 +1314,9 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
         final ConfigurationSnapshot<ControllerServiceDTO> response = new ConfigurationSnapshot<>(updatedRevision.getVersion(), dtoFactory.createControllerServiceDto(controllerService));
 
         // save the flow
-        controllerFacade.save();
+        if (properties.isNode()) {
+            controllerFacade.save();
+        }
 
         return response;
     }
@@ -1330,7 +1334,9 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
         final ConfigurationSnapshot<Void> response = new ConfigurationSnapshot<>(updatedRevision.getVersion());
 
         // save the flow
-        controllerFacade.save();
+        if (properties.isNode()) {
+            controllerFacade.save();
+        }
 
         return response;
     }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java
index 4f33756..83d9abd 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java
@@ -192,6 +192,9 @@ public class ControllerServiceResource extends ApplicationResource {
         if (controllerServiceEntity.getRevision() == null) {
             throw new IllegalArgumentException("Revision must be specified.");
         }
+        
+        // get the revision
+        final RevisionDTO revision = controllerServiceEntity.getRevision();
 
         if (controllerServiceEntity.getControllerService().getId() != null) {
             throw new IllegalArgumentException("Controller service ID cannot be specified.");
@@ -200,6 +203,9 @@ public class ControllerServiceResource extends ApplicationResource {
         // if cluster manager, convert POST to PUT (to maintain same ID across nodes) and replicate
         if (properties.isClusterManager()) {
 
+            // apply action to the cluster manager first
+            serviceFacade.createControllerService(new Revision(revision.getVersion(), revision.getClientId()), controllerServiceEntity.getControllerService());
+            
             // create ID for resource
             final String id = UUID.randomUUID().toString();
 
@@ -229,7 +235,6 @@ public class ControllerServiceResource extends ApplicationResource {
         }
 
         // create the controller service and generate the json
-        final RevisionDTO revision = controllerServiceEntity.getRevision();
         final ConfigurationSnapshot<ControllerServiceDTO> controllerResponse = serviceFacade.createControllerService(
                 new Revision(revision.getVersion(), revision.getClientId()), controllerServiceEntity.getControllerService());
         final ControllerServiceDTO controllerService = controllerResponse.getConfiguration();

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java
index 394e33d..65311cb 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java
@@ -22,8 +22,8 @@ import java.util.Map;
 import java.util.Set;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.nifi.controller.Availability;
-
 import org.apache.nifi.controller.FlowController;
+
 import org.apache.nifi.controller.exception.ValidationException;
 import org.apache.nifi.controller.service.ControllerServiceNode;
 import org.apache.nifi.web.ResourceNotFoundException;

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/ControllerServiceDAOFactoryBean.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/ControllerServiceDAOFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/ControllerServiceDAOFactoryBean.java
new file mode 100644
index 0000000..af41a9f
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/ControllerServiceDAOFactoryBean.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.web.spring;
+
+import org.apache.nifi.cluster.manager.impl.WebClusterManager;
+import org.apache.nifi.controller.FlowController;
+import org.apache.nifi.controller.repository.FlowFileEventRepository;
+import org.apache.nifi.util.NiFiProperties;
+import org.apache.nifi.web.dao.ControllerServiceDAO;
+import org.apache.nifi.web.dao.impl.StandardControllerServiceDAO;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ *
+ */
+public class ControllerServiceDAOFactoryBean implements FactoryBean, ApplicationContextAware {
+
+    private ApplicationContext context;
+    private StandardControllerServiceDAO controllerServiceDao;
+    private NiFiProperties properties;
+
+    @Override
+    public Object getObject() throws Exception {
+        if (controllerServiceDao == null) {
+            controllerServiceDao = new StandardControllerServiceDAO();
+            if (properties.isClusterManager()) {
+                controllerServiceDao.setServiceProvider(context.getBean("clusterManager", WebClusterManager.class));
+            } else {
+                controllerServiceDao.setServiceProvider(context.getBean("flowController", FlowController.class));
+            }
+        }
+
+        return controllerServiceDao;
+    }
+
+    @Override
+    public Class getObjectType() {
+        return ControllerServiceDAO.class;
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public void setProperties(NiFiProperties properties) {
+        this.properties = properties;
+    }
+
+    @Override
+    public void setApplicationContext(ApplicationContext context) throws BeansException {
+        this.context = context;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml
index c6aa6c0..8bc4fdd 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml
@@ -68,8 +68,8 @@
     <bean id="processorDAO" class="org.apache.nifi.web.dao.impl.StandardProcessorDAO">
         <property name="flowController" ref="flowController"/>
     </bean>
-    <bean id="controllerServiceDAO" class="org.apache.nifi.web.dao.impl.StandardControllerServiceDAO">
-        <property name="flowController" ref="flowController"/>
+    <bean id="controllerServiceDAO" class="org.apache.nifi.web.spring.ControllerServiceDAOFactoryBean" depends-on="clusterManager flowController">
+        <property name="properties" ref="nifiProperties"/>
     </bean>
     <bean id="templateDAO" class="org.apache.nifi.web.dao.impl.StandardTemplateDAO">
         <property name="flowController" ref="flowController"/>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
index 4a54a48..f16c372 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
@@ -419,6 +419,7 @@
                                                 <include>${staging.dir}/css/dialog.css</include>
                                                 <include>${staging.dir}/css/new-processor-dialog.css</include>
                                                 <include>${staging.dir}/css/new-controller-service-dialog.css</include>
+                                                <include>${staging.dir}/css/disable-controller-service-dialog.css</include>
                                                 <include>${staging.dir}/css/graph.css</include>
                                                 <include>${staging.dir}/css/header.css</include>
                                                 <include>${staging.dir}/css/main.css</include>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
index 9afc26c..d306368 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
@@ -80,6 +80,7 @@
         <jsp:include page="/WEB-INF/partials/ok-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/yes-no-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/status-history-dialog.jsp"/>
+        <jsp:include page="/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/canvas/new-controller-service-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/canvas/new-processor-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/canvas/new-port-dialog.jsp"/>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp
new file mode 100644
index 0000000..f4a4e72
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp
@@ -0,0 +1,27 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+--%>
+<%@ page contentType="text/html" pageEncoding="UTF-8" session="false" %>
+<div id="disable-controller-service-dialog">
+    <div class="dialog-content">
+        <div class="setting">
+            <div class="setting-name">Service</div>
+            <div class="setting-field">
+                <span id="disable-controller-service-name"></span>
+            </div>
+        </div>
+    </div>
+</div>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css
index a472a42..e59aba7 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css
@@ -31,6 +31,7 @@
 @import url(dialog.css);
 @import url(new-processor-dialog.css);
 @import url(new-controller-service-dialog.css);
+@import url(disable-controller-service-dialog.css);
 @import url(graph.css);
 @import url(header.css);
 @import url(main.css);

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/disable-controller-service-dialog.css
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/disable-controller-service-dialog.css b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/disable-controller-service-dialog.css
new file mode 100644
index 0000000..1da8f09
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/disable-controller-service-dialog.css
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* 
+    New controller service dialog.
+*/
+
+#disable-controller-service-dialog {
+    z-index: 1301;
+    display: none;
+    width: 500px;
+    height: 450px;
+    border: 1px solid #eee;
+    line-height: normal;
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
index 64f6dac..61b3156 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
@@ -635,12 +635,76 @@ nf.Settings = (function () {
         });
     };
     
+    // sets whether the specified controller service is enabled
+    var setEnabled = function (controllerService, enabled) {
+        var revision = nf.Client.getRevision();
+        return $.ajax({
+            type: 'PUT',
+            url: controllerService.uri,
+            data: {
+                clientId: revision.clientId,
+                version: revision.version,
+                enabled: enabled
+            },
+            dataType: 'json'
+        }).done(function (response) {
+            // update the revision
+            nf.Client.setRevision(response.revision);
+
+            // update the service
+            var controllerServicesGrid = $('#controller-services-table').data('gridInstance');
+            var controllerServicesData = controllerServicesGrid.getData();
+            controllerServicesData.updateItem(controllerService.id, response.controllerService);
+        }).fail(nf.Common.handleAjaxError);
+    };
+    
+    /**
+     * Initializes the dialog used to disable controller services.
+     */
+    var initDisableControllerSerivceDialog = function () {
+        $('#disable-controller-service-dialog').modal({
+            headerText: 'Disable Controller Service',
+            overlayBackground: false,
+            buttons: [{
+                buttonText: 'Disable',
+                handler: {
+                    click: function () {
+                        
+                    }
+                }
+            }, {
+                buttonText: 'Cancel',
+                handler: {
+                    click: function () {
+                        $(this).modal('hide');
+                    }
+                }
+            }],
+            close: function() {
+                
+            }
+        });
+    };
+    
+    /**
+     * Shows the dialog for disabling a controller service.
+     * 
+     * @argument {object} controllerService The controller service to disable
+     */
+    var showDisableControllerServiceDialog = function (controllerService) {
+        $('#disable-controller-service-name').text(controllerService.name);
+        $('#disable-controller-service-dialog').modal('show');
+    };
+    
     /**
      * Initializes the controller services tab.
      */
     var initControllerServices = function () {
         // initialize the new controller service dialog
         initNewControllerServiceDialog();
+      
+        // initialize the disable controller service dialog
+        initDisableControllerSerivceDialog();
         
         // more details formatter
         var moreControllerServiceDetails = function (row, cell, value, columnDef, dataContext) {
@@ -711,27 +775,6 @@ nf.Settings = (function () {
         controllerServicesGrid.registerPlugin(new Slick.AutoTooltips());
         controllerServicesGrid.setSortColumn('name', true);
         
-        // sets whether the specified controller service is enabled
-        var setEnabled = function (controllerService, enabled) {
-            var revision = nf.Client.getRevision();
-            return $.ajax({
-                type: 'PUT',
-                url: controllerService.uri,
-                data: {
-                    clientId: revision.clientId,
-                    version: revision.version,
-                    enabled: enabled
-                },
-                dataType: 'json'
-            }).done(function (response) {
-                // update the revision
-                nf.Client.setRevision(response.revision);
-
-                // update the service
-                controllerServicesData.updateItem(controllerService.id, response.controllerService);
-            }).fail(nf.Common.handleAjaxError);
-        };
-        
         // configure a click listener
         controllerServicesGrid.onClick.subscribe(function (e, args) {
             var target = $(e.target);
@@ -746,7 +789,11 @@ nf.Settings = (function () {
                 } else if (target.hasClass('enable-controller-service')) {
                     setEnabled(controllerService, true);
                 } else if (target.hasClass('disable-controller-service')) {
-                    setEnabled(controllerService, false);
+                    if (nf.Common.isEmpty(controllerService.references)) {
+                        setEnabled(controllerService, false);
+                    } else {
+                        showDisableControllerServiceDialog(controllerService);
+                    }
                 } else if (target.hasClass('delete-controller-service')) {
                     var revision = nf.Client.getRevision();
                     return $.ajax({