NIFI-1781:

- Listening for window resize events more selectively.
- Fixing malformed request when configuring remote process group ports.
- Fixing malformed request when starting/stopping a selected process group.
- Fixing default value for authorizers.xml.
- This closes #524
This commit is contained in:
Matt Gilman 2016-06-13 12:53:39 -04:00
parent cc95e5d8c5
commit 75bb4bfaa2
11 changed files with 248 additions and 228 deletions

View File

@ -186,7 +186,7 @@ public class NiFiProperties extends Properties {
// defaults // defaults
public static final String DEFAULT_TITLE = "NiFi"; public static final String DEFAULT_TITLE = "NiFi";
public static final Boolean DEFAULT_AUTO_RESUME_STATE = true; public static final Boolean DEFAULT_AUTO_RESUME_STATE = true;
public static final String DEFAULT_AUTHORITY_PROVIDER_CONFIGURATION_FILE = "conf/authority-providers.xml"; public static final String DEFAULT_AUTHORIZER_CONFIGURATION_FILE = "conf/authorizers.xml";
public static final String DEFAULT_LOGIN_IDENTITY_PROVIDER_CONFIGURATION_FILE = "conf/login-identity-providers.xml"; public static final String DEFAULT_LOGIN_IDENTITY_PROVIDER_CONFIGURATION_FILE = "conf/login-identity-providers.xml";
public static final String DEFAULT_USER_CREDENTIAL_CACHE_DURATION = "24 hours"; public static final String DEFAULT_USER_CREDENTIAL_CACHE_DURATION = "24 hours";
public static final Integer DEFAULT_REMOTE_INPUT_PORT = null; public static final Integer DEFAULT_REMOTE_INPUT_PORT = null;
@ -511,7 +511,7 @@ public class NiFiProperties extends Properties {
public File getAuthorizerConfiguraitonFile() { public File getAuthorizerConfiguraitonFile() {
final String value = getProperty(AUTHORIZER_CONFIGURATION_FILE); final String value = getProperty(AUTHORIZER_CONFIGURATION_FILE);
if (StringUtils.isBlank(value)) { if (StringUtils.isBlank(value)) {
return new File(DEFAULT_AUTHORITY_PROVIDER_CONFIGURATION_FILE); return new File(DEFAULT_AUTHORIZER_CONFIGURATION_FILE);
} else { } else {
return new File(value); return new File(value);
} }

View File

@ -16,24 +16,12 @@
*/ */
package org.apache.nifi.web.api; package org.apache.nifi.web.api;
import java.net.URI; import com.wordnik.swagger.annotations.Api;
import java.util.Set; import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import javax.servlet.http.HttpServletRequest; import com.wordnik.swagger.annotations.ApiResponse;
import javax.ws.rs.Consumes; import com.wordnik.swagger.annotations.ApiResponses;
import javax.ws.rs.DELETE; import com.wordnik.swagger.annotations.Authorization;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.authorization.Authorizer; import org.apache.nifi.authorization.Authorizer;
import org.apache.nifi.authorization.RequestAction; import org.apache.nifi.authorization.RequestAction;
@ -49,12 +37,22 @@ import org.apache.nifi.web.api.entity.RemoteProcessGroupPortEntity;
import org.apache.nifi.web.api.request.ClientIdParameter; import org.apache.nifi.web.api.request.ClientIdParameter;
import org.apache.nifi.web.api.request.LongParameter; import org.apache.nifi.web.api.request.LongParameter;
import com.wordnik.swagger.annotations.Api; import javax.servlet.http.HttpServletRequest;
import com.wordnik.swagger.annotations.ApiOperation; import javax.ws.rs.Consumes;
import com.wordnik.swagger.annotations.ApiParam; import javax.ws.rs.DELETE;
import com.wordnik.swagger.annotations.ApiResponse; import javax.ws.rs.DefaultValue;
import com.wordnik.swagger.annotations.ApiResponses; import javax.ws.rs.GET;
import com.wordnik.swagger.annotations.Authorization; import javax.ws.rs.HttpMethod;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.net.URI;
import java.util.Set;
/** /**
* RESTful endpoint for managing a Remote group. * RESTful endpoint for managing a Remote group.
@ -310,11 +308,16 @@ public class RemoteProcessGroupResource extends ApplicationResource {
+ "remote process group port id of the requested resource (%s).", requestRemoteProcessGroupPort.getId(), portId)); + "remote process group port id of the requested resource (%s).", requestRemoteProcessGroupPort.getId(), portId));
} }
// ensure the group ids are the same
if (!id.equals(requestRemoteProcessGroupPort.getGroupId())) {
throw new IllegalArgumentException(String.format("The remote process group id (%s) in the request body does not equal the "
+ "remote process group id of the requested resource (%s).", requestRemoteProcessGroupPort.getGroupId(), id));
}
if (isReplicateRequest()) { if (isReplicateRequest()) {
return replicate(HttpMethod.PUT, remoteProcessGroupPortEntity); return replicate(HttpMethod.PUT, remoteProcessGroupPortEntity);
} }
// handle expects request (usually from the cluster manager)
final Revision revision = getRevision(remoteProcessGroupPortEntity, id); final Revision revision = getRevision(remoteProcessGroupPortEntity, id);
return withWriteLock( return withWriteLock(
serviceFacade, serviceFacade,
@ -393,12 +396,18 @@ public class RemoteProcessGroupResource extends ApplicationResource {
+ "remote process group port id of the requested resource (%s).", requestRemoteProcessGroupPort.getId(), portId)); + "remote process group port id of the requested resource (%s).", requestRemoteProcessGroupPort.getId(), portId));
} }
// ensure the group ids are the same
if (!id.equals(requestRemoteProcessGroupPort.getGroupId())) {
throw new IllegalArgumentException(String.format("The remote process group id (%s) in the request body does not equal the "
+ "remote process group id of the requested resource (%s).", requestRemoteProcessGroupPort.getGroupId(), id));
}
if (isReplicateRequest()) { if (isReplicateRequest()) {
return replicate(HttpMethod.PUT, remoteProcessGroupPortEntity); return replicate(HttpMethod.PUT, remoteProcessGroupPortEntity);
} }
// handle expects request (usually from the cluster manager) // handle expects request (usually from the cluster manager)
final Revision revision = getRevision(remoteProcessGroupPortEntity, portId); final Revision revision = getRevision(remoteProcessGroupPortEntity, id);
return withWriteLock( return withWriteLock(
serviceFacade, serviceFacade,
revision, revision,

View File

@ -112,6 +112,7 @@ nf.ng.Canvas.GraphControlsCtrl = function (serviceProvider, navigateCtrl, operat
this.navigateCtrl = navigateCtrl; this.navigateCtrl = navigateCtrl;
this.operateCtrl = operateCtrl; this.operateCtrl = operateCtrl;
} }
GraphControlsCtrl.prototype = { GraphControlsCtrl.prototype = {
constructor: GraphControlsCtrl, constructor: GraphControlsCtrl,
@ -144,13 +145,17 @@ nf.ng.Canvas.GraphControlsCtrl = function (serviceProvider, navigateCtrl, operat
}); });
} }
// listen for browser resize events to reset the graph control positioning
$(window).resize(positionGraphControls);
// set the initial position // set the initial position
positionGraphControls(); positionGraphControls();
}, },
/**
* Position the graph controls
*/
positionGraphControls: function () {
positionGraphControls();
},
/** /**
* Undock the graph control. * Undock the graph control.
* @param {jQuery} $event * @param {jQuery} $event

View File

@ -512,33 +512,28 @@ nf.Actions = (function () {
componentsToStart.each(function (d) { componentsToStart.each(function (d) {
var selected = d3.select(this); var selected = d3.select(this);
// processor endpoint does not use running flag... // prepare the request
var component = { var uri, entity;
'id': d.id,
};
if (nf.CanvasUtils.isProcessor(selected) || nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected)) {
component['state'] = 'RUNNING';
} else {
component['running'] = true;
}
// build the entity
var entity = {
'revision': nf.Client.getRevision(d),
'component': component
};
startRequests.push(updateResource(d.component.uri, entity).done(function (response) {
if (nf.CanvasUtils.isProcessGroup(selected)) { if (nf.CanvasUtils.isProcessGroup(selected)) {
nf.ProcessGroup.set(response); uri = config.urls.api + '/flow/process-groups/' + encodeURIComponent(d.id);
entity = {
// reload the group's connections 'id': d.id,
var connections = nf.Connection.getComponentConnections(response.id); 'state': 'RUNNING'
$.each(connections, function (_, connection) {
if (connection.accessPolicy.canRead) {
nf.Connection.reload(connection.component);
} }
}); } else {
uri = d.component.uri;
entity = {
'revision': nf.Client.getRevision(d),
'component': {
'id': d.id,
'state': 'RUNNING'
}
};
}
startRequests.push(updateResource(uri, entity).done(function (response) {
if (nf.CanvasUtils.isProcessGroup(selected)) {
nf.ProcessGroup.reload(d.component);
} else { } else {
nf[d.type].set(response); nf[d.type].set(response);
} }
@ -587,33 +582,28 @@ nf.Actions = (function () {
componentsToStop.each(function (d) { componentsToStop.each(function (d) {
var selected = d3.select(this); var selected = d3.select(this);
// processor endpoint does not use running flag... // prepare the request
var component = { var uri, entity;
'id': d.id,
};
if (nf.CanvasUtils.isProcessor(selected) || nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected)) {
component['state'] = 'STOPPED';
} else {
component['running'] = false;
}
// build the entity
var entity = {
'revision': nf.Client.getRevision(d),
'component': component
};
stopRequests.push(updateResource(d.component.uri, entity).done(function (response) {
if (nf.CanvasUtils.isProcessGroup(selected)) { if (nf.CanvasUtils.isProcessGroup(selected)) {
nf.ProcessGroup.set(response); uri = config.urls.api + '/flow/process-groups/' + encodeURIComponent(d.id);
entity = {
// reload the group's connections 'id': d.id,
var connections = nf.Connection.getComponentConnections(response.id); 'state': 'STOPPED'
$.each(connections, function (_, connection) { };
if (connection.accessPolicy.canRead) { } else {
nf.Connection.reload(connection.component); uri = d.component.uri;
entity = {
'revision': nf.Client.getRevision(d),
'component': {
'id': d.id,
'state': 'STOPPED'
} }
}); };
}
stopRequests.push(updateResource(uri, entity).done(function (response) {
if (nf.CanvasUtils.isProcessGroup(selected)) {
nf.ProcessGroup.reload(d.component);
} else { } else {
nf[d.type].set(response); nf[d.type].set(response);
} }

View File

@ -523,6 +523,17 @@ nf.Canvas = (function () {
if (e.target === window) { if (e.target === window) {
updateGraphSize(); updateGraphSize();
updateFlowStatusContainerSize(); updateFlowStatusContainerSize();
nf.ng.Bridge.get('appCtrl.serviceProvider.graphControlsCtrl').positionGraphControls();
// resize grids when appropriate
if ($('#process-group-controller-services-table').is(':visible')) {
nf.ProcessGroupConfiguration.resetTableSize();
} else if ($('#controller-services-table').is(':visible') || $('#reporting-tasks-table').is(':visible')) {
nf.Settings.resetTableSize();
} else if ($('#queue-listing-table').is(':visible')) {
nf.QueueListing.resetTableSize();
}
} }
}).on('keydown', function (evt) { }).on('keydown', function (evt) {
// if a dialog is open, disable canvas shortcuts // if a dialog is open, disable canvas shortcuts

View File

@ -229,11 +229,6 @@ nf.ProcessGroupConfiguration = (function () {
// settings refresh button... // settings refresh button...
nf.Common.addHoverEffect('#process-group-configuration-refresh-button', 'button-refresh', 'button-refresh-hover'); nf.Common.addHoverEffect('#process-group-configuration-refresh-button', 'button-refresh', 'button-refresh-hover');
// handle window resizing
$(window).on('resize', function (e) {
nf.ProcessGroupConfiguration.resetTableSize();
});
// initialize each tab // initialize each tab
initGeneral(); initGeneral();
nf.ControllerServices.init(getControllerServicesTable()); nf.ControllerServices.init(getControllerServicesTable());

View File

@ -491,26 +491,11 @@ nf.QueueListing = (function () {
}).fail(nf.Common.handleAjaxError); }).fail(nf.Common.handleAjaxError);
}; };
/**
* Resets the table size.
*/
var resetTableSize = function () {
var queueListingGrid = $('#queue-listing-table').data('gridInstance');
if (nf.Common.isDefinedAndNotNull(queueListingGrid)) {
queueListingGrid.resizeCanvas();
}
};
return { return {
init: function () { init: function () {
initializeListingRequestStatusDialog(); initializeListingRequestStatusDialog();
initFlowFileDetailsDialog(); initFlowFileDetailsDialog();
// listen for browser resize events to update the page size
$(window).resize(function () {
resetTableSize();
});
// define mouse over event for the refresh button // define mouse over event for the refresh button
nf.Common.addHoverEffect('#queue-listing-refresh-button', 'button-refresh', 'button-refresh-hover').click(function () { nf.Common.addHoverEffect('#queue-listing-refresh-button', 'button-refresh', 'button-refresh-hover').click(function () {
var connection = $('#queue-listing-table').data('connection'); var connection = $('#queue-listing-table').data('connection');
@ -634,6 +619,16 @@ nf.QueueListing = (function () {
$('#displayed-flowfiles').text('0'); $('#displayed-flowfiles').text('0');
}, },
/**
* Update the size of the grid based on its container's current size.
*/
resetTableSize: function () {
var queueListingGrid = $('#queue-listing-table').data('gridInstance');
if (nf.Common.isDefinedAndNotNull(queueListingGrid)) {
queueListingGrid.resizeCanvas();
}
},
/** /**
* Shows the listing of the FlowFiles from a given connection. * Shows the listing of the FlowFiles from a given connection.
* *
@ -668,7 +663,7 @@ nf.QueueListing = (function () {
}); });
// adjust the table size // adjust the table size
resetTableSize(); nf.QueueListing.resetTableSize();
// store the connection for access later // store the connection for access later
$('#queue-listing-table').data('connection', connection); $('#queue-listing-table').data('connection', connection);

View File

@ -260,6 +260,7 @@ nf.RemoteProcessGroupPorts = (function () {
'revision': nf.Client.getRevision(remoteProcessGroupData), 'revision': nf.Client.getRevision(remoteProcessGroupData),
'remoteProcessGroupPort': { 'remoteProcessGroupPort': {
id: port.id, id: port.id,
groupId: remoteProcessGroupId,
transmitting: isTransmitting transmitting: isTransmitting
} }
}; };

View File

@ -670,7 +670,7 @@ nf.RemoteProcessGroup = (function () {
// received ports value // received ports value
updated.select('text.remote-process-group-received tspan.ports') updated.select('text.remote-process-group-received tspan.ports')
.text(function (d) { .text(function (d) {
return d.inputPortCount + ' ' + String.fromCharCode(8594) + ' '; return d.outputPortCount + ' ' + String.fromCharCode(8594) + ' ';
}); });
// received count value // received count value

View File

@ -990,11 +990,6 @@ nf.Settings = (function () {
} }
}); });
// handle window resizing
$(window).on('resize', function (e) {
nf.Settings.resetTableSize();
});
// initialize each tab // initialize each tab
initGeneral(); initGeneral();
nf.ControllerServices.init(getControllerServicesTable()); nf.ControllerServices.init(getControllerServicesTable());

View File

@ -48,6 +48,9 @@ $(document).ready(function () {
nf.Shell = (function () { nf.Shell = (function () {
var showPageResize = null;
var showContentResize = null;
return { return {
/** /**
* Shows a page in the shell. * Shows a page in the shell.
@ -99,13 +102,21 @@ nf.Shell = (function () {
height: shell.height() height: shell.height()
}).appendTo(shell); }).appendTo(shell);
// add a window resize listener // remove the window resize listener
$(window).resize(function () { if (typeof showPageResize === 'function') {
$(window).off('resize', showPageResize);
}
// handle resize
showPageResize = function () {
shellIframe.css({ shellIframe.css({
width: shell.width(), width: shell.width(),
height: shell.height() height: shell.height()
}); });
}); };
// add a window resize listener
$(window).resize(showPageResize);
}).promise(); }).promise();
}, },
@ -152,17 +163,25 @@ nf.Shell = (function () {
height: shell.height() height: shell.height()
}).append(content).appendTo(shell); }).append(content).appendTo(shell);
// remove the window resize listener
if (typeof showContentResize === 'function') {
$(window).off('resize', showContentResize);
}
// show the content // show the content
$('#shell-dialog').modal('show'); $('#shell-dialog').modal('show');
content.show(); content.show();
// add a window resize listener // handle resizes
$(window).resize(function () { showContentResize = function () {
contentContainer.css({ contentContainer.css({
width: shell.width(), width: shell.width(),
height: shell.height() height: shell.height()
}); });
}); };
// add a window resize listener
$(window).resize(showContentResize);
} }
}).promise(); }).promise();
} }