diff --git a/user-console/src/main/java/org/pentaho/mantle/client/ui/xul/MantleXul.java b/user-console/src/main/java/org/pentaho/mantle/client/ui/xul/MantleXul.java index 90ef6840349..b9e060543d0 100644 --- a/user-console/src/main/java/org/pentaho/mantle/client/ui/xul/MantleXul.java +++ b/user-console/src/main/java/org/pentaho/mantle/client/ui/xul/MantleXul.java @@ -12,7 +12,7 @@ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * - * Copyright (c) 2002-2023 Hitachi Vantara. All rights reserved. + * Copyright (c) 2002-2024 Hitachi Vantara. All rights reserved. */ package org.pentaho.mantle.client.ui.xul; @@ -364,51 +364,112 @@ public void onError( Request request, Throwable exception ) { } public void onResponseReceived( Request request, Response response ) { - JsArray jsoverlays = JsXulOverlay.parseJson( JsonUtils.escapeJsonForEval( response.getText() ) ); - ArrayList overlays = new ArrayList(); - for ( int i = 0; i < jsoverlays.length(); i++ ) { - JsXulOverlay o = jsoverlays.get( i ); - MantleXulOverlay overlay; - overlay = - new MantleXulOverlay( o.getId(), o.getOverlayUri(), o.getSource(), o.getResourceBundleUri(), - Integer.parseInt( o.getPriority() ) ); - overlays.add( overlay ); + if ( containsSchedulerEEOverlay( jsoverlays ) ) { + fetchWithEEOverlay( jsoverlays ); + } else { + fetchWihoutEEOverlay( jsoverlays ); } + } + } ); + } catch ( RequestException e ) { + // showError(e); + } + } + }; + cmd.execute(); + } - MantleXul.this.addOverlays( overlays ); + private void fetchWithEEOverlay( JsArray jsoverlays ) { - final String url = GWT.getHostPageBaseURL() + "plugin/data-access/api/permissions/hasDataAccess"; //$NON-NLS-1$ - RequestBuilder builder = new RequestBuilder( RequestBuilder.GET, url ); - builder.setHeader( "If-Modified-Since", "01 Jan 1970 00:00:00 GMT" ); - builder.setHeader( "accept", "application/json" ); + final String url = GWT.getHostPageBaseURL() + "api/licenseManager/getLicenses"; //$NON-NLS-1$ + RequestBuilder builder = new RequestBuilder( RequestBuilder.GET, url ); + builder.setHeader( "If-Modified-Since", "01 Jan 1970 00:00:00 GMT" ); + builder.setHeader( "accept", "application/json" ); - try { - builder.sendRequest( null, new RequestCallback() { + try { + builder.sendRequest( null, new RequestCallback() { - public void onError( Request request, Throwable exception ) { - Window.alert( exception.getMessage() ); - } + public void onError( Request request, Throwable exception ) { + Window.alert( exception.getMessage() ); + } - public void onResponseReceived( Request request, Response response ) { - if ( response.getText().equals( "true" ) ) { - controller.loadOverlay( "dataaccess" ); - } - } - } ); - } catch ( RequestException e ) { - // showError(e); + public void onResponseReceived( Request request, Response response ) { + boolean containsEELicense = response.getText().contains( "BISERVER-EE" ); + + ArrayList overlays = new ArrayList(); + for ( int i = 0; i < jsoverlays.length(); i++ ) { + JsXulOverlay o = jsoverlays.get( i ); + if ( o.getId().equals( "admin.perspective.overlay.scheduler-ee" ) ) { + if ( !containsEELicense ) { + continue; } } - } ); - } catch ( RequestException e ) { - // showError(e); + MantleXulOverlay overlay; + overlay = + new MantleXulOverlay( o.getId(), o.getOverlayUri(), o.getSource(), o.getResourceBundleUri(), + Integer.parseInt( o.getPriority() ) ); + overlays.add( overlay ); + } + + MantleXul.this.addOverlays( overlays ); + fetchDataAccessOverlay(); } + } ); + } catch ( RequestException e ) { + // showError(e); + } + } + + private void fetchWihoutEEOverlay( JsArray jsoverlays ) { + ArrayList overlays = new ArrayList(); + for ( int i = 0; i < jsoverlays.length(); i++ ) { + JsXulOverlay o = jsoverlays.get( i ); + MantleXulOverlay overlay; + overlay = + new MantleXulOverlay( o.getId(), o.getOverlayUri(), o.getSource(), o.getResourceBundleUri(), + Integer.parseInt( o.getPriority() ) ); + overlays.add( overlay ); + } + MantleXul.this.addOverlays( overlays ); + fetchDataAccessOverlay(); + } + + private boolean containsSchedulerEEOverlay( JsArray jsoverlays ) { + ArrayList overlays = new ArrayList(); + for ( int i = 0; i < jsoverlays.length(); i++ ) { + JsXulOverlay o = jsoverlays.get( i ); + if ( o.getId().equals( "admin.perspective.overlay.scheduler-ee" ) ) { + return true; } - }; - cmd.execute(); + } + return false; + } + + private void fetchDataAccessOverlay() { + final String url = GWT.getHostPageBaseURL() + "plugin/data-access/api/permissions/hasDataAccess"; //$NON-NLS-1$ + RequestBuilder builder = new RequestBuilder( RequestBuilder.GET, url ); + builder.setHeader( "If-Modified-Since", "01 Jan 1970 00:00:00 GMT" ); + builder.setHeader( "accept", "application/json" ); + + try { + builder.sendRequest( null, new RequestCallback() { + + public void onError( Request request, Throwable exception ) { + Window.alert( exception.getMessage() ); + } + + public void onResponseReceived( Request request, Response response ) { + if ( response.getText().equals( "true" ) ) { + controller.loadOverlay( "dataaccess" ); + } + } + } ); + } catch ( RequestException e ) { + // showError(e); + } } public void overlayLoaded() {