use of org.exoplatform.portal.application.PortalRequestContext in project onlyoffice by exoplatform.
the class OnlyofficeFileViewer method getFileViewerConfig.
/**
* Gets the file viewer config.
*
* @param fileId the file id
* @param workspace the workspace
* @return the file viewer config
*/
public Config getFileViewerConfig(String fileId, String workspace) {
OnlyofficeEditorService editorService = WCMCoreUtils.getService(OnlyofficeEditorService.class);
PortalRequestContext requestContext = Util.getPortalRequestContext();
HttpServletRequest request = requestContext.getRequest();
try {
Config config = editorService.createViewer(request.getScheme(), request.getServerName(), request.getServerPort(), request.getRemoteUser(), workspace, fileId);
return config;
} catch (RepositoryException | OnlyofficeEditorException e) {
LOG.error("Cannot create viewer config for fileId: " + fileId + ", workspace: " + workspace, e);
}
return null;
}
use of org.exoplatform.portal.application.PortalRequestContext in project onlyoffice by exoplatform.
the class OnlyofficeDocumentEditorPlugin method contextEditorLink.
/**
* Context editor link.
*
* @param node the node
* @param context the context
* @param requestURI the request URI
* @return the string
* @throws OnlyofficeEditorException the onlyoffice editor exception
* @throws RepositoryException the repository exception
*/
private String contextEditorLink(Node node, String context, URI requestURI) throws OnlyofficeEditorException, RepositoryException {
String link;
if (requestURI != null) {
link = editorService.getEditorLink(node, requestURI.getScheme(), requestURI.getHost(), requestURI.getPort());
} else {
PortalRequestContext pcontext = Util.getPortalRequestContext();
if (pcontext != null) {
link = editorService.getEditorLink(node, pcontext.getRequest().getScheme(), pcontext.getRequest().getServerName(), pcontext.getRequest().getServerPort());
} else {
throw new OnlyofficeEditorException("Cannot get editor link - request URI and PortalRequestContext are null");
}
}
editorLinks.putIfAbsent(node, link);
return editorLink(link, context);
}
use of org.exoplatform.portal.application.PortalRequestContext in project social by Meeds-io.
the class UISpaceAccess method cleanSession.
@PreDestroy
public void cleanSession() {
PortalRequestContext pcontext = Util.getPortalRequestContext();
pcontext.getRequest().getSession().removeAttribute(SpaceAccessType.ACCESSED_SPACE_PRETTY_NAME_KEY);
pcontext.getRequest().getSession().removeAttribute(SpaceAccessType.ACCESSED_TYPE_KEY);
}
use of org.exoplatform.portal.application.PortalRequestContext in project ecms by exoplatform.
the class EmailNotifyCloudDocumentListener method getViewableLink.
/**
* Used in
* {@link WatchCloudDocumentServiceImpl#watchDocument(Node, String, int)}.
*
* @return the viewable link
* @throws Exception the exception
*/
String getViewableLink() throws Exception {
PortalRequestContext pContext = Util.getPortalRequestContext();
NodeURL nodeURL = pContext.createURL(NodeURL.TYPE);
String nodePath = NodeLocation.getNodeByLocation(observedNode_).getPath();
ManageDriveService manageDriveService = WCMCoreUtils.getService(ManageDriveService.class);
List<DriveData> driveList = manageDriveService.getDriveByUserRoles(pContext.getRemoteUser(), getMemberships());
DriveData drive = getDrive(driveList, WCMCoreUtils.getRepository().getConfiguration().getDefaultWorkspaceName(), nodePath);
String driverName = drive.getName();
String nodePathInDrive = "/".equals(drive.getHomePath()) ? nodePath : nodePath.substring(drive.getHomePath().length());
UserNode siteExNode = getUserNodeByURI(SITE_EXPLORER);
nodeURL.setNode(siteExNode);
nodeURL.setQueryParameterValue(PATH_PARAM, "/" + driverName + nodePathInDrive);
PortletRequestContext portletRequestContext = WebuiRequestContext.getCurrentInstance();
PortletRequest portletRequest = portletRequestContext.getRequest();
String baseURI = portletRequest.getScheme() + "://" + portletRequest.getServerName() + ":" + String.format("%s", portletRequest.getServerPort());
return baseURI + nodeURL.toString();
}
use of org.exoplatform.portal.application.PortalRequestContext in project social by Meeds-io.
the class UIEditUserProfileForm method warning.
/**
* @param messageKey
* @param args
*/
private void warning(String messageKey, String... args) {
WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
context.getUIApplication().addMessage(new ApplicationMessage(messageKey, args, ApplicationMessage.WARNING));
((PortalRequestContext) context.getParentAppRequestContext()).ignoreAJAXUpdateOnPortlets(true);
}
Aggregations