Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BACKLOG-39778] EMAIL GROUPS - remove the "Email Groups" section competely from view if license does not have BI-SERVER feature #5556

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -364,51 +364,112 @@ public void onError( Request request, Throwable exception ) {
}

public void onResponseReceived( Request request, Response response ) {

JsArray<JsXulOverlay> jsoverlays =
JsXulOverlay.parseJson( JsonUtils.escapeJsonForEval( response.getText() ) );

ArrayList<XulOverlay> overlays = new ArrayList<XulOverlay>();
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<JsXulOverlay> 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<XulOverlay> overlays = new ArrayList<XulOverlay>();
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<JsXulOverlay> jsoverlays ) {
ArrayList<XulOverlay> overlays = new ArrayList<XulOverlay>();
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<JsXulOverlay> jsoverlays ) {
ArrayList<XulOverlay> overlays = new ArrayList<XulOverlay>();
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() {
Expand Down
Loading