Class AbstractUserWorkspaceImpl
- java.lang.Object
-
- org.nuxeo.ecm.platform.userworkspace.core.service.AbstractUserWorkspaceImpl
-
- All Implemented Interfaces:
Serializable
,CollectionLocationService
,UserWorkspaceService
- Direct Known Subclasses:
DefaultUserWorkspaceServiceImpl
public abstract class AbstractUserWorkspaceImpl extends Object implements UserWorkspaceService, CollectionLocationService
Abstract class holding most of the logic for usingUnrestrictedSessionRunner
while creating UserWorkspaces and associated resources- Since:
- 5.9.5
- Author:
- tiry
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AbstractUserWorkspaceImpl.UnrestrictedUserWorkspaceFinder
-
Field Summary
Fields Modifier and Type Field Description protected static char
ESCAPE_CHAR
protected static String
ESCAPED_CHARS
protected int
maxsize
protected String
targetDomainName
-
Constructor Summary
Constructors Constructor Description AbstractUserWorkspaceImpl()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected String
buildUserWorkspaceTitle(String userName)
protected String
computePathUserWorkspaceRoot(CoreSession userCoreSession, String usedUsername)
protected DocumentModel
createDefaultCollectionsRoot(CoreSession session, DocumentModel userWorkspace)
protected DocumentModel
createFavorites(CoreSession session, DocumentModel userWorkspace)
protected String
digest(String username, int maxsize)
protected abstract DocumentModel
doCreateUserWorkspace(CoreSession unrestrictedSession, PathRef wsRef, String username)
protected abstract DocumentModel
doCreateUserWorkspacesRoot(CoreSession unrestrictedSession, PathRef rootRef)
protected String
escape(String string)
Bijective escaping for user names.protected void
generateCandidates(List<String> names, String username, int max)
List<String>
getCandidateUserWorkspaceNames(String username)
Finds the list of potential names for the user workspace.protected UserWorkspaceServiceImplComponent
getComponent()
DocumentModel
getCurrentUserPersonalWorkspace(String userName, DocumentModel currentDocument)
Gets the current user personal workspace from a lower level.DocumentModel
getCurrentUserPersonalWorkspace(CoreSession userCoreSession)
Gets the current user personal workspace.DocumentModel
getCurrentUserPersonalWorkspace(CoreSession userCoreSession, DocumentModel context)
Deprecated.since 9.3protected DocumentModel
getCurrentUserPersonalWorkspace(NuxeoPrincipal principal, String userName, CoreSession userCoreSession)
This method handles the UserWorkspace creation with a Principal or a username.protected String
getDomainName(CoreSession userCoreSession)
protected PathRef
getExistingUserWorkspace(CoreSession session, PathRef rootref, NuxeoPrincipal principal, String username)
protected PathRef
getExistingUserWorkspaceRoot(CoreSession session, String username)
protected Locale
getLocale(CoreSession session)
DocumentModel
getUserDefaultCollectionsRoot(CoreSession session)
Provide the default document where will be stored collections.DocumentModel
getUserFavorites(CoreSession session)
Provide the default favorites document.protected String
getUserName(NuxeoPrincipal principal, String username)
Gets the base username to use to determine a user's workspace.DocumentModel
getUserPersonalWorkspace(String userName, DocumentModel context)
Gets a detached user workspace of a specified user.DocumentModel
getUserPersonalWorkspace(NuxeoPrincipal principal, DocumentModel context)
Gets a detached user workspace of a specified user depending of the passed principal.protected DocumentModel
initCreateFavorites(CoreSession session, DocumentModel favorites)
protected abstract DocumentModel
initCreateUserWorkspace(CoreSession unrestrictedSession, DocumentModel doc, String username)
protected abstract DocumentModel
initCreateUserWorkspacesRoot(CoreSession unrestrictedSession, DocumentModel doc)
protected DocumentModel
initDefaultCollectionsRoot(CoreSession session, DocumentModel collectionsRoot)
void
invalidate()
Invalidates the user workspace service and force re-computation of user workspace root location.boolean
isUnderUserWorkspace(NuxeoPrincipal principal, String username, DocumentModel doc)
Checks whether the passed document is under the user's workspace (or is the workspace itself).protected void
notifyEvent(CoreSession coreSession, DocumentModel document, NuxeoPrincipal principal, String eventId, Map<String,Serializable> properties)
-
-
-
Field Detail
-
ESCAPE_CHAR
protected static final char ESCAPE_CHAR
- See Also:
- Constant Field Values
-
ESCAPED_CHARS
protected static final String ESCAPED_CHARS
- See Also:
- Constant Field Values
-
targetDomainName
protected volatile String targetDomainName
-
maxsize
protected final int maxsize
-
-
Method Detail
-
getDomainName
protected String getDomainName(CoreSession userCoreSession)
-
getUserName
protected String getUserName(NuxeoPrincipal principal, String username)
Gets the base username to use to determine a user's workspace. This is not used directly as a path segment, but forms the sole basis for it.- Since:
- 9.2
-
getCandidateUserWorkspaceNames
public List<String> getCandidateUserWorkspaceNames(String username)
Finds the list of potential names for the user workspace. They're all tried in order.- Returns:
- the list of candidate names
- Since:
- 9.2
-
escape
protected String escape(String string)
Bijective escaping for user names.Escapes some chars not allowed in a path segment or URL. The escaping character is a
~
followed by the one-byte hex value of the character.- Since:
- 9.2
-
computePathUserWorkspaceRoot
protected String computePathUserWorkspaceRoot(CoreSession userCoreSession, String usedUsername)
-
getCurrentUserPersonalWorkspace
public DocumentModel getCurrentUserPersonalWorkspace(String userName, DocumentModel currentDocument)
Description copied from interface:UserWorkspaceService
Gets the current user personal workspace from a lower level.If this personal workspace does not exist then a new one will be created for the user who is represented by first argument.
- Specified by:
getCurrentUserPersonalWorkspace
in interfaceUserWorkspaceService
- Parameters:
userName
- the current usercurrentDocument
- the current document on which the user was on- Returns:
- the DocumentModel for the personal workspace of the current user
-
getCurrentUserPersonalWorkspace
public DocumentModel getCurrentUserPersonalWorkspace(CoreSession userCoreSession)
Description copied from interface:UserWorkspaceService
Gets the current user personal workspace.If this personal workspace does not exist then a new one will be created for the user owning the core session.
- Specified by:
getCurrentUserPersonalWorkspace
in interfaceUserWorkspaceService
- Parameters:
userCoreSession
- the user core session- Returns:
- the user personal workspace
-
getCurrentUserPersonalWorkspace
@Deprecated public DocumentModel getCurrentUserPersonalWorkspace(CoreSession userCoreSession, DocumentModel context)
Deprecated.since 9.3Only for compatibility.- Specified by:
getCurrentUserPersonalWorkspace
in interfaceUserWorkspaceService
-
getCurrentUserPersonalWorkspace
protected DocumentModel getCurrentUserPersonalWorkspace(NuxeoPrincipal principal, String userName, CoreSession userCoreSession)
This method handles the UserWorkspace creation with a Principal or a username. At least one should be passed. If a principal is passed, the username is not taken into account.- Since:
- 5.7 "userWorkspaceCreated" is triggered
-
getExistingUserWorkspaceRoot
protected PathRef getExistingUserWorkspaceRoot(CoreSession session, String username)
-
getExistingUserWorkspace
protected PathRef getExistingUserWorkspace(CoreSession session, PathRef rootref, NuxeoPrincipal principal, String username)
-
getUserPersonalWorkspace
public DocumentModel getUserPersonalWorkspace(NuxeoPrincipal principal, DocumentModel context)
Description copied from interface:UserWorkspaceService
Gets a detached user workspace of a specified user depending of the passed principal.- Specified by:
getUserPersonalWorkspace
in interfaceUserWorkspaceService
- Parameters:
principal
- of the wanted user's workspace ownercontext
- is a document to determine the domain- Returns:
- the DocumentModel for the personal workspace
-
getUserPersonalWorkspace
public DocumentModel getUserPersonalWorkspace(String userName, DocumentModel context)
Description copied from interface:UserWorkspaceService
Gets a detached user workspace of a specified user.- Specified by:
getUserPersonalWorkspace
in interfaceUserWorkspaceService
- Parameters:
userName
- is the username of the wanted user's workspace ownercontext
- is a document to determine the domain- Returns:
- the DocumentModel for the personal workspace
-
isUnderUserWorkspace
public boolean isUnderUserWorkspace(NuxeoPrincipal principal, String username, DocumentModel doc)
Description copied from interface:UserWorkspaceService
Checks whether the passed document is under the user's workspace (or is the workspace itself).- Specified by:
isUnderUserWorkspace
in interfaceUserWorkspaceService
- Parameters:
principal
- the userusername
- the username, if principal is not availabledoc
- the document- Returns:
true
if the document is under the user's workspace
-
notifyEvent
protected void notifyEvent(CoreSession coreSession, DocumentModel document, NuxeoPrincipal principal, String eventId, Map<String,Serializable> properties)
-
getComponent
protected UserWorkspaceServiceImplComponent getComponent()
-
doCreateUserWorkspacesRoot
protected abstract DocumentModel doCreateUserWorkspacesRoot(CoreSession unrestrictedSession, PathRef rootRef)
-
initCreateUserWorkspacesRoot
protected abstract DocumentModel initCreateUserWorkspacesRoot(CoreSession unrestrictedSession, DocumentModel doc)
-
doCreateUserWorkspace
protected abstract DocumentModel doCreateUserWorkspace(CoreSession unrestrictedSession, PathRef wsRef, String username)
-
initCreateUserWorkspace
protected abstract DocumentModel initCreateUserWorkspace(CoreSession unrestrictedSession, DocumentModel doc, String username)
-
invalidate
public void invalidate()
Description copied from interface:UserWorkspaceService
Invalidates the user workspace service and force re-computation of user workspace root location.- Specified by:
invalidate
in interfaceUserWorkspaceService
-
getUserDefaultCollectionsRoot
public DocumentModel getUserDefaultCollectionsRoot(CoreSession session)
Description copied from interface:CollectionLocationService
Provide the default document where will be stored collections. The document must be a "Folderish" accepting "Collection" sub-type.- Specified by:
getUserDefaultCollectionsRoot
in interfaceCollectionLocationService
- Parameters:
session
- the core session- Returns:
- the default location for collections
- Since:
- 10.3
-
getUserFavorites
public DocumentModel getUserFavorites(CoreSession session)
Description copied from interface:CollectionLocationService
Provide the default favorites document. The document must be of type Favorites.- Specified by:
getUserFavorites
in interfaceCollectionLocationService
- Parameters:
session
- the core session- Returns:
- the favorites
- Since:
- 10.3
-
getLocale
protected Locale getLocale(CoreSession session)
- Since:
- 10.3
-
createFavorites
protected DocumentModel createFavorites(CoreSession session, DocumentModel userWorkspace)
- Since:
- 10.3
-
initCreateFavorites
protected DocumentModel initCreateFavorites(CoreSession session, DocumentModel favorites)
- Since:
- 10.3
-
createDefaultCollectionsRoot
protected DocumentModel createDefaultCollectionsRoot(CoreSession session, DocumentModel userWorkspace)
- Since:
- 10.3
-
initDefaultCollectionsRoot
protected DocumentModel initDefaultCollectionsRoot(CoreSession session, DocumentModel collectionsRoot)
- Since:
- 10.3
-
-