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


Java ConversationState类代码示例

本文整理汇总了Java中org.exoplatform.services.security.ConversationState的典型用法代码示例。如果您正苦于以下问题:Java ConversationState类的具体用法?Java ConversationState怎么用?Java ConversationState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: generateActivity

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
private void generateActivity() throws Exception {
	// Get current user and assign to ownerStream
	String username = ConversationState.getCurrent().getIdentity().getUserId();
	IdentityManager identityM =
	(IdentityManager) PortalContainer.getInstance().getComponentInstanceOfType(IdentityManager.class);
	Identity userIdentity = identityM.getOrCreateIdentity(OrganizationIdentityProvider.NAME, username, false);
	Identity ownerStream = userIdentity;
	// New activity
	ExoSocialActivityImpl activity = new ExoSocialActivityImpl();
	activity.setUserId(userIdentity.getId());
	activity.setTitle("This is an activity of type <b>" + ACTIVITY_TYPE + "</b>.");
	activity.setBody("This is for testing");
	activity.setType(ACTIVITY_TYPE);
	// Save activity
	ActivityManager activityM =
	(ActivityManager) PortalContainer.getInstance().getComponentInstanceOfType(ActivityManager.class);
	activityM.saveActivityNoReturn(ownerStream, activity);
}
 
开发者ID:exo-samples,项目名称:docs-samples,代码行数:19,代码来源:GenerateActivity4Testing.java

示例2: synchronizeFolderWithExo

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
@GET
@RolesAllowed("users")
@Path("/sync")
public Response synchronizeFolderWithExo(@QueryParam("folderId") String folderIdString) throws Exception {
  if (folderIdString == null || folderIdString.isEmpty()) {
    LOG.warn("folderId parameter is null while synchronizing.");
    return Response.noContent().build();
  }
  // It must be a user present in the session because of RolesAllowed
  // annotation
  String username = ConversationState.getCurrent().getIdentity().getUserId();
  IntegrationService service = IntegrationService.getInstance(username);
  service.addFolderToSynchronization(folderIdString);
  integrationListener.synchronize(username);
  return Response.ok().build();
}
 
开发者ID:exo-addons,项目名称:exchange-extension,代码行数:17,代码来源:ExchangeRESTService.java

示例3: unsynchronizeFolderWithExo

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
@GET
@RolesAllowed("users")
@Path("/unsync")
public Response unsynchronizeFolderWithExo(@QueryParam("folderId") String folderIdString) throws Exception {
  if (folderIdString == null || folderIdString.isEmpty()) {
    LOG.warn("folderId parameter is null while unsynchronizing");
    return Response.noContent().build();
  }
  // It must be a user present in the session because of RolesAllowed
  // annotation
  String username = ConversationState.getCurrent().getIdentity().getUserId();
  IntegrationService service = IntegrationService.getInstance(username);
  service.deleteFolderFromSynchronization(folderIdString);
  integrationListener.synchronize(username);
  return Response.ok().build();
}
 
开发者ID:exo-addons,项目名称:exchange-extension,代码行数:17,代码来源:ExchangeRESTService.java

示例4: getSettings

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
@GET
@RolesAllowed("users")
@Path("/settings")
@Produces(MediaType.APPLICATION_JSON)
public Response getSettings() throws Exception {
  try {
    String username = ConversationState.getCurrent().getIdentity().getUserId();

    UserSettings settings = new UserSettings();

    String exchangeServerName = IntegrationService.getUserArrtibute(organizationService, username, IntegrationService.USER_EXCHANGE_SERVER_URL_ATTRIBUTE);
    String exchangeDomainName = IntegrationService.getUserArrtibute(organizationService, username, IntegrationService.USER_EXCHANGE_SERVER_DOMAIN_ATTRIBUTE);
    String exchangeUsername = IntegrationService.getUserArrtibute(organizationService, username, IntegrationService.USER_EXCHANGE_USERNAME_ATTRIBUTE);

    settings.setServerName(exchangeServerName == null ? integrationListener.exchangeServerURL : exchangeServerName);
    settings.setDomainName(exchangeDomainName == null ? integrationListener.exchangeDomain : exchangeDomainName);
    settings.setUsername(exchangeUsername == null ? username : exchangeUsername);

    return Response.ok(settings, MediaType.APPLICATION_JSON).cacheControl(cc).build();
  } catch (Exception e) {
    return Response.status(HTTPStatus.INTERNAL_ERROR).cacheControl(cc).build();
  }
}
 
开发者ID:exo-addons,项目名称:exchange-extension,代码行数:24,代码来源:ExchangeRESTService.java

示例5: setSettings

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
@POST
@RolesAllowed("users")
@Path("/settings")
@Consumes(MediaType.APPLICATION_JSON)
public Response setSettings(UserSettings settings) throws Exception {
  try {
    String username = ConversationState.getCurrent().getIdentity().getUserId();

    IntegrationService.setUserArrtibute(organizationService, username, IntegrationService.USER_EXCHANGE_SERVER_URL_ATTRIBUTE, settings.getServerName());
    IntegrationService.setUserArrtibute(organizationService, username, IntegrationService.USER_EXCHANGE_SERVER_DOMAIN_ATTRIBUTE, settings.getDomainName());
    IntegrationService.setUserArrtibute(organizationService, username, IntegrationService.USER_EXCHANGE_USERNAME_ATTRIBUTE, settings.getUsername());
    IntegrationService.setUserArrtibute(organizationService, username, IntegrationService.USER_EXCHANGE_PASSWORD_ATTRIBUTE, settings.getPassword());

    integrationListener.userLoggedOut(username);
    integrationListener.startExchangeSynchronizationTask(username, settings.getUsername(), settings.getPassword(), settings.getDomainName(), settings.getServerName());

    return Response.ok().cacheControl(cc).build();
  } catch (Exception e) {
    return Response.status(HTTPStatus.INTERNAL_ERROR).cacheControl(cc).build();
  }
}
 
开发者ID:exo-addons,项目名称:exchange-extension,代码行数:22,代码来源:ExchangeRESTService.java

示例6: UserBean

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
public UserBean() {
  IdentityManager identityManager = (IdentityManager) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(IdentityManager.class);
  String currentUserId = ConversationState.getCurrent().getIdentity().getUserId();
  Identity currentIdentity = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, currentUserId, false);
  Profile profile = currentIdentity.getProfile();
  userEmail = profile.getEmail();
}
 
开发者ID:exo-samples,项目名称:docs-samples,代码行数:8,代码来源:UserBean.java

示例7: getCurrentUser

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
private String getCurrentUser() {
  ConversationState conversationState = ConversationState.getCurrent();
  if (conversationState == null) {
    throw new IllegalStateException("No Identity found: ConversationState.getCurrent() is null");
  }
  if (ConversationState.getCurrent().getIdentity()==null) {
    throw new IllegalStateException("No Identity found: ConversationState.getCurrent().getIdentity() is null");
  }
  return ConversationState.getCurrent().getIdentity().getUserId();
}
 
开发者ID:exo-archives,项目名称:exo-es-search,代码行数:11,代码来源:ElasticSearchServiceConnector.java

示例8: getUserMemberships

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
private Set<String> getUserMemberships() {
  ConversationState conversationState = ConversationState.getCurrent();
  if (conversationState == null) {
    throw new IllegalStateException("No Identity found: ConversationState.getCurrent() is null");
  }
  if (ConversationState.getCurrent().getIdentity()==null) {
    throw new IllegalStateException("No Identity found: ConversationState.getCurrent().getIdentity() is null");
  }
  if (ConversationState.getCurrent().getIdentity().getMemberships()==null) {
    //This case is not supported
    //The doc says "Any anonymous user automatically becomes a member of the group guests.group when they enter the public pages."
    //http://docs.exoplatform.com/PLF42/sect-Reference_Guide-Portal_Default_Permission_Configuration.html
    throw new IllegalStateException("No Membership found: ConversationState.getCurrent().getIdentity().getMemberships() is null");
  }

  Set<String> entries = new HashSet<>();
  for (MembershipEntry entry : ConversationState.getCurrent().getIdentity().getMemberships()) {
    //If it's a wildcard membership, add a point to transform it to regexp
    if (entry.getMembershipType().equals(MembershipEntry.ANY_TYPE)) {
      entries.add(entry.toString().replace("*", ".*"));
    }
    //If it's not a wildcard membership
    else {
      //Add the membership
      entries.add(entry.toString());
      //Also add a wildcard membership (not as a regexp) in order to match to wildcard permission
      //Ex: membership dev:/pub must match permission dev:/pub and permission *:/pub
      entries.add("*:"+entry.getGroup());
    }
  }
  return entries;
}
 
开发者ID:exo-archives,项目名称:exo-es-search,代码行数:33,代码来源:ElasticSearchServiceConnector.java

示例9: setCurrentIdentity

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
private void setCurrentIdentity(String userId, String... memberships) {
  Set<MembershipEntry> membershipEntrySet = new HashSet<>();
  if (memberships != null) {
    for (String membership : memberships) {
      String[] membershipSplit = membership.split(":");
      membershipEntrySet.add(new MembershipEntry(membershipSplit[1], membershipSplit[0]));
    }
  }
  ConversationState.setCurrent(new ConversationState(new Identity(userId, membershipEntrySet)));
}
 
开发者ID:exo-archives,项目名称:exo-es-search,代码行数:11,代码来源:PermissionsFilterIntTest.java

示例10: setCurrentIdentity

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
private void setCurrentIdentity(String userId, String... memberships) {
  Set<MembershipEntry> membershipEntrySet = new HashSet<>();
  if (memberships!=null) {
    for (String membership : memberships) {
      String[] membershipSplit = membership.split(":");
      membershipEntrySet.add(new MembershipEntry(membershipSplit[1], membershipSplit[0]));
    }
  }
  ConversationState.setCurrent(new ConversationState(new Identity(userId, membershipEntrySet)));
}
 
开发者ID:exo-archives,项目名称:exo-es-search,代码行数:11,代码来源:SiteFilterIntTest.java

示例11: initServices

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
@Before
public void initServices() {
  super.setup();

  Identity identity = new Identity("TCL", Collections.singletonList(new MembershipEntry("BasketballPlayer")));
  ConversationState.setCurrent(new ConversationState(identity));
  elasticSearchServiceConnector = new ElasticSearchServiceConnector(getInitConnectorParams(), elasticSearchingClient);
}
 
开发者ID:exo-archives,项目名称:exo-es-search,代码行数:9,代码来源:ElasticIndexingAttachmentIntegrationTest.java

示例12: testSearchWithoutIdentity

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testSearchWithoutIdentity() {
    //Given
    ConversationState.setCurrent(null);
    ElasticSearchServiceConnector connector = new ElasticSearchServiceConnector(getInitParams(), elasticSearchingClient);
    //When
    connector.buildQuery("My Wiki", null, 0, 20, null, null);
    //Then
    fail("IllegalStateException 'No identity found' expected");
}
 
开发者ID:exo-archives,项目名称:exo-es-search,代码行数:11,代码来源:ElasticSearchServiceConnectorTest.java

示例13: onEvent

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
@Override
public void onEvent(Event<ConversationRegistry, ConversationState> event) throws Exception {
  String username = event.getData().getIdentity().getUserId();
  if (StringUtils.isNotEmpty(username) && !username.equals(IdentityConstants.ANONIM)) {
    getExchangeListenerService().userLoggedIn(username, null);
  }
}
 
开发者ID:exo-addons,项目名称:exchange-extension,代码行数:8,代码来源:ExchangeLoginListener.java

示例14: getCalendars

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
@GET
@RolesAllowed("users")
@Path("/calendars")
@Produces({ MediaType.APPLICATION_JSON })
public Response getCalendars() throws Exception {
  // It must be a user present in the session because of RolesAllowed
  // annotation
  String username = ConversationState.getCurrent().getIdentity().getUserId();
  try {
    List<FolderBean> beans = new ArrayList<FolderBean>();

    IntegrationService service = IntegrationService.getInstance(username);
    if (service != null) {
      List<FolderId> folderIDs = service.getAllExchangeCalendars();
      for (FolderId folderId : folderIDs) {
        Folder folder = service.getExchangeCalendar(folderId);
        if (folder != null) {
          boolean synchronizedFolder = service.isCalendarSynchronizedWithExchange(folderId.getUniqueId());
          FolderBean bean = new FolderBean(folderId.getUniqueId(), folder.getDisplayName(), synchronizedFolder);
          beans.add(bean);
        }
      }
    }
    return Response.ok(beans).cacheControl(cc).build();
  } catch (Exception e) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Exchange Inegration Service: Unable to retrieve list of calendars for user: '" + username + "'");
    }
    return Response.ok().cacheControl(cc).build();
  }
}
 
开发者ID:exo-addons,项目名称:exchange-extension,代码行数:32,代码来源:ExchangeRESTService.java

示例15: synchronizeNow

import org.exoplatform.services.security.ConversationState; //导入依赖的package包/类
@GET
@RolesAllowed("users")
@Path("/syncNow")
public Response synchronizeNow() throws Exception {
  // It must be a user present in the session because of RolesAllowed
  // annotation
  String username = ConversationState.getCurrent().getIdentity().getUserId();
  integrationListener.synchronize(username);
  return Response.ok().build();
}
 
开发者ID:exo-addons,项目名称:exchange-extension,代码行数:11,代码来源:ExchangeRESTService.java


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