示例#1
0
 private Scope getDefaultSearchScope() {
   log.debug("setting default scope!");
   String siteId = toolManager.getCurrentPlacement().getContext();
   if (siteService.isUserSite(siteId)) {
     log.debug("got scope of Mine");
     return Scope.MINE;
   } else {
     log.debug("got scope of Site");
     return Scope.SITE;
   }
 }
示例#2
0
  public static boolean isUserSite(java.lang.String param0) {
    org.sakaiproject.site.api.SiteService service = getInstance();
    if (service == null) return false;

    return service.isUserSite(param0);
  }
示例#3
0
  // run this before each test starts
  protected void onSetUpBeforeTransaction() throws Exception {
    // Time
    /*long oneMonthAgoMs = new Date().getTime() - (30 * 24 * 60 * 60 * 1000);
    long twoMonthAgoMs = new Date().getTime() - (2 * 30 * 24 * 60 * 60 * 1000);
    Time timeA = createMock(Time.class);
    expect(timeA.getTime()).andReturn(oneMonthAgoMs).anyTimes();
    replay(timeA);
    Time timeB = createMock(Time.class);
    expect(timeB.getTime()).andReturn(twoMonthAgoMs).anyTimes();
    replay(timeB);*/

    // Site Service
    M_ss = createMock(SiteService.class);

    // null site
    expect(M_ss.getSite(null)).andThrow(new IdUnusedException("null")).anyTimes();
    expect(M_ss.getSite("non_existent_site"))
        .andThrow(new IdUnusedException("non_existent_site"))
        .anyTimes();

    // My Workspace - user sites
    FakeSite userSiteA = new FakeSite("~" + FakeData.USER_A_ID);
    FakeSite userSiteB = new FakeSite("~" + FakeData.USER_B_ID);
    expect(M_ss.getSiteUserId(FakeData.USER_A_ID)).andStubReturn("~" + FakeData.USER_A_ID);
    expect(M_ss.getSiteUserId(FakeData.USER_B_ID)).andStubReturn("~" + FakeData.USER_B_ID);
    expect(M_ss.getSiteUserId("no_user")).andStubReturn(null);
    expect(M_ss.getSite("~" + FakeData.USER_A_ID)).andStubReturn(userSiteA);
    expect(M_ss.getSite("~" + FakeData.USER_B_ID)).andStubReturn(userSiteB);

    // Site A has tools {SiteStats, Chat, Resources}, has {user-a,user-b}, created 1 month ago
    Site siteA =
        new FakeSite(
            FakeData.SITE_A_ID,
            Arrays.asList(
                StatsManager.SITESTATS_TOOLID, FakeData.TOOL_CHAT, StatsManager.RESOURCES_TOOLID));
    ((FakeSite) siteA)
        .setUsers(new HashSet<String>(Arrays.asList(FakeData.USER_A_ID, FakeData.USER_B_ID)));
    ((FakeSite) siteA)
        .setMembers(new HashSet<String>(Arrays.asList(FakeData.USER_A_ID, FakeData.USER_B_ID)));
    expect(M_ss.getSite(FakeData.SITE_A_ID)).andStubReturn(siteA);
    expect(M_ss.isUserSite(FakeData.SITE_A_ID)).andStubReturn(false);
    expect(M_ss.isSpecialSite(FakeData.SITE_A_ID)).andStubReturn(false);

    // Site B has tools {TOOL_CHAT}, has {user-a}, created 2 months ago
    FakeSite siteB = new FakeSite(FakeData.SITE_B_ID, FakeData.TOOL_CHAT);
    ((FakeSite) siteB).setUsers(new HashSet<String>(Arrays.asList(FakeData.USER_A_ID)));
    ((FakeSite) siteB).setMembers(new HashSet<String>(Arrays.asList(FakeData.USER_A_ID)));
    expect(M_ss.getSite(FakeData.SITE_B_ID)).andStubReturn(siteB);
    expect(M_ss.isUserSite(FakeData.SITE_B_ID)).andStubReturn(false);
    expect(M_ss.isSpecialSite(FakeData.SITE_B_ID)).andStubReturn(false);

    // Site 'non_existent_site' doesn't exist
    expect(M_ss.isUserSite("non_existent_site")).andStubReturn(false);
    expect(M_ss.isSpecialSite("non_existent_site")).andStubReturn(false);

    // Content Hosting Service
    //		M_chs = createMock(ContentHostingService.class);
    //		M_chs.checkCollection("/group/site-a-id/folder/");
    //		expectLastCall().anyTimes();
    //		M_chs.checkResource("/group-user/site-a-id/user-a/resource1");
    //		expectLastCall().anyTimes();

    ResourceLoader msgs = createMock(ResourceLoader.class);
    expect(msgs.getString((String) anyObject()))
        .andStubAnswer(
            new IAnswer<String>() {
              public String answer() throws Throwable {
                return (String) getCurrentArguments()[0];
              }
            });

    // apply
    replay(M_ss);
    // replay(M_chs);
    replay(msgs);
    ((FakeEventRegistryService) M_ers).setSiteService(M_ss);
    ((FakeEventRegistryService) M_ers).setToolManager(M_tm);
    ((FakeEventRegistryService) M_ers).setStatsManager(M_sm);
    ((ReportManagerImpl) M_rm).setEventRegistryService(M_ers);
    ((StatsManagerImpl) M_sm).setSiteService(M_ss);
    // ((StatsManagerImpl)M_sm).setContentHostingService(M_chs);
    ((StatsManagerImpl) M_sm).setResourceLoader(msgs);
    ((StatsManagerImpl) M_sm).setEnableSitePresences(true);
    ((ReportManagerImpl) M_rm).setResourceLoader(msgs);
    ((StatsUpdateManagerImpl) M_sum).setSiteService(M_ss);
    ((StatsUpdateManagerImpl) M_sum).setStatsManager(M_sm);
  }