use of org.pentaho.platform.plugin.services.pluginmgr.IAdminContentConditionalLogic in project pentaho-platform by pentaho.
the class UserConsoleResource method getAdminContent.
/**
* Returns the list of admin related settings
*
* @return list of settings
*/
@GET
@Path("/getAdminContent")
@Facet(name = "Unsupported")
@Produces({ APPLICATION_JSON, APPLICATION_XML })
public List<Setting> getAdminContent() {
ArrayList<Setting> settings = new ArrayList<Setting>();
try {
IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class, UserConsoleService.getPentahoSession());
List<String> pluginIds = pluginManager.getRegisteredPlugins();
nextPlugin: for (String pluginId : pluginIds) {
String adminContentInfo = (String) pluginManager.getPluginSetting(pluginId, "admin-content-info", null);
String exceptionMessage = (String) pluginManager.getPluginSetting(pluginId, "exception-message", null);
if (adminContentInfo != null) {
StringTokenizer nameValuePairs = new StringTokenizer(adminContentInfo, ";");
while (nameValuePairs.hasMoreTokens()) {
String currentToken = nameValuePairs.nextToken().trim();
if (currentToken.startsWith("conditional-logic-validator=")) {
String validatorName = currentToken.substring("conditional-logic-validator=".length());
Class<?> validatorClass = pluginManager.getClassLoader(pluginId).loadClass(validatorName);
IAdminContentConditionalLogic validator = (IAdminContentConditionalLogic) validatorClass.newInstance();
int status = validator.validate();
if (status == IAdminContentConditionalLogic.DISPLAY_ADMIN_CONTENT) {
settings.add(new Setting("admin-content-info", adminContentInfo));
}
if (status == IAdminContentConditionalLogic.DISPLAY_EXCEPTION_MESSAGE && exceptionMessage != null) {
settings.add(new Setting("exception-message", exceptionMessage));
}
if (status == IAdminContentConditionalLogic.AVOID_ADMIN_CONTENT) {
continue nextPlugin;
}
}
}
}
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return settings;
}
Aggregations