当前位置: 首页>>代码示例>>Java>>正文


Java SessionManager.getCurrentSession方法代码示例

本文整理汇总了Java中org.sakaiproject.tool.api.SessionManager.getCurrentSession方法的典型用法代码示例。如果您正苦于以下问题:Java SessionManager.getCurrentSession方法的具体用法?Java SessionManager.getCurrentSession怎么用?Java SessionManager.getCurrentSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sakaiproject.tool.api.SessionManager的用法示例。


在下文中一共展示了SessionManager.getCurrentSession方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception
{
	String runAs = "admin";
	voter = (ResourceEventVoter) getService(ResourceEventVoter.class.getName());
	helper = (ResourceEventVoterHelper) getService(ResourceEventVoterHelper.class.getName());
	chs = (ContentHostingService) getService(ContentHostingService.class.getName());
	timeService = (TimeService) getService(TimeService.class.getName());
	usageSessionService = (UsageSessionService) getService(UsageSessionService.class.getName());
	usageSessionService.startSession(runAs, "localhost", "resourceVoter-integrationTest");

	sessionManager = (SessionManager) getService("org.sakaiproject.tool.api.SessionManager");
	session = sessionManager.getCurrentSession();
	session.setUserEid(runAs);
	session.setUserId(runAs);

	event = new ResourceEventVoterHelper.ReEvent("content.revise", true, 1,
			"/content/group/5c5fdcef-dbb2-415b-9714-b031e4e18bb8/quotes.txt", null);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:20,代码来源:TestResourceEventVoter.java

示例2: actAsUserEid

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
/**
 * Convenience method to switch authn/authz identities.
 * TODO Move this frequently-needed helper logic into the base class.
 *
 * @param userEid
 */
public void actAsUserEid(String userEid) {
	if (log.isDebugEnabled()) log.debug("actAsUserEid=" + userEid);
	
	SessionManager sessionManager = getService(SessionManager.class);
	
	String userId;
	try {
		userId = userDirectoryService.getUserId(userEid);
	} catch (UserNotDefinedException e) {
		log.error("Could not act as user EID=" + userEid, e);
		return;
	}
	Session session = sessionManager.getCurrentSession();
	session.setUserEid(userEid);
	session.setUserId(userId);
	authzGroupService.refreshUser(userId);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:24,代码来源:ContextualDisplayServiceTest.java

示例3: testVirusFound

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
/**
    * Checks the resources of zero bytes are handled correctly.
    */
@Test
   public void testVirusFound() throws Exception {
       ContentHostingService ch = getService(ContentHostingService.class);
       SessionManager sm = getService(SessionManager.class);
       Session session = sm.getCurrentSession();
       session.setUserEid("admin");
       session.setUserId("admin");
       ContentResourceEdit cr;
       cr = ch.addResource("/fileStream1");
       cr.setContent(new ByteArrayInputStream("test".getBytes()));
       ch.commitResource(cr);


       BaseContentService bchs = (BaseContentService)ch;
       bchs.processVirusQueue();

       try {
           ch.getResource("/fileStream1");
       } catch (IdUnusedException e) {
           Assert.assertTrue("file not found, this is expected because a virus was detected", true);
           return;
       }
       Assert.assertTrue("the file was found, this is not expected, since a virus was found it should have been removed", false);
   }
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:28,代码来源:VirusScannerTest.java

示例4: testDeleteResource

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
@Test
public void testDeleteResource() throws Exception {
    ContentHostingService ch = getService(ContentHostingService.class);
    SessionManager sm = getService(SessionManager.class);
    Session session = sm.getCurrentSession();
    session.setUserId("admin");
    session.setUserEid("admin");

    // Create a file
    String filename = "/"+ UUID.randomUUID().toString();
    ContentResourceEdit resource = ch.addResource(filename);
    resource.setContent("Hello World".getBytes());
    ch.commitResource(resource);

    // Delete the file (into the recycle bin)
    ch.removeResource(filename);
    ch.restoreResource(filename);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:19,代码来源:ContentHostingServiceRecycleTest.java

示例5: setUp

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
@Before
public void setUp() throws IdUsedException, IdInvalidException, InconsistentException, PermissionException, IdUnusedException {
    _chs = (ContentHostingService)getService(ContentHostingService.class.getName());
    _ags = (AuthzGroupService)getService(AuthzGroupService.class.getName());

    SessionManager sm = (SessionManager)getService(SessionManager.class.getName());
    Session session = sm.getCurrentSession();
    session.setUserEid("admin");
    session.setUserId("admin");

    _ss = (SiteService)getService(SiteService.class.getName());
    Site newSite = _ss.addSite(SITE_ID, (String) null);
    Group group = newSite.addGroup();
    group.setTitle(".group");
    _groupReference = group.getReference();
    _ss.save(newSite);

    collectionEdit = _chs.addCollection(IMAGES_COLLECTION);
    _chs.commitCollection(collectionEdit);

    collectionEdit = _chs.addCollection(PHOTOS_COLLECTION);
    _chs.commitCollection(collectionEdit);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:24,代码来源:RoleAccessTest.java

示例6: setUp

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
/**
 * Setup test fixture (runs once for each test method called)
 */
public void setUp() throws Exception {
	// Fetch the services we need to run the tests
	siteService = (SiteService)getService(SiteService.class.getName());
	sessionManager = (SessionManager)getService(SessionManager.class.getName());
	sectionManager = (SectionManager)getService(SectionManager.class.getName());

	Session session = sessionManager.getCurrentSession();
	session.setUserId("admin");
	session.setUserEid("admin");
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:14,代码来源:CourseManagementIntegrationTest.java

示例7: setUp

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
/**
 * Setup test fixture (runs once for each test method called)
 */
public void setUp() throws Exception {
	// Fetch the services we need to run the tests
	sectionAwareness = (SectionAwareness)getService(SectionAwareness.class.getName());
	siteService = (SiteService)getService(SiteService.class.getName());
	userDirService = (UserDirectoryService)getService(UserDirectoryService.class.getName());
	sessionManager = (SessionManager)getService(SessionManager.class.getName());

	Session session = sessionManager.getCurrentSession();
	session.setUserId("admin");
	session.setUserEid("admin");

	// Create some users
	userDirService.addUser("test.user.a", "test.user.a", "Jane", "Doe", "[email protected]", "123", null, null);
	userDirService.addUser("test.user.b", "test.user.b", "Joe", "Schmoe", "[email protected]", "123", null, null);

	// Create a site
	site = siteService.addSite(generateSiteId(), "course");
	
	// Create a group for SectionAwareness to, er, become aware of
	group1 = site.addGroup();
	group1.setTitle(GROUP1_TITLE);
			
	// Save the group
	siteService.save(site);
	
	site.addMember("test.user.a", "Student", true, false);

	// Save the site and its new member
	siteService.save(site);

	// Add a user to a group
	group1.addMember("test.user.a", "Student", true, false);
	
	// Save the group with its new member
	siteService.saveGroupMembership(site);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:40,代码来源:SectionAwarenessImplTest.java

示例8: commit

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
/**
 * @inheritDoc
 */
public void commit(PreferencesEdit edit)
{
	if (edit != null)
	{
		// check for closed edit
		if (!edit.isActiveEdit())
		{
			try
			{
				throw new Exception();
			}
			catch (Exception e)
			{
				log.warn("commit(): closed PreferencesEdit", e);
			}
			return;
		}

		// update the properties
		// addLiveUpdateProperties(user.getPropertiesEdit());
		
		//invalidate the cache
		m_cache.remove(edit.getId());
			
		// complete the edit
		m_storage.commit(edit);
	
		SessionManager sManager = sessionManager();
		Session s = sManager.getCurrentSession();
	
		// track it
		eventTrackingService()
				.post(eventTrackingService().newEvent(((BasePreferences) edit).getEvent(), edit.getReference(), true));

		// close the edit object
		((BasePreferences) edit).closeEdit();
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:42,代码来源:BasePreferencesService.java

示例9: testJoinableSiteSQL

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
@Test
public void testJoinableSiteSQL() throws Exception {
	// This test came about through KNL-1294 and was written to test that joinable sites search worked
	// when also supplying a map of properties to search for.
	SessionManager sessionManager = getService(SessionManager.class);
	SiteService siteService = getService(SiteService.class);

	Session session = sessionManager.getCurrentSession();
	session.setUserEid("admin");
	session.setUserId("admin");

	// Use a random UUID for type so database state can't break the test.
	String type = UUID.randomUUID().toString();
	Site site = siteService.addSite(UUID.randomUUID().toString(), type);
	site.setJoinable(true);
	site.setJoinerRole("access");
	site.setPublished(true);
	site.setTitle("Site");
	site.getPropertiesEdit().addProperty("key", "value");
	siteService.save(site);

	Map stringMap = Collections.singletonMap("key", "value");

	// Need to switch user so we're not a member of the site.
	session.setUserEid("someuser");
	session.setUserId("someuser");
	List<Site> sites;
	// First test search for any with properties.
	sites = siteService.getSites(SelectionType.ANY, type, null, stringMap, SiteService.SortType.TITLE_ASC, null);
	Assert.assertEquals(1, sites.size());
	// Then test that it's joinable with properties
	sites = siteService.getSites(SelectionType.JOINABLE, type, null, stringMap, SiteService.SortType.TITLE_ASC, null);
	Assert.assertEquals(1, sites.size());
	// Then test that it's joinable and with criteria
	sites = siteService.getSites(SelectionType.JOINABLE, type, "Site", null, SiteService.SortType.TITLE_ASC, null);
	Assert.assertEquals(1, sites.size());
	// Then test that it's joinable and with criteria and properties
	sites = siteService.getSites(SelectionType.JOINABLE, type, "Site", stringMap, SiteService.SortType.TITLE_ASC, null);
	Assert.assertEquals(1, sites.size());
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:41,代码来源:SiteSearchTest.java

示例10: startSession

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
private void startSession() {
	UsageSessionService usageSessionService = getService(UsageSessionService.class);
	usageSessionService.startSession("admin", "localhost", "integration-tests");
	SessionManager sessionManager = getService(SessionManager.class);
	session = sessionManager.getCurrentSession();
	session.setUserEid("admin");
	session.setUserId("admin");
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:9,代码来源:SiteAliasCleanupNotificationActionIntegrationTest.java

示例11: reset

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
/**
 * Clear out any threadlocals and reset the session to be admin.
 * @param tl ThreadLocalManager service.
 * @param sm SessionManager service.
 */
private void reset(ThreadLocalManager tl, SessionManager sm) {
    tl.clear();
    Session session = sm.getCurrentSession();
    session.setUserId("admin");
    session.setUserEid("admin");
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:12,代码来源:ContentHostingServiceRecycleTest.java

示例12: testEmptyResources

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
/**
 * Checks the resources of zero bytes are handled correctly.
 */
@Test
public void testEmptyResources() throws Exception {
	ContentHostingService ch = getService(ContentHostingService.class);
	SessionManager sm = getService(SessionManager.class);
	Session session = sm.getCurrentSession();
	session.setUserEid("admin");
	session.setUserId("admin");
	ContentResourceEdit cr;
	cr = ch.addResource("/emptyFileStreamed");
	cr.setContent(new ByteArrayInputStream(new byte[0]));
	ch.commitResource(cr);
	
	cr = ch.addResource("/emptyFileArray");
	cr.setContent(new byte[0]);
	ch.commitResource(cr);
	
	ContentResource resource;
	InputStream stream;
	resource = ch.getResource("/emptyFileStreamed");
	stream = resource.streamContent();
	Assert.assertEquals(0, stream.available());
	Assert.assertEquals(0, resource.getContentLength());
	Assert.assertEquals(0, resource.getContent().length);
	
	resource = ch.getResource("/emptyFileArray");
	stream = resource.streamContent();
	Assert.assertEquals(0, stream.available());
	Assert.assertEquals(0, resource.getContentLength());
	Assert.assertEquals(0, resource.getContent().length);
	
	
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:36,代码来源:ContentHostingServiceTest.java

示例13: testDeleteResource

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
@Test
public void testDeleteResource() {
	ContentHostingService ch = getService(ContentHostingService.class);
	SessionManager sm = getService(SessionManager.class);
	Session session = sm.getCurrentSession();
	session.setUserEid("admin");
	session.setUserId("admin");
	try {
		ch.removeResource("noSuchResource");
		Assert.fail();
	} catch (Exception e) {
		Assert.assertTrue(e instanceof IdUnusedException);
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:15,代码来源:ContentHostingServiceTest.java

示例14: setUp

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
@Before
public void setUp() throws IdUsedException, IdInvalidException, InconsistentException, PermissionException {
    _chs = (ContentHostingService)getService(ContentHostingService.class.getName());
    _ags = (AuthzGroupService)getService(AuthzGroupService.class.getName());

    SessionManager sm = (SessionManager)getService(SessionManager.class.getName());
    Session session = sm.getCurrentSession();
    session.setUserEid("admin");
    session.setUserId("admin");
    ContentCollectionEdit collectionEdit = _chs.addCollection(PHOTOS_COLLECTION);
    _chs.commitCollection(collectionEdit);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:13,代码来源:RoleViewTest.java

示例15: init

import org.sakaiproject.tool.api.SessionManager; //导入方法依赖的package包/类
public void init()
{
	securityService = (RWikiSecurityService) context
			.getBean(RWikiSecurityService.class.getName());
	objectService = (RWikiObjectService) context
			.getBean(RWikiObjectService.class.getName());
	toolRenderService = (ToolRenderService) context
			.getBean(ToolRenderService.class.getName());
	populateService = (PopulateService) context
			.getBean(PopulateService.class.getName());
	realmService = (AuthzGroupService) context
			.getBean(AuthzGroupService.class.getName());
	preferenceService = (PreferenceService) context
			.getBean(PreferenceService.class.getName());

	toolManager = (ToolManager) context
			.getBean(ToolManager.class.getName());

	sessionManager = (SessionManager) context.getBean(SessionManager.class
			.getName());
	siteService = (SiteService) context
			.getBean(SiteService.class.getName());


	messageService = (MessageService) context.getBean(MessageService.class
			.getName());

	experimental = ServerConfigurationService.getBoolean(
			"wiki.experimental", false);

	searchExperimental  = ServerConfigurationService.getBoolean(
			  "wiki.fullsearch", true) && 
			  ServerConfigurationService.getBoolean("search.enable", false);

	withnotification = ServerConfigurationService.getBoolean(
			"wiki.notification", true);
	withcomments = ServerConfigurationService.getBoolean("wiki.comments",
			true);
	defaultUIHomePageName = ServerConfigurationService.getString(
			"wiki.ui.homepage", "Home");
	
	if ( searchExperimental ) {
		searchService = (SearchService) context.getBean(SearchService.class
			.getName());
	}
	
	// if the message service has been configured
	// update the presence
	if (messageService != null)
	{
		Session session = sessionManager.getCurrentSession();

		String userId = this.getCurrentUserId();
		if (userId != null && userId.length() > 0)
		{
			String currentPageName = this.getCurrentPageName();
			String pageSpace = this.getCurrentPageSpace();
			if ( currentPageName != null && currentPageName.length() < 255 && pageSpace != null && pageSpace.length() < 255 ) {
				messageService.updatePresence(session.getId(), userId, this.getCurrentPageName(), this
						.getCurrentPageSpace());
			} else {
				log.warn("Page names in wiki cannot be over 225 characters in length, presence not updated. Page Name was "+currentPageName);
			}
		}
	}
	

}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:69,代码来源:RequestScopeSuperBean.java


注:本文中的org.sakaiproject.tool.api.SessionManager.getCurrentSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。