예제 #1
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    this.authenticationService =
        (MutableAuthenticationService)
            getServer().getApplicationContext().getBean("AuthenticationService");
    this.authenticationComponent =
        (AuthenticationComponent)
            getServer().getApplicationContext().getBean("authenticationComponent");
    this.policyBehaviourFilter =
        (BehaviourFilter) getServer().getApplicationContext().getBean("policyBehaviourFilter");
    this.transactionService =
        (TransactionService) getServer().getApplicationContext().getBean("transactionService");
    this.personService =
        (PersonService) getServer().getApplicationContext().getBean("PersonService");
    this.nodeService = (NodeService) getServer().getApplicationContext().getBean("NodeService");
    this.siteService = (SiteService) getServer().getApplicationContext().getBean("SiteService");
    this.wikiService = (WikiService) getServer().getApplicationContext().getBean("WikiService");
    this.internalNodeService =
        (NodeService) getServer().getApplicationContext().getBean("nodeService");
    this.nodeArchiveService =
        (NodeArchiveService) getServer().getApplicationContext().getBean("nodeArchiveService");

    // Authenticate as user
    this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());

    // Create test site
    // - only create the site if it doesn't already exist
    SiteInfo siteInfo = this.siteService.getSite(SITE_SHORT_NAME_WIKI);
    if (siteInfo == null) {
      this.siteService.createSite(
          "WikiSitePreset",
          SITE_SHORT_NAME_WIKI,
          "WikiSiteTitle",
          "TestDescription",
          SiteVisibility.PUBLIC);
    }

    // Ensure the links container is there
    if (!siteService.hasContainer(SITE_SHORT_NAME_WIKI, "wiki")) {
      siteService.createContainer(SITE_SHORT_NAME_WIKI, "wiki", null, null);
    }

    // Create users
    createUser(USER_ONE, SiteModel.SITE_COLLABORATOR);
    createUser(USER_TWO, SiteModel.SITE_COLLABORATOR);

    // Do tests as inviter user
    this.authenticationComponent.setCurrentUser(USER_ONE);
  }
  public boolean isSiteSirhExist() {
    SiteInfo site = siteService.getSite(CreateSiteWebScript.NOM_SITE);

    if (null == site) return false;

    return true;
  }
예제 #3
0
  @Override
  protected void tearDown() throws Exception {
    super.tearDown();

    // admin user required to delete user
    this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());

    SiteInfo siteInfo = this.siteService.getSite(SITE_SHORT_NAME_WIKI);
    if (siteInfo != null) {
      // delete the site
      siteService.deleteSite(SITE_SHORT_NAME_WIKI);
      nodeArchiveService.purgeArchivedNode(
          nodeArchiveService.getArchivedNode(siteInfo.getNodeRef()));
    }

    // delete the users
    if (personService.personExists(USER_ONE)) {
      personService.deletePerson(USER_ONE);
    }
    if (this.authenticationService.authenticationExists(USER_ONE)) {
      this.authenticationService.deleteAuthentication(USER_ONE);
    }

    if (personService.personExists(USER_TWO)) {
      personService.deletePerson(USER_TWO);
    }
    if (this.authenticationService.authenticationExists(USER_TWO)) {
      this.authenticationService.deleteAuthentication(USER_TWO);
    }
  }
  private PersonFavourite addFavouriteSite(String userName, NodeRef nodeRef) {
    PersonFavourite favourite = null;

    SiteInfo siteInfo = siteService.getSite(nodeRef);
    if (siteInfo != null) {
      favourite = getFavouriteSite(userName, siteInfo);
      if (favourite == null) {
        Map<String, Serializable> preferences = new HashMap<String, Serializable>(1);

        String siteFavouritedKey = siteFavouritedKey(siteInfo);
        preferences.put(siteFavouritedKey, Boolean.TRUE);

        // ISO8601 string format: PreferenceService works with strings only for dates it seems
        String siteCreatedAtKey = siteCreatedAtKey(siteInfo);
        Date createdAt = new Date();
        String createdAtStr = ISO8601DateFormat.format(createdAt);
        preferences.put(siteCreatedAtKey, createdAtStr);

        preferenceService.setPreferences(userName, preferences);

        favourite =
            new PersonFavourite(
                userName, siteInfo.getNodeRef(), Type.SITE, siteInfo.getTitle(), createdAt);

        QName nodeClass = nodeService.getType(nodeRef);
        OnAddFavouritePolicy policy = onAddFavouriteDelegate.get(nodeRef, nodeClass);
        policy.onAddFavourite(userName, nodeRef);
      }
    } else {
      // shouldn't happen, getType recognizes it as a site or subtype
      logger.warn("Unable to get site for " + nodeRef);
    }

    return favourite;
  }
  @Before
  public void setUp() throws Exception {
    // The class under test
    dispatcher = ctx.getBean("vtiRequestDispatcher", VtiRequestDispatcher.class);
    fileFolderService = ctx.getBean("FileFolderService", FileFolderService.class);
    siteService = ctx.getBean("SiteService", SiteService.class);
    response = new MockHttpServletResponse();
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());

    // Create a site for use in these tests
    shortSiteId = "SharepointTest-" + UUID.randomUUID();
    if (!siteService.hasSite(shortSiteId)) {
      siteService.createSite(
          "sitePreset1", shortSiteId, "Test site", "Sharepoint tests", SiteVisibility.PUBLIC);
      docLib =
          siteService.createContainer(
              shortSiteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
    }
  }
  @Override
  protected String applyInternal() throws Exception {
    // get all users in the system
    List<PersonInfo> personInfos =
        _personService
            .getPeople(null, null, null, new PagingRequest(Integer.MAX_VALUE, null))
            .getPage();

    Set<NodeRef> people = new HashSet<NodeRef>(personInfos.size());

    for (PersonInfo personInfo : personInfos) {
      people.add(personInfo.getNodeRef());
    }

    int count = 0;

    // iterate through all the users
    for (final NodeRef person : people) {
      // get the username from the node
      final Serializable username = nodeService.getProperty(person, ContentModel.PROP_USERNAME);

      // if no username, continue
      if (username == null) {
        continue;
      }

      // if it's the guest or admin, skip as well
      if (username.toString().equals("guest") || username.toString().equals("admin")) {
        continue;
      }

      // list all sites that the user is excplicit member in
      final List<SiteInfo> sites = _siteService.listSites(username.toString());

      // the user is member of 1 site or more, continue
      if (sites.size() > 0) {
        continue;
      }

      // if this point is reached, the user is not a member of any site, so it
      // should be deleted
      LOG.error("Deleting user '" + username + "', user is not a member of any site");

      _personService.deletePerson(username.toString());

      count++;
    }

    LOG.error(
        "Deleted " + count + " of " + people.size() + " users that wasn't a member in any sites.");

    return I18NUtil.getMessage(MSG_SUCCESS);
  }
예제 #7
0
  private String getSiteName(Map<String, String> properties) {
    String siteFullName = properties.get(wfVarResourceName);
    SiteInfo site = siteService.getSite(siteFullName);
    if (site == null)
      throw new InvitationException("The site " + siteFullName + " could not be found.");

    String siteName = site.getShortName();
    String siteTitle = site.getTitle();
    if (siteTitle != null && siteTitle.length() > 0) {
      siteName = siteTitle;
    }
    return siteName;
  }
예제 #8
0
 /** Deletes the site */
 public void deleteSite() {
   if (siteService.isSiteAdmin(AuthenticationUtil.getFullyAuthenticatedUser())) {
     AuthenticationUtil.runAs(
         new AuthenticationUtil.RunAsWork<Void>() {
           public Void doWork() throws Exception {
             // Delete the site
             siteService.deleteSite(siteInfo.getShortName());
             return null;
           }
         },
         AuthenticationUtil.getAdminUserName());
   } else {
     // Delete the site
     this.siteService.deleteSite(this.siteInfo.getShortName());
   }
 }
예제 #9
0
  public void testRenamePageWithEmptyTitle() throws Exception {
    JSONObject page;
    String name = System.currentTimeMillis() + "";
    String name2 = System.currentTimeMillis() + 1 + "";

    // Create a page
    page = createOrUpdatePage(name, name, null, Status.STATUS_OK);
    assertEquals("Incorrect JSON: " + page.toString(), true, page.has("title"));

    // Fetch it and check
    page = getPage(name, Status.STATUS_OK);
    assertEquals(name, page.getString("name"));
    assertEquals(name, page.getString("title"));

    // update title
    SiteInfo site = siteService.getSite(SITE_SHORT_NAME_WIKI);
    WikiPageInfo pageInfo = wikiService.getWikiPage(site.getShortName(), name);
    NodeRef pageRef = pageInfo.getNodeRef();
    nodeService.setProperty(pageRef, ContentModel.PROP_TITLE, "");

    // Fetch it and check
    page = getPage(name, Status.STATUS_OK);
    JSONArray versions = page.getJSONArray("versionhistory");

    int maxVersionIndex = versions.length() - 1;
    double vNum = Double.parseDouble(versions.getJSONObject(maxVersionIndex).getString("version"));
    String newTitle = versions.getJSONObject(maxVersionIndex).getString("title");
    for (int i = versions.length() - 2; i >= 0; i--) {
      JSONObject version = versions.getJSONObject(i);
      String ver = version.getString("version");
      if (Double.parseDouble(ver) > vNum) {
        maxVersionIndex = i;
        vNum = Double.parseDouble(ver);
        newTitle = versions.getJSONObject(maxVersionIndex).getString("title");
      }
    }
    assertEquals(name, page.getString("name"));
    assertEquals("", newTitle);

    renamePage(name, name2, Status.STATUS_OK);

    // Fetch it at the new address
    page = getPage(name2, Status.STATUS_OK);
    assertEquals(name2, page.getString("name"));
    assertEquals(name2, page.getString("title"));
  }
예제 #10
0
 /**
  * Saves any outstanding updates to the site details.
  *
  * <p>If properties of the site are changed and save is not called, those changes will be lost.
  */
 public void save() {
   if (this.isDirty == true) {
     if (siteService.isSiteAdmin(AuthenticationUtil.getFullyAuthenticatedUser())) {
       AuthenticationUtil.runAs(
           new AuthenticationUtil.RunAsWork<Void>() {
             public Void doWork() throws Exception {
               // Update the site details as a site-admin
               siteService.updateSite(siteInfo);
               return null;
             }
           },
           AuthenticationUtil.getAdminUserName());
     } else {
       // Update the site details
       this.siteService.updateSite(this.siteInfo);
     }
     // Reset the dirty flag
     this.isDirty = false;
   }
 }
예제 #11
0
  /** Monkeys with the created date on a wiki page */
  private void pushPageCreatedDateBack(String name, int daysAgo) throws Exception {
    NodeRef container = siteService.getContainer(SITE_SHORT_NAME_WIKI, "wiki");
    NodeRef node = nodeService.getChildByName(container, ContentModel.ASSOC_CONTAINS, name);

    Date created = (Date) nodeService.getProperty(node, ContentModel.PROP_CREATED);
    Date newCreated = new Date(created.getTime() - daysAgo * 24 * 60 * 60 * 1000);

    UserTransaction txn = transactionService.getUserTransaction();
    txn.begin();

    this.policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
    internalNodeService.setProperty(node, ContentModel.PROP_CREATED, newCreated);
    this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);

    txn.commit();

    // Now chance something else on the node to have it re-indexed
    nodeService.setProperty(node, ContentModel.PROP_CREATED, newCreated);
    nodeService.setProperty(node, ContentModel.PROP_DESCRIPTION, "Forced change");
  }
  private boolean removeFavouriteSite(String userName, NodeRef nodeRef) {
    PrefKeys prefKeys = getPrefKeys(Type.SITE);
    boolean exists = false;

    SiteInfo siteInfo = siteService.getSite(nodeRef);
    if (siteInfo != null) {
      StringBuilder sitePrefKeyBuilder = new StringBuilder(prefKeys.getSharePrefKey());
      sitePrefKeyBuilder.append(siteInfo.getShortName());
      String sitePrefKey = sitePrefKeyBuilder.toString();

      String siteFavouritedKey = siteFavouritedKey(siteInfo);

      exists = preferenceService.getPreference(userName, siteFavouritedKey) != null;
      preferenceService.clearPreferences(userName, sitePrefKey);
    } else {
      throw new IllegalArgumentException("NodeRef " + nodeRef + " is not a site");
    }

    return exists;
  }
  private PersonFavourite getPersonFavourite(String userName, Type type, NodeRef nodeRef) {
    PersonFavourite ret = null;
    if (type.equals(Type.SITE)) {
      SiteInfo siteInfo = siteService.getSite(nodeRef);
      if (siteInfo != null) {
        ret = getFavouriteSite(userName, siteInfo);
      } else {
        // shouldn't happen, getType recognizes it as a site or subtype
        logger.warn("Unable to get site for " + nodeRef);
      }
    } else if (type.equals(Type.FILE)) {
      ret = getFavouriteDocumentOrFolder(userName, type, nodeRef);
    } else if (type.equals(Type.FOLDER)) {
      ret = getFavouriteDocumentOrFolder(userName, type, nodeRef);
    } else {
      // shouldn't happen
      throw new AlfrescoRuntimeException("Unexpected favourite type");
    }

    return ret;
  }
  private boolean isFavouriteSite(String userName, NodeRef nodeRef) {
    Boolean isFavourited = Boolean.FALSE;
    SiteInfo siteInfo = siteService.getSite(nodeRef);
    if (siteInfo != null) {
      String favouritedPrefKey = siteFavouritedKey(siteInfo);
      Serializable value = preferenceService.getPreference(userName, favouritedPrefKey);

      if (value != null) {
        if (value instanceof String) {
          isFavourited = Boolean.valueOf((String) value);
        } else if (value instanceof Boolean) {
          isFavourited = (Boolean) value;
        } else {
          throw new AlfrescoRuntimeException("Unexpected favourites preference value");
        }
      }
    } else {
      throw new IllegalArgumentException("NodeRef " + nodeRef + " is not a site");
    }

    return isFavourited.booleanValue();
  }
  private void extractFavouriteSite(
      String userName,
      Type type,
      Map<PersonFavouriteKey, PersonFavourite> sortedFavouriteNodes,
      Map<String, Serializable> preferences,
      String key) {
    // preference value indicates whether the site has been favourited
    Serializable pref = preferences.get(key);
    Boolean isFavourite = (Boolean) pref;
    if (isFavourite) {
      PrefKeys sitePrefKeys = getPrefKeys(Type.SITE);
      int length = sitePrefKeys.getSharePrefKey().length();
      String siteId = key.substring(length);

      try {
        SiteInfo siteInfo = siteService.getSite(siteId);
        if (siteInfo != null) {
          StringBuilder builder = new StringBuilder(sitePrefKeys.getAlfrescoPrefKey());
          builder.append(siteId);
          builder.append(".createdAt");
          String createdAtPrefKey = builder.toString();
          String createdAtStr = (String) preferences.get(createdAtPrefKey);
          Date createdAt = null;
          if (createdAtStr != null) {
            createdAt = (createdAtStr != null ? ISO8601DateFormat.parse(createdAtStr) : null);
          }
          PersonFavourite personFavourite =
              new PersonFavourite(userName, siteInfo.getNodeRef(), Type.SITE, siteId, createdAt);
          sortedFavouriteNodes.put(personFavourite.getKey(), personFavourite);
        }
      } catch (AccessDeniedException ex) {
        // the user no longer has access to this site, skip over the favourite
        // TODO remove the favourite preference
        return;
      }
    }
  }
  @Override
  public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {

    logger.debug("DEBUT Web Script CreateSiteWebScript");

    long startTime = System.currentTimeMillis();

    Map<String, Object> model = new HashMap<String, Object>();
    model.put("nomWebScript", "CreateSiteWebScript");

    if (!rulesExist()) {
      long endTime = System.currentTimeMillis();

      logger.debug("Rules on node Sites et Users not exist");

      model.put("statut", "Rules on node Sites et Users not exist");
      model.put("tempsExecution", endTime - startTime);

      logger.debug("FIN Web Script CreateSiteWebScript");

      return model;
    }

    SiteInfo site = siteService.getSite(NOM_SITE);

    String statut = null;

    if (null == site) {

      Integer result = null;
      try {
        result = createSite(login, password);
      } catch (HttpException e) {
        logger.error(e.getMessage());
      } catch (JSONException e) {
        logger.error(e.getMessage());
      } catch (IOException e) {
        logger.error(e.getMessage());
      }

      if (null != result && result.equals(HttpStatus.SC_OK)) {
        statut = "OK";
        logger.debug("Le site SIRH est bien créé.");

        alfrescoWsConsumer.addUser(
            alfrescoWsConsumer.getAlfTicket(login, password),
            loginSIRH,
            passwordSIRH,
            FIRST_NAME_ADMIN_SIRH,
            LAST_NAME_ADMIN_SIRH,
            EMAIL_ADMIN_SIRH,
            null,
            null,
            null);
      } else {
        statut = "KO";
        logger.debug("Un problème est survenu lors de la création du site SIRH.");
      }
    } else {
      statut = "Site déjà créé";
      logger.debug("Le site SIRH est déjà créé.");
    }

    long endTime = System.currentTimeMillis();

    model.put("statut", statut);
    model.put("tempsExecution", endTime - startTime);

    logger.debug("FIN Web Script CreateSiteWebScript");

    return model;
  }
예제 #17
0
  public void test_MNT11595() throws Exception {
    final String user = "******";

    try {
      // admin authentication
      this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());

      MutableAuthenticationService mas =
          (MutableAuthenticationService)
              getServer().getApplicationContext().getBean("authenticationService");

      // create user
      createUser(user, SiteModel.SITE_MANAGER);

      assertTrue(personService.personExists(user));

      // invite user to a site with 'Manager' role
      siteService.setMembership(SITE_SHORT_NAME_WIKI, user, SiteRole.SiteManager.toString());

      // user authentication
      this.authenticationComponent.setCurrentUser(user);

      // create wiki page by user ('Manager' role)
      WikiPageInfo wikiPage =
          this.wikiService.createWikiPage(
              SITE_SHORT_NAME_WIKI,
              "test wiki page",
              "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals. Sir Winston Churchill");

      String uri =
          "/slingshot/wiki/page/"
              + SITE_SHORT_NAME_WIKI
              + "/Main_Page?alf_ticket="
              + mas.getCurrentTicket()
              + "application/json";

      Response responseManagerRole = sendRequest(new GetRequest(uri), 404);
      JSONObject resultManagerRole = new JSONObject(responseManagerRole.getContentAsString());
      JSONObject permissionsManagerRole = resultManagerRole.getJSONObject("permissions");
      assertTrue(permissionsManagerRole.getBoolean("create"));
      assertTrue(permissionsManagerRole.getBoolean("edit"));

      // admin authentication
      this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());

      // change user role - 'Consumer' role
      siteService.setMembership(SITE_SHORT_NAME_WIKI, user, SiteRole.SiteConsumer.toString());

      // user authentication
      this.authenticationComponent.setCurrentUser(user);

      Response responseConsumerRole = sendRequest(new GetRequest(uri), 404);
      JSONObject resultConsumerRole = new JSONObject(responseConsumerRole.getContentAsString());
      JSONObject permissionsConsumerRole = resultConsumerRole.getJSONObject("permissions");
      assertFalse(permissionsConsumerRole.getBoolean("create"));
      assertFalse(permissionsConsumerRole.getBoolean("edit"));
    } finally {
      this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());

      if (personService.personExists(user)) {
        personService.deletePerson(user);
      }

      if (this.authenticationService.authenticationExists(user)) {
        this.authenticationService.deleteAuthentication(user);
      }
    }
  }
예제 #18
0
  /** Listing */
  public void testOverallListing() throws Exception {
    JSONObject pages;
    JSONArray entries;

    // Initially, there are no events
    pages = getPages(null, null);
    assertEquals("Incorrect JSON: " + pages.toString(), true, pages.has("totalPages"));
    assertEquals(0, pages.getInt("totalPages"));

    // Add two links to get started with
    createOrUpdatePage(PAGE_TITLE_ONE, PAGE_CONTENTS_ONE, null, Status.STATUS_OK);
    createOrUpdatePage(PAGE_TITLE_TWO, PAGE_CONTENTS_TWO, null, Status.STATUS_OK);

    // Check again
    pages = getPages(null, null);

    // Should have two links
    assertEquals("Incorrect JSON: " + pages.toString(), true, pages.has("totalPages"));
    assertEquals(2, pages.getInt("totalPages"));

    entries = pages.getJSONArray("pages");
    assertEquals(2, entries.length());
    // Sorted by newest created first
    assertEquals(PAGE_TITLE_TWO, entries.getJSONObject(0).getString("title"));
    assertEquals(PAGE_TITLE_ONE, entries.getJSONObject(1).getString("title"));

    // Add a third, which is internal, and created by the other user
    this.authenticationComponent.setCurrentUser(USER_TWO);
    JSONObject page3 =
        createOrUpdatePage(PAGE_TITLE_THREE, PAGE_CONTENTS_THREE, null, Status.STATUS_OK);
    String name3 = PAGE_TITLE_THREE.replace(' ', '_');
    createOrUpdatePage(PAGE_TITLE_THREE, "UD" + PAGE_CONTENTS_THREE, null, Status.STATUS_OK);
    this.authenticationComponent.setCurrentUser(USER_ONE);

    // Check now, should have three links
    pages = getPages(null, null);
    assertEquals(3, pages.getInt("totalPages"));

    entries = pages.getJSONArray("pages");
    assertEquals(3, entries.length());
    assertEquals(PAGE_TITLE_THREE, entries.getJSONObject(0).getString("title"));
    assertEquals(PAGE_TITLE_TWO, entries.getJSONObject(1).getString("title"));
    assertEquals(PAGE_TITLE_ONE, entries.getJSONObject(2).getString("title"));

    // Ask for filtering by user
    pages = getPages(null, USER_ONE);
    assertEquals(2, pages.getInt("totalPages"));

    entries = pages.getJSONArray("pages");
    assertEquals(2, entries.length());
    assertEquals(PAGE_TITLE_TWO, entries.getJSONObject(0).getString("title"));
    assertEquals(PAGE_TITLE_ONE, entries.getJSONObject(1).getString("title"));

    pages = getPages(null, USER_TWO);
    assertEquals(1, pages.getInt("totalPages"));

    entries = pages.getJSONArray("pages");
    assertEquals(1, entries.length());
    assertEquals(PAGE_TITLE_THREE, entries.getJSONObject(0).getString("title"));

    // Ask for filtering by recently added docs
    pages = getPages("recentlyAdded", null);
    assertEquals(3, pages.getInt("totalPages"));

    entries = pages.getJSONArray("pages");
    assertEquals(3, entries.length());
    assertEquals(PAGE_TITLE_THREE, entries.getJSONObject(0).getString("title"));
    assertEquals(PAGE_TITLE_TWO, entries.getJSONObject(1).getString("title"));
    assertEquals(PAGE_TITLE_ONE, entries.getJSONObject(2).getString("title"));

    // Push one back into the past
    pushPageCreatedDateBack(name3, 10);

    pages = getPages("recentlyAdded", null);
    assertEquals(2, pages.getInt("totalPages"));

    entries = pages.getJSONArray("pages");
    assertEquals(2, entries.length());
    assertEquals(PAGE_TITLE_TWO, entries.getJSONObject(0).getString("title"));
    assertEquals(PAGE_TITLE_ONE, entries.getJSONObject(1).getString("title"));

    // Now for recently modified ones
    pages = getPages("recentlyModified", null);
    assertEquals(3, pages.getInt("totalPages"));

    entries = pages.getJSONArray("pages");
    assertEquals(3, entries.length());
    assertEquals(PAGE_TITLE_THREE, entries.getJSONObject(0).getString("title"));
    assertEquals(PAGE_TITLE_TWO, entries.getJSONObject(1).getString("title"));
    assertEquals(PAGE_TITLE_ONE, entries.getJSONObject(2).getString("title"));
    //       assertEquals(PAGE_TITLE_THREE, entries.getJSONObject(2).getString("title"));

    // Change the owner+creator of one of the pages to System, ensure that
    //  this doesn't break anything in the process
    String pageTwoName = entries.getJSONObject(1).getString("name");
    WikiPageInfo pageTwo = wikiService.getWikiPage(SITE_SHORT_NAME_WIKI, pageTwoName);
    nodeService.setProperty(
        pageTwo.getNodeRef(), ContentModel.PROP_OWNER, AuthenticationUtil.SYSTEM_USER_NAME);
    nodeService.setProperty(
        pageTwo.getNodeRef(), ContentModel.PROP_CREATOR, AuthenticationUtil.SYSTEM_USER_NAME);
    nodeService.setProperty(
        pageTwo.getNodeRef(), ContentModel.PROP_MODIFIER, AuthenticationUtil.SYSTEM_USER_NAME);

    // Check the listing still works (note - order will have changed)
    pages = getPages("recentlyModified", null);
    assertEquals(3, pages.getInt("totalPages"));

    entries = pages.getJSONArray("pages");
    assertEquals(3, entries.length());
    assertEquals(PAGE_TITLE_TWO, entries.getJSONObject(0).getString("title"));
    assertEquals(PAGE_TITLE_THREE, entries.getJSONObject(1).getString("title"));
    assertEquals(PAGE_TITLE_ONE, entries.getJSONObject(2).getString("title"));

    // Delete User Two, who owns the 3rd page, and ensure that this
    //  doesn't break anything
    this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
    personService.deletePerson(USER_TWO);
    this.authenticationComponent.setCurrentUser(USER_ONE);

    // Check the listing still works
    pages = getPages("recentlyModified", null);
    assertEquals(3, pages.getInt("totalPages"));

    entries = pages.getJSONArray("pages");
    assertEquals(3, entries.length());
    assertEquals(PAGE_TITLE_TWO, entries.getJSONObject(0).getString("title"));
    assertEquals(PAGE_TITLE_THREE, entries.getJSONObject(1).getString("title"));
    assertEquals(PAGE_TITLE_ONE, entries.getJSONObject(2).getString("title"));

    // Now hide the site, and remove the user from it, won't be allowed to see it
    this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
    SiteInfo site = siteService.getSite(SITE_SHORT_NAME_WIKI);
    site.setVisibility(SiteVisibility.PRIVATE);
    siteService.updateSite(site);
    siteService.removeMembership(SITE_SHORT_NAME_WIKI, USER_ONE);
    this.authenticationComponent.setCurrentUser(USER_ONE);

    sendRequest(new GetRequest(URL_WIKI_LIST), Status.STATUS_NOT_FOUND);
  }