final String contextURL = moduleBaseURL.substring( 0, moduleBaseURL.lastIndexOf( moduleName ) );
if ( inheritsCheckBox.getValue() ) {
VerticalPanel vp = new VerticalPanel();
vp.add( new Label( Messages.getString( "permissionsWillBeLostQuestion" ) ) ); //$NON-NLS-1$
final PromptDialogBox permissionsOverwriteConfirm =
new PromptDialogBox(
Messages.getString( "permissionsWillBeLostConfirmMessage" ), Messages.getString( "ok" ), Messages.getString( "cancel" ), false, true, vp ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
final IDialogCallback callback = new IDialogCallback() {
public void cancelPressed() {
permissionsOverwriteConfirm.hide();
inheritsCheckBox.setValue( false );
dirty = false;
refreshPermission();
}
public void okPressed() {
String path = fileSummary.getPath().substring( 0, fileSummary.getPath().lastIndexOf( "/" ) );
String url = contextURL + "api/repo/files/" + SolutionBrowserPanel.pathToId( path ) + "/acl"; //$NON-NLS-1$ //$NON-NLS-2$
RequestBuilder builder = new RequestBuilder( RequestBuilder.GET, url );
// This header is required to force Internet Explorer to not cache values from the GET response.
builder.setHeader( "If-Modified-Since", "01 Jan 1970 00:00:00 GMT" );
try {
builder.sendRequest( null, new RequestCallback() {
public void onResponseReceived( Request request, Response response ) {
if ( response.getStatusCode() == Response.SC_OK ) {
initializePermissionPanel( XMLParser.parse( response.getText() ) );
inheritsCheckBox.setValue( true );
refreshPermission();
} else {
inheritsCheckBox.setValue( false );
refreshPermission();
MessageDialogBox dialogBox =
new MessageDialogBox(
Messages.getString( "error" ), Messages.getString( "couldNotGetPermissions", response.getStatusText() ), //$NON-NLS-1$ //$NON-NLS-2$
false, false, true );
dialogBox.center();
}
}
@Override
public void onError( Request request, Throwable exception ) {
inheritsCheckBox.setValue( false );
refreshPermission();
MessageDialogBox dialogBox =
new MessageDialogBox(
Messages.getString( "error" ), Messages.getString( "couldNotGetPermissions", exception.getLocalizedMessage() ), //$NON-NLS-1$ //$NON-NLS-2$
false, false, true );
dialogBox.center();
}
} );
} catch ( RequestException e ) {
inheritsCheckBox.setValue( false );
refreshPermission();
MessageDialogBox dialogBox =
new MessageDialogBox(
Messages.getString( "error" ), Messages.getString( "couldNotGetPermissions", e.getLocalizedMessage() ), //$NON-NLS-1$ //$NON-NLS-2$
false, false, true );
dialogBox.center();
}
}
};
permissionsOverwriteConfirm.setCallback( callback );
permissionsOverwriteConfirm.center();
}
refreshPermission();
}
} );