Example usage for java.util.prefs Preferences systemRoot

List of usage examples for java.util.prefs Preferences systemRoot

Introduction

In this page you can find the example usage for java.util.prefs Preferences systemRoot.

Prototype

public static Preferences systemRoot() 

Source Link

Document

Returns the root preference node for the system.

Usage

From source file:com.example.app.support.service.AppUtil.java

/**
 * Get the Role for Front End Access to the application
 *
 * @return the front end access role// ww w  .j  a  v  a2  s. c  om
 */
public Role getFrontEndAccessRole() {
    String frontEndRoleProgId = Preferences.systemRoot().get(PREF_KEY_FRONTEND_ROLE, null);
    if (StringFactory.isEmptyString(frontEndRoleProgId))
        throw new IllegalStateException(
                "Frontend Role Programmatic Id should be defined in Preferences.systemRoot " + "with the key: "
                        + PREF_KEY_FRONTEND_ROLE);
    return ofNullable(_roleDAO.getRoleByProgrammaticName(frontEndRoleProgId))
            .orElseThrow(() -> new IllegalStateException(
                    "Front End Role could not be foundfor programmatic id: " + frontEndRoleProgId));
}

From source file:com.example.app.support.service.AppUtil.java

/**
 * Get the Role for Admin Access to the application
 *
 * @return the admin access role/*  www.ja v a  2  s.c  om*/
 */
public Role getAdminAccessRole() {
    String adminRoleProgId = Preferences.systemRoot().get(PREF_KEY_ADMIN_ROLE, null);
    if (StringFactory.isEmptyString(adminRoleProgId))
        throw new IllegalStateException(
                "Admin Role Programmatic Id should be defined in Preferences.systemRoot " + "with the key: "
                        + PREF_KEY_ADMIN_ROLE);
    return ofNullable(_roleDAO.getRoleByProgrammaticName(adminRoleProgId))
            .orElseThrow(() -> new IllegalStateException(
                    "Admin Role could not be found for programmatic id: " + adminRoleProgId));
}

From source file:org.settings4j.connector.PreferencesConnector.java

/**
 * Default Constructor initialize the User and System {@link Preferences}.
 */
public PreferencesConnector() {
    this(Preferences.systemRoot(), Preferences.userRoot());
}

From source file:org.settings4j.helper.spring.Settings4jPlaceholderConfigurerTest.java

@Before
public void setUp() throws Exception {
    removeUnitTestNode(Preferences.userRoot());
    removeUnitTestNode(Preferences.systemRoot());
    Properties props = System.getProperties();
    props.remove(SYSTEM_PROPERTY_TEST_1);
    props.remove(SYSTEM_PROPERTY_TEST_2);
    props.remove(SYSTEM_PROPERTY_TEST_3);
    System.setProperties(props);//from  ww w .  ja  va 2 s  . c  o m
}