/** Default Constructor. */
 public ConsoleFactoryClient() {
   AngularIFrameView.addTokenSupport(
       AngularIFrameView.CASE_LISTING_ADMIN_TOKEN, "/admin/cases/list");
   AngularIFrameView.addTokenSupport(
       AngularIFrameView.APPLICATION_LISTING_PAGE, "/admin/applications");
   AngularIFrameView.addTokenSupport(
       AngularIFrameView.PROCESS_MORE_DETAILS_ADMIN_TOKEN, "/admin/processes/details");
 }
  @Override
  public RawView defineViewTokens(final String token) {

    if (ItemNotFoundPopup.TOKEN.equals(token)) {
      return new ItemNotFoundPopup();
    } else if (DeactivateUserWarningPopUp.TOKEN.equals(token)) {
      return new DeactivateUserWarningPopUp();

      // Manage Cases pages
    } else if (CaseQuickDetailsAdminPage.TOKEN.equals(token)
        && isUserAuthorized(CaseQuickDetailsAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new CaseQuickDetailsAdminPage();
    } else if (CaseMoreDetailsAdminPage.TOKEN.equals(token)
        && isUserAuthorized(CaseMoreDetailsAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new CaseMoreDetailsAdminPage();
    } else if (ArchivedCaseQuickDetailsAdminPage.TOKEN.equals(token)
        && isUserAuthorized(
            ArchivedCaseQuickDetailsAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ArchivedCaseQuickDetailsAdminPage();
    } else if (ArchivedCaseMoreDetailsAdminPage.TOKEN.equals(token)
        && isUserAuthorized(
            ArchivedCaseMoreDetailsAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ArchivedCaseMoreDetailsAdminPage();
      // } else if (ListGroupPage.TOKEN.equals(token)) {
      // return new ListGroupPage();
    } else if (DisplayCaseFormPage.TOKEN.equals(token)
        && isUserAuthorized(DisplayCaseFormPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new DisplayCaseFormPage();

      // Import export organization page
    } else if (OrganizationImportAndExportPage.TOKEN.equals(token)
        && isUserAuthorized(
            OrganizationImportAndExportPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new OrganizationImportAndExportPage();

      // Manage Users pages
    } else if (UserListingAdminPage.TOKEN.equals(token)
        && isUserAuthorized(UserListingAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new UserListingAdminPage();
    } else if (UserQuickDetailsAdminPage.TOKEN.equals(token)
        && isUserAuthorized(UserQuickDetailsAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new UserQuickDetailsAdminPage();
    } else if (UserQuickDetailsPage.TOKEN.equals(token)
        && isUserAuthorized(UserQuickDetailsPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new UserQuickDetailsPage();
    } else if (UserMoreDetailsAdminPage.TOKEN.equals(token)
        && isUserAuthorized(UserMoreDetailsAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new UserMoreDetailsAdminPage();
    } else if (PopupAddUserPage.TOKEN.equals(token)
        && isUserAuthorized(PopupAddUserPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new PopupAddUserPage();
    } else if (AddMembershipPage.TOKEN.equals(token)
        && isUserAuthorized(AddMembershipPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new AddMembershipPage();
    } else if (DeleteMembershipPage.TOKEN.equals(token)
        && isUserAuthorized(DeleteMembershipPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new DeleteMembershipPage();
    } else if (ListMembershipPage.TOKEN.equals(token)
        && isUserAuthorized(ListMembershipPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ListMembershipPage();
    } else if (UpdateUserPage.TOKEN.equals(token)
        && isUserAuthorized(UpdateUserPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new UpdateUserPage();

      // Manage processes pages For Admin
    } else if (ProcessListingAdminPage.TOKEN.equals(token)
        && isUserAuthorized(ProcessListingAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ProcessListingAdminPage();
    } else if (ProcessQuickDetailsAdminPage.TOKEN.equals(token)
        && isUserAuthorized(
            ProcessQuickDetailsAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ProcessQuickDetailsAdminPage();
    } else if (ProcessMoreDetailsAdminPage.TOKEN.equals(token)
        && isUserAuthorized(ProcessMoreDetailsAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      // No action is necessary as an unauthorized request will result in a page reload.
      return new ProcessMoreDetailsAdminPage();
    } else if (AngularIFrameView.PROCESS_MORE_DETAILS_ADMIN_TOKEN.equals(token)
        && isUserAuthorized(ProcessMoreDetailsAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return prepareAngularPage(token);
    } else if (UploadProcessPage.TOKEN.equals(token)
        && isUserAuthorized(UploadProcessPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new UploadProcessPage();
    } else if (CreateCategoryAndAddToProcessPage.TOKEN.equals(token)
        && isUserAuthorized(
            CreateCategoryAndAddToProcessPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new CreateCategoryAndAddToProcessPage();
    } else if (AddProcessCategoryPage.TOKEN.equals(token)
        && isUserAuthorized(AddProcessCategoryPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new AddProcessCategoryPage();
    } else if (ListProcessActorUserPage.TOKEN.equals(token)
        && isUserAuthorized(ListProcessActorUserPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ListProcessActorUserPage();
    } else if (ListProcessActorGroupPage.TOKEN.equals(token)
        && isUserAuthorized(ListProcessActorGroupPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ListProcessActorGroupPage();
    } else if (ListProcessActorRolePage.TOKEN.equals(token)
        && isUserAuthorized(ListProcessActorRolePage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ListProcessActorRolePage();
    } else if (ListProcessActorMembershipPage.TOKEN.equals(token)
        && isUserAuthorized(
            ListProcessActorMembershipPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ListProcessActorMembershipPage();
    } else if (SelectMembershipForActorPage.TOKEN.equals(token)
        && isUserAuthorized(
            SelectMembershipForActorPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new SelectMembershipForActorPage();
    } else if (SelectUserForActorPage.TOKEN.equals(token)
        && isUserAuthorized(SelectUserForActorPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new SelectUserForActorPage();
    } else if (SelectGroupForActorPage.TOKEN.equals(token)
        && isUserAuthorized(SelectGroupForActorPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new SelectGroupForActorPage();
    } else if (SelectRoleForActorPage.TOKEN.equals(token)
        && isUserAuthorized(SelectRoleForActorPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new SelectRoleForActorPage();

      // Manage Roles pages
    } else if (RoleListingPage.TOKEN.equals(token)
        && isUserAuthorized(RoleListingPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new RoleListingPage();
    } else if (RoleQuickDetailsPage.TOKEN.equals(token)
        && isUserAuthorized(RoleQuickDetailsPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new RoleQuickDetailsPage();
    } else if (AddRolePage.TOKEN.equals(token)
        && isUserAuthorized(AddRolePage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new AddRolePage();
    } else if (UpdateRolePage.TOKEN.equals(token)
        && isUserAuthorized(UpdateRolePage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new UpdateRolePage();

      // Manage Groups pages
    } else if (GroupListingAdminPage.TOKEN.equals(token)
        && isUserAuthorized(GroupListingAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new GroupListingAdminPage();
    } else if (GroupQuickDetailsAdminPage.TOKEN.equals(token)
        && isUserAuthorized(GroupQuickDetailsAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new GroupQuickDetailsAdminPage();
    } else if (AddGroupPage.TOKEN.equals(token)
        && isUserAuthorized(AddGroupPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new AddGroupPage();
    } else if (UpdateGroupPage.TOKEN.equals(token)
        && isUserAuthorized(UpdateGroupPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new UpdateGroupPage();

      // User Privileges settings pages
    } else if (ProfileListingPage.TOKEN.equals(token)
        && isUserAuthorized(ProfileListingPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ProfileListingPage();
    } else if (ProfileMoreDetailsPage.TOKEN.equals(token)
        && isUserAuthorized(ProfileMoreDetailsPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ProfileMoreDetailsPage();
    } else if (ProfileQuickDetailsPage.TOKEN.equals(token)
        && isUserAuthorized(ProfileQuickDetailsPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ProfileQuickDetailsPage();
    } else if (AddGroupToProfileMemberPage.TOKEN.equals(token)
        && isUserAuthorized(AddGroupToProfileMemberPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new AddGroupToProfileMemberPage();
    } else if (AddRoleToProfileMemberPage.TOKEN.equals(token)
        && isUserAuthorized(AddRoleToProfileMemberPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new AddRoleToProfileMemberPage();
    } else if (AddUserToProfileMemberPage.TOKEN.equals(token)
        && isUserAuthorized(AddUserToProfileMemberPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new AddUserToProfileMemberPage();
    } else if (AddMembershipToProfileMemberPage.TOKEN.equals(token)
        && isUserAuthorized(
            AddMembershipToProfileMemberPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new AddMembershipToProfileMemberPage();
    } else if (DeleteProfileMemberPage.TOKEN.equals(token)
        && isUserAuthorized(DeleteProfileMemberPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new DeleteProfileMemberPage();

    } else if (DeleteActorMemberPage.TOKEN.equals(token)) {
      return new DeleteActorMemberPage();

      // Manage Tasks pages
    } else if (TaskListingAdminPage.TOKEN.equals(token)
        && isUserAuthorized(TaskListingAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new TaskListingAdminPage();
    } else if (SelectUserAndAssignTaskPage.TOKEN.equals(token)
        && isUserAuthorized(SelectUserAndAssignTaskPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new SelectUserAndAssignTaskPage();
    } else if (TaskQuickDetailsAdminPage.TOKEN.equals(token)
        && isUserAuthorized(TaskQuickDetailsAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new TaskQuickDetailsAdminPage();
    } else if (TaskMoreDetailsAdminPage.TOKEN.equals(token)
        && isUserAuthorized(TaskMoreDetailsAdminPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new TaskMoreDetailsAdminPage();

      /*
       * THEME pages
       * } else if (ListThemePage.TOKEN.equals(token)) {
       * return new ListThemePage();
       * } else if (UploadThemePage.TOKEN.equals(token)) {
       * return new UploadThemePage();
       * } else if (EditThemePage.TOKEN.equals(token)) {
       * return new EditThemePage();
       */

      // Visualize & do tasks
    } else if (TasksListingPage.TOKEN.equals(token)
        && isUserAuthorized(TasksListingPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new TasksListingPage();
    } else if (HumanTaskQuickDetailsPage.TOKEN.equals(token)
        && isUserAuthorized(HumanTaskQuickDetailsPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new HumanTaskQuickDetailsPage();
    } else if (HumanTaskMoreDetailsPage.TOKEN.equals(token)
        && isUserAuthorized(HumanTaskMoreDetailsPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new HumanTaskMoreDetailsPage();
    } else if (ArchivedHumanTaskQuickDetailsPage.TOKEN.equals(token)
        && isUserAuthorized(
            ArchivedHumanTaskQuickDetailsPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ArchivedHumanTaskQuickDetailsPage();
    } else if (ArchivedHumanTaskMoreDetailsPage.TOKEN.equals(token)
        && isUserAuthorized(
            ArchivedHumanTaskMoreDetailsPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ArchivedHumanTaskMoreDetailsPage();
    } else if (PerformTaskPage.TOKEN.equals(token)
        && isUserAuthorized(PerformTaskPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new PerformTaskPage();

      // Visualize & Start processes
    } else if (ProcessListingPage.TOKEN.equals(token)
        && isUserAuthorized(ProcessListingPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ProcessListingPage();
    } else if (ProcessQuickDetailsPage.TOKEN.equals(token)
        && isUserAuthorized(ProcessQuickDetailsPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ProcessQuickDetailsPage();
    } else if (StartProcessFormPage.TOKEN.equals(token)
        && isUserAuthorized(StartProcessFormPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new StartProcessFormPage();

      // Visualize Cases
    } else if (CaseListingPage.TOKEN.equals(token)
        && isUserAuthorized(CaseListingPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new CaseListingPage();
    } else if (CaseQuickDetailsPage.TOKEN.equals(token)
        && isUserAuthorized(CaseQuickDetailsPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new CaseQuickDetailsPage();
    } else if (ArchivedCaseQuickDetailsPage.TOKEN.equals(token)
        && isUserAuthorized(
            ArchivedCaseQuickDetailsPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ArchivedCaseQuickDetailsPage();
    } else if (ArchivedCaseMoreDetailsPage.TOKEN.equals(token)
        && isUserAuthorized(ArchivedCaseMoreDetailsPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new ArchivedCaseMoreDetailsPage();
    } else if (CaseMoreDetailsPage.TOKEN.equals(token)
        && isUserAuthorized(CaseMoreDetailsPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new CaseMoreDetailsPage();

    } else if (TechnicalUserWarningView.TOKEN.equals(token)) {
      return new TechnicalUserWarningView();
      // System
    } else if (PopupAboutPage.TOKEN.equals(token)) {
      return new PopupAboutPage();
    } else if (TechnicalUserServicePausedView.TOKEN.equals(token)) {
      return new TechnicalUserServicePausedView();
    } else if (ChangeLangPage.TOKEN.equals(token)) {
      return new ChangeLangPage();
    } else if (TenantMaintenancePage.TOKEN.equals(token)
        && isUserAuthorized(TenantMaintenancePage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new TenantMaintenancePage();
      // Custom pages
    } else if (PageListingPage.TOKEN.equals(token)
        && isUserAuthorized(PageListingPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new PageListingPage();
    } else if (AddCustomPage.TOKEN.equals(token)
        && isUserAuthorized(AddCustomPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new AddCustomPage();
    } else if (EditCustomPage.TOKEN.equals(token)
        && isUserAuthorized(EditCustomPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new EditCustomPage();
    } else if (PageQuickDetailsPage.TOKEN.equals(token)
        && isUserAuthorized(PageListingPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new PageQuickDetailsPage();
    } else if (CustomPagePermissionsValidationPopupPage.TOKEN.equals(token)
        && isUserAuthorized(PageListingPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new CustomPagePermissionsValidationPopupPage();

      // Custom pages
    } else if (token != null && token.startsWith(CustomPageWithFrame.TOKEN)) {
      if (isUserAuthorized(token, getCurrentUserAccessRights())) {
        return new CustomPageWithFrame(token);
      } else {
        return new BlankPage();
      }
      // BDM
    } else if (BDMImportPage.TOKEN.equals(token)
        && isUserAuthorized(BDMImportPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new BDMImportPage();
    } else if (BDMImportWarningPopUp.TOKEN.equals(token)
        && isUserAuthorized(BDMImportPage.PRIVILEGES, getCurrentUserAccessRights())) {
      return new BDMImportWarningPopUp();

    } else if (AngularIFrameView.supportsToken(token)
        && isUserAuthorized(Arrays.asList(token), getCurrentUserAccessRights())) {
      // No action is necessary as an unauthorized request will result in a page reload.
      return prepareAngularPage(token);
    } else {
      return new BlankPage();
    }
  }
 /**
  * @param token
  * @return
  */
 public RawView prepareAngularPage(final String token) {
   new CheckValidSessionBeforeAction(emptyAction).execute();
   final AngularIFrameView ngView = angularFrame;
   ngView.setUrl("#" + AngularIFrameView.getRoute(token), token);
   return ngView;
 }