use of org.exoplatform.container.ExoContainerContext in project social by Meeds-io.
the class SpaceSearchConnector method search.
@Override
public Collection<SearchResult> search(SearchContext context, String query, Range range, Sorting sorting) {
List<SearchResult> results = new ArrayList<SearchResult>();
SpaceFilter filter = new SpaceFilter();
filter.setSpaceNameSearchCondition(query);
filter.setSorting(sorting);
// if condition only have special characters or empty
if (filter.getSpaceNameSearchCondition().isEmpty()) {
return results;
}
ExoContainerContext eXoContext = (ExoContainerContext) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(ExoContainerContext.class);
String portalName = eXoContext.getPortalContainerName();
ListAccess<Space> la = spaceService.getUnifiedSearchSpacesWithListAccess(getCurrentUserName(), filter);
//
try {
Space[] spaces = la.load(range.offset, range.limit);
//
RowIterator rowIt = rows(buildQuery(filter), range.offset, range.limit);
Row row = null;
//
for (Space s : spaces) {
//
if (Space.HIDDEN.equals(s.getVisibility()) && !spaceService.isMember(s, getCurrentUserName()))
continue;
//
StringBuilder sb = new StringBuilder(s.getDisplayName());
sb.append(String.format(" - %s Member(s)", s.getMembers().length));
if (Space.OPEN.equals(s.getRegistration())) {
sb.append(" - Free to Join");
} else if (Space.VALIDATION.equals(s.getRegistration())) {
sb.append(" - Register");
} else if (Space.CLOSE.equals(s.getRegistration())) {
sb.append(" - Invitation Only");
} else {
LOG.debug(s.getRegistration() + " registration unknown");
}
//
row = (rowIt != null && rowIt.hasNext()) ? rowIt.nextRow() : null;
//
SearchResult result = new SearchResult(getSpaceUrl(context, s, portalName), s.getDisplayName(), // getExcerpt(row),
s.getDescription(), sb.toString(), s.getAvatarUrl() != null ? s.getAvatarUrl() : LinkProvider.SPACE_DEFAULT_AVATAR_URL, s.getCreatedTime(), getRelevancy(row));
results.add(result);
}
} catch (Exception e) {
LOG.error(e);
}
//
return results;
}
use of org.exoplatform.container.ExoContainerContext in project social by Meeds-io.
the class SpaceElasticUnifiedSearchServiceConnector method getUrlFromJsonResult.
private String getUrlFromJsonResult(Space space, SearchContext context) {
if (space == null || context == null) {
return null;
}
try {
String permanentSpaceName = space.getPrettyName();
String groupId = space.getGroupId();
//
String siteName = groupId.replaceAll("/", ":");
String siteType = SiteType.GROUP.getName();
ExoContainerContext eXoContext = (ExoContainerContext) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(ExoContainerContext.class);
String portalName = eXoContext.getPortalContainerName();
String spaceURI = context.handler(portalName).lang("").siteName(siteName).siteType(siteType).path(permanentSpaceName).renderLink();
return URLDecoder.decode(String.format("/%s%s", portalName, spaceURI), "UTF-8");
} catch (Exception e) {
LOG.error("Cannot compute space url for " + space.getDisplayName(), e);
return "";
}
}
use of org.exoplatform.container.ExoContainerContext in project social by Meeds-io.
the class UIUserActivityStreamPortlet method redirectActivity.
/**
* Redirects to activity page viewer (single page) if user has been logged in successfully.
* Resolves problem query params are removing by portal in case of logging in is required. (SOC-3832).
*
* @throws Exception
*/
public void redirectActivity() throws Exception {
String path = Utils.getSelectedNode();
if (path.contains(SINGLE_ACTIVITY_REDIRECT_LINK_PREFIX)) {
PortalRequestContext portalRequestContext = Util.getPortalRequestContext();
HttpServletResponse response = portalRequestContext.getResponse();
ExoContainerContext context = CommonsUtils.getService(ExoContainerContext.class);
String link = new StringBuffer(CommonsUtils.getCurrentDomain()).append("/").append(context.getRestContextName()).append(NOTIFICATION_REST_PREFIX).append(path.replace(SINGLE_ACTIVITY_REDIRECT_LINK_PREFIX, "")).toString();
response.sendRedirect(link);
}
}
Aggregations