use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.
the class SystemResource method getAuthenticationProvider.
/**
* Return JSON string reporting which authentication provider is currently in use
*
* Response sample: { "authenticationType": "JCR_BASED_AUTHENTICATION" }
*
* @return AuthenticationProvider represented as JSON response
* @throws Exception
*/
@GET
@Path("/authentication-provider")
@Produces({ MediaType.APPLICATION_JSON })
@Facet(name = "Unsupported")
public Response getAuthenticationProvider() throws Exception {
try {
if (canAdminister()) {
IConfiguration config = this.systemConfig.getConfiguration("security");
String provider = config.getProperties().getProperty("provider");
return Response.ok(new AuthenticationProvider(provider)).type(MediaType.APPLICATION_JSON).build();
} else {
return Response.status(UNAUTHORIZED).build();
}
} catch (Throwable t) {
// $NON-NLS-1$
logger.error(Messages.getInstance().getString("SystemResource.GENERAL_ERROR"), t);
throw new Exception(t);
}
}
use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.
the class SystemResource method setLocaleOverride.
/**
* Apply the selected locale to the user console
*
* @param locale (user console's locale)
*
* @return
*/
@POST
@Path("/locale")
@Facet(name = "Unsupported")
public Response setLocaleOverride(String locale) {
IPentahoSession session = PentahoSessionHolder.getSession();
Locale newLocale = null;
if (session != null) {
if (!StringUtils.isEmpty(locale)) {
// Clean up "en-US" and "en/GB"
String localeTmp = locale.replaceAll("-|/", "_");
try {
newLocale = LocaleUtils.toLocale(localeTmp);
session.setAttribute("locale_override", localeTmp);
LocaleHelper.setLocaleOverride(newLocale);
} catch (IllegalArgumentException ex) {
return Response.serverError().entity(ex.getMessage()).build();
}
} else {
// empty string or null passed in, unset locale_override variable.
session.setAttribute("locale_override", null);
LocaleHelper.setLocaleOverride(null);
}
} else {
LocaleHelper.setLocaleOverride(null);
}
return getLocale();
}
use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.
the class ThemeResource method setTheme.
/**
* Set the current theme to the one provided in this request
*
* @param theme (theme to be changed to)
*
* @return
*/
@POST
@Path("/set")
@Consumes({ WILDCARD })
@StatusCodes({ @ResponseCode(code = 200, condition = "Successfully set theme."), @ResponseCode(code = 403, condition = "Illegal set operation.") })
@Produces("text/plain")
@Facet(name = "Unsupported")
public Response setTheme(String theme) {
IThemeManager themeManager = PentahoSystem.get(IThemeManager.class);
List<String> ids = themeManager.getSystemThemeIds();
if ((ids != null) && (ids.indexOf(theme) >= 0)) {
getPentahoSession().setAttribute("pentaho-user-theme", theme);
IUserSettingService settingsService = PentahoSystem.get(IUserSettingService.class, getPentahoSession());
settingsService.setUserSetting("pentaho-user-theme", theme);
return getActiveTheme();
} else {
// Prevent log forging/injection
String cleanTheme = theme.replace('\n', ' ').replace('\r', ' ');
// We do not want to NLS-ize this message
logger.error("Attempt to set invalid theme: " + cleanTheme);
return Response.status(Response.Status.FORBIDDEN).entity("").build();
}
}
use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.
the class UserConsoleResource method getMondrianCatalogs.
/**
* Return the list of mondrian cubes in the platform
*
* @return list of cubes
*/
@GET
@Path("/cubes")
@Facet(name = "Unsupported")
@Produces({ APPLICATION_JSON, APPLICATION_XML })
public List<Cube> getMondrianCatalogs() {
ArrayList<Cube> cubes = new ArrayList<Cube>();
IMondrianCatalogService catalogService = PentahoSystem.get(IMondrianCatalogService.class, "IMondrianCatalogService", UserConsoleService.getPentahoSession());
List<MondrianCatalog> catalogs = catalogService.listCatalogs(UserConsoleService.getPentahoSession(), true);
for (MondrianCatalog cat : catalogs) {
for (MondrianCube cube : cat.getSchema().getCubes()) {
cubes.add(new Cube(cat.getName(), cube.getName(), cube.getId()));
}
}
return cubes;
}
use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.
the class UserConsoleResource method getMantleSettings.
/**
* Return the current user console settings
*
* @return current settings
*/
@GET
@Path("/settings")
@Produces({ APPLICATION_JSON, APPLICATION_XML })
@Facet(name = "Unsupported")
public List<Setting> getMantleSettings() {
ArrayList<Setting> settings = new ArrayList<Setting>();
settings.add(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new Setting("login-show-users-list", PentahoSystem.getSystemSetting("login-show-users-list", "")));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
settings.add(new Setting("documentation-url", PentahoSystem.getSystemSetting("documentation-url", "")));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
settings.add(new Setting("submit-on-enter-key", PentahoSystem.getSystemSetting("submit-on-enter-key", "true")));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
settings.add(new Setting("user-console-revision", PentahoSystem.getSystemSetting("user-console-revision", "")));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
settings.add(new Setting("startupPerspective", PentahoSystem.getSystemSetting("startup-perspective", "")));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
settings.add(new Setting("showOnlyPerspective", PentahoSystem.getSystemSetting("show-only-perspective", "")));
int startupUrls = Integer.parseInt(PentahoSystem.getSystemSetting("num-startup-urls", "0"));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
settings.add(new Setting("num-startup-urls", PentahoSystem.getSystemSetting("num-startup-urls", "0")));
for (int i = 1; i <= startupUrls; i++) {
// $NON-NLS-1$
settings.add(new Setting("startup-url-" + i, PentahoSystem.getSystemSetting("startup-url-" + i, "")));
// $NON-NLS-1$
settings.add(new Setting("startup-name-" + i, PentahoSystem.getSystemSetting("startup-name-" + i, "")));
}
// Check for override of New Analysis View via pentaho.xml
// Poked in via pentaho.xml entries
// <new-analysis-view>
// <command-url>http://www.google.com</command-url>
// <command-title>Marc Analysis View</command-title>
// </new-analysis-view>
// <new-report>
// <command-url>http://www.yahoo.com</command-url>
// <command-title>Marc New Report</command-title>
// </new-report>
//
// $NON-NLS-1$
String overrideNewAnalysisViewCommmand = PentahoSystem.getSystemSetting("new-analysis-view/command-url", null);
// $NON-NLS-1$
String overrideNewAnalysisViewTitle = PentahoSystem.getSystemSetting("new-analysis-view/command-title", null);
if ((overrideNewAnalysisViewCommmand != null) && (overrideNewAnalysisViewTitle != null)) {
// $NON-NLS-1$
settings.add(new Setting("new-analysis-view-command-url", overrideNewAnalysisViewCommmand));
// $NON-NLS-1$
settings.add(new Setting("new-analysis-view-command-title", overrideNewAnalysisViewTitle));
}
// $NON-NLS-1$
String overrideNewReportCommmand = PentahoSystem.getSystemSetting("new-report/command-url", null);
// $NON-NLS-1$
String overrideNewReportTitle = PentahoSystem.getSystemSetting("new-report/command-title", null);
if ((overrideNewReportCommmand != null) && (overrideNewReportTitle != null)) {
// $NON-NLS-1$
settings.add(new Setting("new-report-command-url", overrideNewReportCommmand));
// $NON-NLS-1$
settings.add(new Setting("new-report-command-title", overrideNewReportTitle));
}
// $NON-NLS-1$
IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class, UserConsoleService.getPentahoSession());
if (pluginManager != null) {
// load content types from IPluginSettings
int i = 0;
for (String contentType : pluginManager.getContentTypes()) {
IContentInfo info = pluginManager.getContentTypeInfo(contentType);
if (info != null) {
// $NON-NLS-1$ //$NON-NLS-2$
settings.add(new Setting("plugin-content-type-" + i, "." + contentType));
// $NON-NLS-1$
settings.add(new Setting("plugin-content-type-icon-" + i, info.getIconUrl()));
int j = 0;
for (IPluginOperation operation : info.getOperations()) {
// $NON-NLS-1$
settings.add(new Setting("plugin-content-type-" + i + "-command-" + j, operation.getId()));
settings.add(new Setting("plugin-content-type-" + i + "-command-perspective-" + j, // $NON-NLS-1$
operation.getPerspective()));
j++;
}
i++;
}
}
}
return settings;
}
Aggregations