return JsonUtils.getJsonResult( false, msg );
}
}
try {
final DashboardStructure dashboardStructure = new DashboardStructure();
Object result = null;
HashMap<String, Object> params = new HashMap<String, Object>( request.getParameterMap() );
params.put( MethodParams.FILE, file );
params.put( MethodParams.WIDGET, String.valueOf( widget ) );
if ( !author.isEmpty() ) {
params.put( MethodParams.AUTHOR, author );
}
if ( !style.isEmpty() ) {
params.put( MethodParams.STYLE, style );
}
if ( !widgetName.isEmpty() ) {
params.put( MethodParams.WIDGET_NAME, widgetName );
}
if ( !rendererType.isEmpty() ) {
params.put( MethodParams.RENDERER_TYPE, rendererType );
}
if ( !title.isEmpty() ) {
params.put( MethodParams.TITLE, title );
}
if ( !description.isEmpty() ) {
params.put( MethodParams.DESCRIPTION, description );
}
String[] widgetParameters = widgetParams.toArray( new String[ 0 ] );
if ( widgetParameters.length > 0 ) {
params.put( MethodParams.WIDGET_PARAMETERS, widgetParameters );
}
String wcdfdeFile = file.replace( ".wcdf", ".cdfde" );
if ( OPERATION_LOAD.equalsIgnoreCase( operation ) ) {
return dashboardStructure.load( wcdfdeFile );
} else if ( OPERATION_DELETE.equalsIgnoreCase( operation ) ) {
dashboardStructure.delete( params );
} else if ( OPERATION_SAVE.equalsIgnoreCase( operation ) ) {
result = dashboardStructure.save( file, cdfStructure );
} else if ( OPERATION_SAVE_AS.equalsIgnoreCase( operation ) ) {
if ( StringUtils.isEmpty( title ) ) {
title = FilenameUtils.getBaseName( file );
}
result = dashboardStructure.saveAs( file, title, description, cdfStructure, isPreview );
} else if ( OPERATION_NEW_FILE.equalsIgnoreCase( operation ) ) {
dashboardStructure.newfile( params );
} else if ( OPERATION_SAVE_SETTINGS.equalsIgnoreCase( operation ) ) {
// check if user is attempting to save settings over a new (non yet saved) dashboard/widget/template
if( StringUtils.isEmpty( file ) || file.equals( UNSAVED_FILE_PATH ) ) {
logger.warn( getMessage( "CdfTemplates.ERROR_003_SAVE_DASHBOARD_FIRST" ) );
return JsonUtils.getJsonResult( false, getMessage( "CdfTemplates.ERROR_003_SAVE_DASHBOARD_FIRST" ) );
}
dashboardStructure.savesettings( params );
} else {
logger.error( "Unknown operation: " + operation );
}
return JsonUtils.getJsonResult( true, result );
} catch ( Exception e ) {