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
public static final String DEFAULT_TITLE = "NiFi";
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_USER_CREDENTIAL_CACHE_DURATION = "24 hours";
public static final Integer DEFAULT_REMOTE_INPUT_PORT = null;
@ -511,7 +511,7 @@ public class NiFiProperties extends Properties {
public File getAuthorizerConfiguraitonFile() {
final String value = getProperty(AUTHORIZER_CONFIGURATION_FILE);
if (StringUtils.isBlank(value)) {
return new File(DEFAULT_AUTHORITY_PROVIDER_CONFIGURATION_FILE);
return new File(DEFAULT_AUTHORIZER_CONFIGURATION_FILE);
} else {
return new File(value);
}

View File

@ -16,24 +16,12 @@
*/
package org.apache.nifi.web.api;
import java.net.URI;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
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 com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;
import com.wordnik.swagger.annotations.Authorization;
import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.authorization.Authorizer;
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.LongParameter;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;
import com.wordnik.swagger.annotations.Authorization;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
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 java.net.URI;
import java.util.Set;
/**
* 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));
}
// 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()) {
return replicate(HttpMethod.PUT, remoteProcessGroupPortEntity);
}
// handle expects request (usually from the cluster manager)
final Revision revision = getRevision(remoteProcessGroupPortEntity, id);
return withWriteLock(
serviceFacade,
@ -393,12 +396,18 @@ public class RemoteProcessGroupResource extends ApplicationResource {
+ "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()) {
return replicate(HttpMethod.PUT, remoteProcessGroupPortEntity);
}
// handle expects request (usually from the cluster manager)
final Revision revision = getRevision(remoteProcessGroupPortEntity, portId);
final Revision revision = getRevision(remoteProcessGroupPortEntity, id);
return withWriteLock(
serviceFacade,
revision,

View File

@ -112,6 +112,7 @@ nf.ng.Canvas.GraphControlsCtrl = function (serviceProvider, navigateCtrl, operat
this.navigateCtrl = navigateCtrl;
this.operateCtrl = operateCtrl;
}
GraphControlsCtrl.prototype = {
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
positionGraphControls();
},
/**
* Position the graph controls
*/
positionGraphControls: function () {
positionGraphControls();
},
/**
* Undock the graph control.
* @param {jQuery} $event

View File

@ -512,33 +512,28 @@ nf.Actions = (function () {
componentsToStart.each(function (d) {
var selected = d3.select(this);
// processor endpoint does not use running flag...
var component = {
'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) {
// prepare the request
var uri, entity;
if (nf.CanvasUtils.isProcessGroup(selected)) {
nf.ProcessGroup.set(response);
// reload the group's connections
var connections = nf.Connection.getComponentConnections(response.id);
$.each(connections, function (_, connection) {
if (connection.accessPolicy.canRead) {
nf.Connection.reload(connection.component);
uri = config.urls.api + '/flow/process-groups/' + encodeURIComponent(d.id);
entity = {
'id': d.id,
'state': 'RUNNING'
}
});
} 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 {
nf[d.type].set(response);
}
@ -587,33 +582,28 @@ nf.Actions = (function () {
componentsToStop.each(function (d) {
var selected = d3.select(this);
// processor endpoint does not use running flag...
var component = {
'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) {
// prepare the request
var uri, entity;
if (nf.CanvasUtils.isProcessGroup(selected)) {
nf.ProcessGroup.set(response);
// reload the group's connections
var connections = nf.Connection.getComponentConnections(response.id);
$.each(connections, function (_, connection) {
if (connection.accessPolicy.canRead) {
nf.Connection.reload(connection.component);
uri = config.urls.api + '/flow/process-groups/' + encodeURIComponent(d.id);
entity = {
'id': d.id,
'state': 'STOPPED'
};
} else {
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 {
nf[d.type].set(response);
}

View File

@ -523,6 +523,17 @@ nf.Canvas = (function () {
if (e.target === window) {
updateGraphSize();
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) {
// if a dialog is open, disable canvas shortcuts

View File

@ -229,11 +229,6 @@ nf.ProcessGroupConfiguration = (function () {
// settings refresh button...
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
initGeneral();
nf.ControllerServices.init(getControllerServicesTable());

View File

@ -491,26 +491,11 @@ nf.QueueListing = (function () {
}).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 {
init: function () {
initializeListingRequestStatusDialog();
initFlowFileDetailsDialog();
// listen for browser resize events to update the page size
$(window).resize(function () {
resetTableSize();
});
// define mouse over event for the refresh button
nf.Common.addHoverEffect('#queue-listing-refresh-button', 'button-refresh', 'button-refresh-hover').click(function () {
var connection = $('#queue-listing-table').data('connection');
@ -634,6 +619,16 @@ nf.QueueListing = (function () {
$('#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.
*
@ -668,7 +663,7 @@ nf.QueueListing = (function () {
});
// adjust the table size
resetTableSize();
nf.QueueListing.resetTableSize();
// store the connection for access later
$('#queue-listing-table').data('connection', connection);

View File

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

View File

@ -670,7 +670,7 @@ nf.RemoteProcessGroup = (function () {
// received ports value
updated.select('text.remote-process-group-received tspan.ports')
.text(function (d) {
return d.inputPortCount + ' ' + String.fromCharCode(8594) + ' ';
return d.outputPortCount + ' ' + String.fromCharCode(8594) + ' ';
});
// 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
initGeneral();
nf.ControllerServices.init(getControllerServicesTable());

View File

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