Nuxeo Enterprise Platform 5.4

org.nuxeo.webengine.sites.utils
Class SiteUtils

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

public class SiteUtils
extends java.lang.Object

Utility class for sites implementation.

Author:
rux added web comments related

Method Summary
static DocumentModel createDocument(javax.servlet.http.HttpServletRequest request, CoreSession session, java.lang.String parentPath, java.lang.String documentType)
          Creates a document type that is received as parameter, as document model.
static Blob getBlob(DocumentModel d, java.lang.String xpath)
           
static boolean getBoolean(DocumentModel d, java.lang.String xpath)
           
static boolean getBoolean(DocumentModel d, java.lang.String xpath, boolean defaultValue)
           
static CommentManager getCommentManager()
           
static DocumentModel getFirstWebSiteParent(CoreSession session, DocumentModel doc)
          Gets the first mini-site parent.
static java.lang.String getFistNWordsFromString(java.lang.String string, int n)
           
static java.util.GregorianCalendar getGregorianCalendar(DocumentModel d, java.lang.String xpath)
           
static javax.ws.rs.core.Response getLogoResponse(DocumentModel document)
           
static java.lang.String getModerationType(CoreSession session, DocumentModel doc)
           
static java.util.ArrayList<java.lang.String> getModerators(CoreSession session, DocumentModel doc)
           
static java.lang.Long getNumber(DocumentModel d, java.lang.String xpath)
           
static java.lang.Long getNumber(DocumentModel d, java.lang.String xpath, java.lang.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)
          This method is used to retrieve the WebPage where this WebComment was published.
static java.lang.String getPagePath(DocumentModel ws, DocumentModel documentModel)
          Returns the path for a webPage from a webSite.
static java.util.Map<java.lang.String,java.lang.Object> getRssFeedArguments(WebContext ctx, java.lang.String key)
          Computes the arguments for rss feed.
static java.lang.String getString(DocumentModel d, java.lang.String xpath)
           
static java.lang.String getString(DocumentModel d, java.lang.String xpath, java.lang.String defaultValue)
           
static java.lang.String getUserDetails(java.lang.String username)
          Retrieves user details for a certain username.
static UserManager getUserManager()
           
static java.util.ArrayList<java.lang.String> getUsersWithPermission(CoreSession session, DocumentModel doc, java.util.Set<java.lang.String> permissions)
           
static java.lang.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 javax.ws.rs.core.Response getLogoResponse(DocumentModel document)
                                                 throws java.lang.Exception
Throws:
java.lang.Exception

getFirstWebSiteParent

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

Throws:
java.lang.Exception

getNumberCommentsForPage

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

Throws:
java.lang.Exception

getUserDetails

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

Returns:
user first name + user last name
Throws:
java.lang.Exception

getWebContainersPath

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

Returns:
the path to all the existing web containers

getPagePath

public static java.lang.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(javax.servlet.http.HttpServletRequest request,
                                           CoreSession session,
                                           java.lang.String parentPath,
                                           java.lang.String documentType)
                                    throws java.lang.Exception
Creates a document type that is received as parameter, as document model.

Throws:
java.lang.Exception

getUsersWithPermission

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

isCurrentModerated

public static boolean isCurrentModerated(CoreSession session,
                                         DocumentModel doc)
                                  throws java.lang.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:
java.lang.Exception

isModeratedByCurrentUser

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

getCommentManager

public static CommentManager getCommentManager()
                                        throws java.lang.Exception
Throws:
java.lang.Exception

getUserManager

public static UserManager getUserManager()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

getPageForComment

public static DocumentModel getPageForComment(DocumentModel comment)
                                       throws java.lang.Exception
This method is used to retrieve the WebPage where this WebComment was published.

Parameters:
comment -
Returns:
the WebPage
Throws:
java.lang.Exception

getModerators

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

getModerationType

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

getString

public static java.lang.String getString(DocumentModel d,
                                         java.lang.String xpath,
                                         java.lang.String defaultValue)

getString

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

getGregorianCalendar

public static java.util.GregorianCalendar getGregorianCalendar(DocumentModel d,
                                                               java.lang.String xpath)
                                                        throws ClientException
Throws:
ClientException

getNumber

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

getNumber

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

getBlob

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

getBoolean

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

getBoolean

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

getFistNWordsFromString

public static java.lang.String getFistNWordsFromString(java.lang.String string,
                                                       int n)

getRssFeedArguments

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

Throws:
java.lang.Exception

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.