Search in sources :

Example 1 with PortalRequestContext

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;
}
Also used : OnlyofficeEditorService(org.exoplatform.onlyoffice.OnlyofficeEditorService) HttpServletRequest(javax.servlet.http.HttpServletRequest) OnlyofficeEditorException(org.exoplatform.onlyoffice.OnlyofficeEditorException) Config(org.exoplatform.onlyoffice.Config) ComponentConfig(org.exoplatform.webui.config.annotation.ComponentConfig) PortalRequestContext(org.exoplatform.portal.application.PortalRequestContext) RepositoryException(javax.jcr.RepositoryException)

Example 2 with PortalRequestContext

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);
}
Also used : OnlyofficeEditorException(org.exoplatform.onlyoffice.OnlyofficeEditorException) PortalRequestContext(org.exoplatform.portal.application.PortalRequestContext)

Example 3 with PortalRequestContext

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);
}
Also used : PortalRequestContext(org.exoplatform.portal.application.PortalRequestContext) PreDestroy(javax.annotation.PreDestroy)

Example 4 with PortalRequestContext

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();
}
Also used : ManageDriveService(org.exoplatform.services.cms.drives.ManageDriveService) PortletRequest(javax.portlet.PortletRequest) PortalRequestContext(org.exoplatform.portal.application.PortalRequestContext) UserNode(org.exoplatform.portal.mop.user.UserNode) DriveData(org.exoplatform.services.cms.drives.DriveData) PortletRequestContext(org.exoplatform.webui.application.portlet.PortletRequestContext) NodeURL(org.exoplatform.web.url.navigation.NodeURL)

Example 5 with PortalRequestContext

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);
}
Also used : ApplicationMessage(org.exoplatform.web.application.ApplicationMessage) WebuiRequestContext(org.exoplatform.webui.application.WebuiRequestContext) PortalRequestContext(org.exoplatform.portal.application.PortalRequestContext)

Aggregations

PortalRequestContext (org.exoplatform.portal.application.PortalRequestContext)101 UIPortalApplication (org.exoplatform.portal.webui.workspace.UIPortalApplication)13 Space (org.exoplatform.social.core.space.model.Space)10 UIPortal (org.exoplatform.portal.webui.portal.UIPortal)9 UIWorkingWorkspace (org.exoplatform.portal.webui.workspace.UIWorkingWorkspace)9 ArrayList (java.util.ArrayList)8 Node (javax.jcr.Node)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)8 NodeURL (org.exoplatform.web.url.navigation.NodeURL)8 WebuiRequestContext (org.exoplatform.webui.application.WebuiRequestContext)8 ExoContainer (org.exoplatform.container.ExoContainer)7 Route (org.exoplatform.social.common.router.ExoRouter.Route)7 UserNode (org.exoplatform.portal.mop.user.UserNode)6 IOException (java.io.IOException)5 Locale (java.util.Locale)5 UserPortalConfigService (org.exoplatform.portal.config.UserPortalConfigService)5 HashMap (java.util.HashMap)4 SpaceService (org.exoplatform.social.core.space.spi.SpaceService)4 JavascriptManager (org.exoplatform.web.application.JavascriptManager)4 PortletRequestContext (org.exoplatform.webui.application.portlet.PortletRequestContext)4