/* * (non-Javadoc) * @see * org.exoplatform.services.wcm.portal.artifacts.BasePortalArtifactsPlugin * #deployToPortal(java.lang.String, * org.exoplatform.services.jcr.ext.common.SessionProvider) */ public void deployToPortal(SessionProvider sessionProvider, String portalName) throws Exception { try { NewsletterCategoryHandler categoryHandler = newsletterManagerService.getCategoryHandler(); for (NewsletterCategoryConfig categoryConfig : categoryConfigs) { categoryHandler.add(sessionProvider, portalName, categoryConfig); } NewsletterSubscriptionHandler subscriptionHandler = newsletterManagerService.getSubscriptionHandler(); for (NewsletterSubscriptionConfig subscriptionConfig : subscriptionConfigs) { subscriptionHandler.add(sessionProvider, portalName, subscriptionConfig); } Node portalNode = livePortalManagerService.getLivePortal(sessionProvider, portalName); String userFolderPath = NewsletterConstant.generateUserPath(portalName); ExtendedNode userFolderNode = (ExtendedNode) ((Node) portalNode.getSession().getItem(userFolderPath)); if (userFolderNode.canAddMixin("exo:privilegeable")) userFolderNode.addMixin("exo:privilegeable"); userFolderNode.setPermission("any", PermissionType.ALL); } catch (Exception e) { if (log.isInfoEnabled()) { log.info("InitialNewsletterPlugin fail because of ", e); } } }
/** * Check if the user can delete the current node * * @return true, if current mode is edit mode * @throws RepositoryException * @throws AccessControlException */ public static boolean isShowDelete(Node content) throws AccessControlException, RepositoryException { boolean isEditMode = false; if (WCMComposer.MODE_EDIT.equals(getCurrentMode())) isEditMode = true; ((ExtendedNode) content).checkPermission(PermissionType.SET_PROPERTY); ((ExtendedNode) content).checkPermission(PermissionType.ADD_NODE); ((ExtendedNode) content).checkPermission(PermissionType.REMOVE); return isEditMode; }
/** * Check if the content is editable and current mode of the site is edit mode * * @param content the content node * @return true if there is no content if the content is editable and current mode is edit mode */ public static boolean isShowQuickEdit(Node content) { if (content == null) return true; try { boolean isEditMode = false; if (WCMComposer.MODE_EDIT.equals(getCurrentMode()) || Util.getUIPortalApplication().getModeState() != UIPortalApplication.NORMAL_MODE) isEditMode = true; ((ExtendedNode) content).checkPermission(PermissionType.SET_PROPERTY); ((ExtendedNode) content).checkPermission(PermissionType.ADD_NODE); ((ExtendedNode) content).checkPermission(PermissionType.REMOVE); return isEditMode; } catch (Exception e) { return false; } }
/** * Check if the node is viewable for the current user or not viewable. <br> * return True if the node is viewable, otherwise will return False * * @param node: The node to check */ public static boolean isViewable(Node node) { try { node.refresh(true); ((ExtendedNode) node).checkPermission(PermissionType.READ); } catch (Exception e) { return false; } return true; }