Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.webengine.sites.utils
Class SiteUtils

java.lang.Object
  extended by org.nuxeo.webengine.sites.utils.SiteUtils

public class SiteUtils
extends Object

Utility class for sites implementation.

Author:
rux added web comments related

Method Summary
static DocumentModel createDocument(HttpServletRequest request, CoreSession session, String parentPath, String documentType)
          Creates a document type that is received as parameter, as document model.
static Blob getBlob(DocumentModel d, String xpath)
           
static boolean getBoolean(DocumentModel d, String xpath)
           
static boolean getBoolean(DocumentModel d, String xpath, boolean defaultValue)
           
static CommentManager getCommentManager()
           
static DocumentModel getFirstWebSiteParent(CoreSession session, DocumentModel doc)
          Gets the first mini-site parent.
static String getFistNWordsFromString(String string, int n)
           
static GregorianCalendar getGregorianCalendar(DocumentModel d, String xpath)
           
static Response getLogoResponse(DocumentModel document)
           
static String getModerationType(CoreSession session, DocumentModel doc)
           
static ArrayList<String> getModerators(CoreSession session, DocumentModel doc)
           
static Long getNumber(DocumentModel d, String xpath)
           
static Long getNumber(DocumentModel d, String xpath, Long defaultValue)
           
static int getNumberCommentsForPage(CoreSession session, DocumentModel page)
          Gets the number of comments added on a page (published actually, if the moderation is on).
static DocumentModel getPageForComment(DocumentModel comment)
          Retrieves the WebPage where this WebComment was published.
static String getPagePath(DocumentModel ws, DocumentModel documentModel)
          Returns the path for a webPage from a webSite.
static Map<String,Object> getRssFeedArguments(WebContext ctx, String key)
          Computes the arguments for rss feed.
static String getString(DocumentModel d, String xpath)
           
static String getString(DocumentModel d, String xpath, String defaultValue)
           
static String getUserDetails(String username)
          Retrieves user details for a certain username.
static UserManager getUserManager()
           
static ArrayList<String> getUsersWithPermission(CoreSession session, DocumentModel doc, Set<String> permissions)
           
static StringBuilder getWebContainersPath()
          Returns the path to all the existing web containers.
static boolean isCurrentModerated(CoreSession session, DocumentModel doc)
           
static boolean isModeratedByCurrentUser(CoreSession session, DocumentModel doc)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLogoResponse

public static Response getLogoResponse(DocumentModel document)
                                throws Exception
Throws:
Exception

getFirstWebSiteParent

public static DocumentModel getFirstWebSiteParent(CoreSession session,
                                                  DocumentModel doc)
                                           throws Exception
Gets the first mini-site parent.

Throws:
Exception

getNumberCommentsForPage

public static int getNumberCommentsForPage(CoreSession session,
                                           DocumentModel page)
                                    throws Exception
Gets the number of comments added on a page (published actually, if the moderation is on).

Throws:
Exception

getUserDetails

public static String getUserDetails(String username)
                             throws Exception
Retrieves user details for a certain username.

Returns:
user first name + user last name
Throws:
Exception

getWebContainersPath

public static StringBuilder getWebContainersPath()
Returns the path to all the existing web containers.

Returns:
the path to all the existing web containers

getPagePath

public static String getPagePath(DocumentModel ws,
                                 DocumentModel documentModel)
Returns the path for a webPage from a webSite.

Parameters:
ws - the web site
documentModel - the webPage
Returns:
the path

createDocument

public static DocumentModel createDocument(HttpServletRequest request,
                                           CoreSession session,
                                           String parentPath,
                                           String documentType)
                                    throws Exception
Creates a document type that is received as parameter, as document model.

Throws:
Exception

getUsersWithPermission

public static ArrayList<String> getUsersWithPermission(CoreSession session,
                                                       DocumentModel doc,
                                                       Set<String> permissions)
                                                throws Exception
Returns:
all users with a given permission for the corresponding workspace
Throws:
Exception

isCurrentModerated

public static boolean isCurrentModerated(CoreSession session,
                                         DocumentModel doc)
                                  throws Exception
Returns:
true if the corresponding workspace is moderated : there is at least one user with moderate permission on this workspace and the moderationType is a priori
Throws:
Exception

isModeratedByCurrentUser

public static boolean isModeratedByCurrentUser(CoreSession session,
                                               DocumentModel doc)
                                        throws Exception
Returns:
true if the current user is among moderators
Throws:
Exception

getCommentManager

public static CommentManager getCommentManager()
                                        throws Exception
Throws:
Exception

getUserManager

public static UserManager getUserManager()
                                  throws Exception
Throws:
Exception

getPageForComment

public static DocumentModel getPageForComment(DocumentModel comment)
                                       throws Exception
Retrieves the WebPage where this WebComment was published.

Parameters:
comment -
Returns:
the WebPage
Throws:
Exception

getModerators

public static ArrayList<String> getModerators(CoreSession session,
                                              DocumentModel doc)
                                       throws Exception
Returns:
all the moderators for the corresponding workspace
Throws:
Exception

getModerationType

public static String getModerationType(CoreSession session,
                                       DocumentModel doc)
                                throws Exception
Returns:
the moderation type for the corresponding workspace ; default is aposteriori
Throws:
Exception

getString

public static String getString(DocumentModel d,
                               String xpath,
                               String defaultValue)

getString

public static String getString(DocumentModel d,
                               String xpath)
                        throws ClientException
Throws:
ClientException

getGregorianCalendar

public static GregorianCalendar getGregorianCalendar(DocumentModel d,
                                                     String xpath)
                                              throws ClientException
Throws:
ClientException

getNumber

public static Long getNumber(DocumentModel d,
                             String xpath)
                      throws ClientException
Throws:
ClientException

getNumber

public static Long getNumber(DocumentModel d,
                             String xpath,
                             Long defaultValue)

getBlob

public static Blob getBlob(DocumentModel d,
                           String xpath)
                    throws ClientException
Throws:
ClientException

getBoolean

public static boolean getBoolean(DocumentModel d,
                                 String xpath,
                                 boolean defaultValue)

getBoolean

public static boolean getBoolean(DocumentModel d,
                                 String xpath)
                          throws ClientException
Throws:
ClientException

getFistNWordsFromString

public static String getFistNWordsFromString(String string,
                                             int n)

getRssFeedArguments

public static Map<String,Object> getRssFeedArguments(WebContext ctx,
                                                     String key)
Computes the arguments for rss feed.


Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.