try {
scheduleFileRequestBuilder.sendRequest( null, new RequestCallback() {
public void onError( Request request, Throwable exception ) {
MessageDialogBox dialogBox =
new MessageDialogBox( Messages.getString( "error" ), exception.toString(), false, false, true ); //$NON-NLS-1$
dialogBox.center();
}
public void onResponseReceived( Request request, Response response ) {
if ( response.getStatusCode() == Response.SC_OK ) {
final JSONObject scheduleRequest = new JSONObject();
scheduleRequest.put( "inputFile", new JSONString( filePath ) ); //$NON-NLS-1$
// Set job name
if ( StringUtils.isEmpty( getOutputName() ) ) {
scheduleRequest.put( "jobName", JSONNull.getInstance() ); //$NON-NLS-1$
} else {
scheduleRequest.put( "jobName", new JSONString( getOutputName() ) ); //$NON-NLS-1$
}
// Set output path location
if ( StringUtils.isEmpty( getOutputLocationPath() ) ) {
scheduleRequest.put( "outputFile", JSONNull.getInstance() ); //$NON-NLS-1$
} else {
scheduleRequest.put( "outputFile", new JSONString( getOutputLocationPath() ) ); //$NON-NLS-1$
}
// BISERVER-9321
scheduleRequest.put( "runInBackground", JSONBoolean.getInstance( true ) );
String responseMessage = response.getText();
final boolean hasParams = hasParameters( responseMessage, isXAction );
RequestBuilder emailValidRequest =
new RequestBuilder( RequestBuilder.GET, contextURL + "api/emailconfig/isValid" ); //$NON-NLS-1$
emailValidRequest.setHeader( "accept", "text/plain" ); //$NON-NLS-1$ //$NON-NLS-2$
emailValidRequest.setHeader( "If-Modified-Since", "01 Jan 1970 00:00:00 GMT" );
try {
emailValidRequest.sendRequest( null, new RequestCallback() {
public void onError( Request request, Throwable exception ) {
MessageDialogBox dialogBox =
new MessageDialogBox( Messages.getString( "error" ), exception.toString(), false, false, true ); //$NON-NLS-1$
dialogBox.center();
}
public void onResponseReceived( Request request, Response response ) {
if ( response.getStatusCode() == Response.SC_OK ) {
// final boolean isEmailConfValid = Boolean.parseBoolean(response.getText());
// force false for now, I have a feeling PM is going to want this, making it easy to turn back
// on
final boolean isEmailConfValid = false;
if ( hasParams ) {
ScheduleParamsDialog dialog =
new ScheduleParamsDialog( filePath, scheduleRequest, isEmailConfValid );
dialog.center();
} else if ( isEmailConfValid ) {
ScheduleEmailDialog scheduleEmailDialog =
new ScheduleEmailDialog( null, filePath, scheduleRequest, null, null );
scheduleEmailDialog.center();
} else {
// just run it
RequestBuilder scheduleFileRequestBuilder =
new RequestBuilder( RequestBuilder.POST, contextURL + "api/scheduler/job" ); //$NON-NLS-1$
scheduleFileRequestBuilder.setHeader( "Content-Type", "application/json" ); //$NON-NLS-1$//$NON-NLS-2$
scheduleFileRequestBuilder.setHeader( "If-Modified-Since", "01 Jan 1970 00:00:00 GMT" );
try {
scheduleFileRequestBuilder.sendRequest( scheduleRequest.toString(), new RequestCallback() {
@Override
public void onError( Request request, Throwable exception ) {
MessageDialogBox dialogBox =
new MessageDialogBox(
Messages.getString( "error" ), exception.toString(), false, false, true ); //$NON-NLS-1$
dialogBox.center();
}
@Override
public void onResponseReceived( Request request, Response response ) {
if ( response.getStatusCode() == 200 ) {
MessageDialogBox dialogBox =
new MessageDialogBox(
Messages.getString( "runInBackground" ), Messages.getString( "backgroundExecutionStarted" ), //$NON-NLS-1$ //$NON-NLS-2$
false, false, true );
dialogBox.center();
} else {
MessageDialogBox dialogBox =
new MessageDialogBox(
Messages.getString( "error" ), Messages.getString( "serverErrorColon" ) + " " + response.getStatusCode(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-2$ //$NON-NLS-3$
false, false, true );
dialogBox.center();
}
}
} );
} catch ( RequestException e ) {
MessageDialogBox dialogBox = new MessageDialogBox( Messages.getString( "error" ), e.toString(), //$NON-NLS-1$
false, false, true );
dialogBox.center();
}
}
}
}
} );
} catch ( RequestException e ) {
MessageDialogBox dialogBox =
new MessageDialogBox( Messages.getString( "error" ), e.toString(), false, false, true ); //$NON-NLS-1$
dialogBox.center();
}
} else {
MessageDialogBox dialogBox =
new MessageDialogBox(
Messages.getString( "error" ), Messages.getString( "serverErrorColon" ) + " " + response.getStatusCode(), false, false, true ); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
dialogBox.center();
}
}
} );
} catch ( RequestException e ) {
MessageDialogBox dialogBox =
new MessageDialogBox( Messages.getString( "error" ), e.toString(), false, false, true ); //$NON-NLS-1$
dialogBox.center();
}
}