@RestResource(id="atg.userprofiling.restresources.currentUserRestResource") public class CurrentUserRestResource extends GenericService implements LockKeyProvider, UpdateableRestResource
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
static java.lang.String |
CREATE |
static java.lang.String |
LOCK_KEY_PREFIX
A String prefix for the lock key for this resource
|
protected java.util.Properties |
mEmbeddedResources |
atg.security.oauth.OAuthService |
mOAuthService
The oauth service.
|
ProfileTools |
mProfileTools
The profile tools.
|
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
CurrentUserRestResource() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
addInputsForCreateUser(FormHandlerExecutor pExecutor,
org.json.JSONObject pInputJson,
atg.service.jaxrs.ResourceUpdateInfo pResourceUpdateInfo)
This method provides a place from which to add form handler input during the create user operation.
|
protected void |
addInputsForLogin(FormHandlerExecutor pExecutor,
java.lang.String pLogin,
java.lang.String pPassword)
This method provides a place from which to add form handler input during the login operation.
|
protected void |
addInputsForLogout(FormHandlerExecutor pExecutor)
This method provides a place from which to add form handler input during the logout operation.
|
protected void |
addInputsForUpdateUser(FormHandlerExecutor pExecutor,
org.json.JSONObject pInputJson,
atg.service.jaxrs.ResourceUpdateInfo pResourceUpdateInfo)
This method provides a place from which to add form handler input during the update user operation.
|
java.lang.Object |
getAddresses()
Gets the address rest subresource.
|
protected java.lang.String |
getAddressesUri()
Build a resource URI for the Addresses.
|
java.lang.String |
getCreateHandleMethod()
Gets the name of the ProfileFormHandler method that is called for handling the creation of a profile.
|
RepresentationModel |
getCurrentUser()
Gets the current user.
|
java.lang.String |
getEmbeddedAddressesRelationshipName()
Get the relationship name used when embedding the addresses resource.
|
java.util.Properties |
getEmbeddedResources()
Gets the embedded resources
|
java.io.Serializable |
getLockKey()
Need to provide a lock key based on the current user profile id
|
java.lang.String |
getLoginHandleMethod()
Gets the name of the ProfileFormHandler method that is called for handling login.
|
java.lang.String |
getLogoutHandleMethod()
Gets the name of the ProfileFormHandler method that is called for handling logout.
|
atg.security.oauth.OAuthService |
getOAuthService()
Gets the oauth service.
|
RepositoryItem |
getProfile()
Retrieves the current profile and makes sure there is one.
|
java.lang.String |
getProfileFormHandlerPath()
Returns the ProfileFormHandlerPath.
|
java.lang.String |
getProfilePath()
Returns the ProfilePath.
|
ProfileTools |
getProfileTools()
Returns the profileTools component.
|
protected RepresentationModel.Builder |
getRepresentationModelBuilder(java.lang.Object pState)
Gets the RepresentationModel.Builder with the given object acting as the state.
|
protected RepresentationModel.Builder |
getRepresentationModelBuilderWithEmbeddedDetails(java.lang.Object pState)
Gets the RepresentationModel.Builder with the given object acting as the state.
|
java.lang.String |
getUpdateHandleMethod()
Gets the name of the ProfileFormHandler method that is called for handling the update of a profile.
|
java.util.Map<java.lang.String,java.lang.String> |
login(java.lang.String pGrantType,
java.lang.String pLogin,
java.lang.String pPassword)
This endpoint authenticates a user based on the credentials passed and returns an access token.
|
Response |
logout()
This endpoint method discards the current user's access token.
|
java.util.Map<java.lang.String,java.lang.String> |
refreshToken()
A new token is generated and returned.
|
RepresentationModel |
register(org.json.JSONObject pInputJson)
Registers a new user.
|
void |
setCreateHandleMethod(java.lang.String pCreateHandleMethod)
Sets the name of the ProfileFormHandler method that is called for handling the creation of a profile.
|
void |
setEmbeddedAddressesRelationshipName(java.lang.String pEmbeddedAddressesRelationshipName)
Configure the relationship name used for embedded addresses.
|
void |
setEmbeddedResources(java.util.Properties pEmbeddedResources)
Sets the EmbeddedResources property
|
void |
setLoginHandleMethod(java.lang.String pLoginHandleMethod)
Sets the name of the ProfileFormHandler method that is called for handling login.
|
void |
setLogoutHandleMethod(java.lang.String pLogoutHandleMethod)
Sets the name of the ProfileFormHandler method that is called for handling logout.
|
void |
setOAuthService(atg.security.oauth.OAuthService pOAuthService)
Sets the oauth service.
|
void |
setProfileFormHandlerPath(java.lang.String pProfileFormHandlerPath)
Sets the ProfileFormHandlerPath.
|
void |
setProfilePath(java.lang.String pProfilePath)
Sets the ProfilePath.
|
void |
setProfileTools(ProfileTools pProfileTools)
Sets the profileTools component.
|
void |
setUpdateHandleMethod(java.lang.String pUpdateHandleMethod)
Sets the name of the ProfileFormHandler method that is called for handling the update of a profile.
|
java.net.URI |
update(atg.service.jaxrs.ResourceUpdateInfo pRestResourceUpdateInfo)
This method specifically handles updates to any embedded resources, all contained with
pRestResourceUpdateInfo . |
RepresentationModel |
updateUser(org.json.JSONObject pInputJson)
This endpoint updates the current user and any updateable (those that implement
atg.service.jaxrs.restresources.UpdateableRestResource )
resources configured on embeddedResources property. |
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService, toString
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
updateEmbeddedResources
public static final java.lang.String CLASS_VERSION
public static final java.lang.String CREATE
public static final java.lang.String LOCK_KEY_PREFIX
public atg.security.oauth.OAuthService mOAuthService
public ProfileTools mProfileTools
protected java.util.Properties mEmbeddedResources
public java.lang.String getProfileFormHandlerPath()
public void setProfileFormHandlerPath(java.lang.String pProfileFormHandlerPath)
pProfileFormHandlerPath
- the ProfileFormHandlerPath to set.public java.lang.String getProfilePath()
public void setProfilePath(java.lang.String pProfilePath)
pProfilePath
- the ProfilePath to set.public atg.security.oauth.OAuthService getOAuthService()
public void setOAuthService(atg.security.oauth.OAuthService pOAuthService)
pOAuthService
- the new o auth servicepublic void setProfileTools(ProfileTools pProfileTools)
pProfileTools
- The profileTools componentpublic ProfileTools getProfileTools()
public void setEmbeddedAddressesRelationshipName(java.lang.String pEmbeddedAddressesRelationshipName)
pEmbeddedAddressesRelationshipName
- the name of the relationship to the embedded resourcepublic java.lang.String getEmbeddedAddressesRelationshipName()
public java.lang.String getUpdateHandleMethod()
The default value is "update".
public void setUpdateHandleMethod(java.lang.String pUpdateHandleMethod)
pUpdateHandleMethod
- the name of the update handle methodpublic java.lang.String getCreateHandleMethod()
The default value is "create".
public void setCreateHandleMethod(java.lang.String pCreateHandleMethod)
pCreateHandleMethod
- the name of the create handle methodpublic java.lang.String getLoginHandleMethod()
The default value is "login".
public void setLoginHandleMethod(java.lang.String pLoginHandleMethod)
pLoginHandleMethod
- the name of the login handle methodpublic java.lang.String getLogoutHandleMethod()
The default value is "logout".
public void setLogoutHandleMethod(java.lang.String pLogoutHandleMethod)
pLogoutHandleMethod
- the name of the logout handle methodpublic java.util.Properties getEmbeddedResources()
public void setEmbeddedResources(java.util.Properties pEmbeddedResources)
pEmbeddedResources
- - the EmbeddedResources value@Endpoint(id="/currentUser/login#POST", filterId="currentUser.login-Default") public java.util.Map<java.lang.String,java.lang.String> login(java.lang.String pGrantType, java.lang.String pLogin, java.lang.String pPassword) throws RestException, atg.security.oauth.OAuthSecurityException, javax.servlet.ServletException
pGrantType
- the grant typepLogin
- the loginpPassword
- the passwordRestException
- if something went wrong during loginatg.security.oauth.OAuthSecurityException
- if something went wrong during loginjavax.servlet.ServletException
- if something went wrong during login@Endpoint(id="/currentUser#GET", isSingular=true, filterId="users.id-Default") public RepresentationModel getCurrentUser() throws RestException
RestException
- if something went wrong whilst getting the current user@Endpoint(id="/currentUser/logout#POST") public Response logout() throws RestException, javax.servlet.ServletException
RestException
- if something went wrong during logoutjavax.servlet.ServletException
- if something went wrong during login@Endpoint(id="/currentUser/refresh#POST", filterId="currentUser.login-Default", security="logged-in") public java.util.Map<java.lang.String,java.lang.String> refreshToken() throws RestException
RestException
- if something went wrong whilst refreshing the token@Endpoint(id="/currentUser/#POST", validatorId="users.id-Full", filterId="users.id.register-Default") public RepresentationModel register(org.json.JSONObject pInputJson) throws RestException, RepositoryException, atg.security.oauth.OAuthSecurityException, java.net.URISyntaxException, javax.servlet.ServletException
pInputJson
- JSON representation of the userRestException
- if something went wrong whilst registering the userRepositoryException
- if something went wrong whilst registering the useratg.security.oauth.OAuthSecurityException
- if something went wrong whilst registering the userjava.net.URISyntaxException
- if something went wrong whilst registering the userjavax.servlet.ServletException
- if something went wrong whilst registering the user@PATCH @Endpoint(id="/currentUser/#PATCH", isSingular=true, validatorId="users.id-Full", filterId="users.id-Default") public RepresentationModel updateUser(org.json.JSONObject pInputJson) throws RestException, RepositoryException, javax.servlet.ServletException
atg.service.jaxrs.restresources.UpdateableRestResource
)
resources configured on embeddedResources
property.pInputJson
- JSON representation of the current userRestException
- if something went wrong updating the current userRepositoryException
- if something went wrong updating the current userjavax.servlet.ServletException
- if something went wrong updating the current user@SubresourceLocator(subresourceIds="atg.userprofiling.restresources.currentUserAddressRestSubresource") public java.lang.Object getAddresses() throws RestException
RestException
- if something went wrong whilst getting the addressespublic RepositoryItem getProfile() throws RestException
RestException
- if there is a problem obtaining the profile.protected boolean addInputsForCreateUser(FormHandlerExecutor pExecutor, org.json.JSONObject pInputJson, atg.service.jaxrs.ResourceUpdateInfo pResourceUpdateInfo) throws javax.servlet.ServletException
To add additional input, call one of the variants of FormHandlerExecutor.addInput(String, Object)
.
pExecutor
- the form handler executor to which the input should be addedpInputJson
- representation of the details to be addedpResourceUpdateInfo
- a ResourceUpdateInfo
containing data to be used during profile creationtrue
if inputs were added successfully, false
otherwisejavax.servlet.ServletException
- if a problem occurred whilst adding input to the executorprotected void addInputsForUpdateUser(FormHandlerExecutor pExecutor, org.json.JSONObject pInputJson, atg.service.jaxrs.ResourceUpdateInfo pResourceUpdateInfo) throws javax.servlet.ServletException
To add additional input, call one of the variants of FormHandlerExecutor.addInput(String, Object)
.
pExecutor
- the form handler executor to which the input should be addedpInputJson
- representation of the details to be addedpResourceUpdateInfo
- a ResourceUpdateInfo
containing data to be used during profile updatejavax.servlet.ServletException
- if a problem occurred whilst adding input to the executorprotected void addInputsForLogin(FormHandlerExecutor pExecutor, java.lang.String pLogin, java.lang.String pPassword) throws javax.servlet.ServletException
To add additional input, call one of the variants of FormHandlerExecutor.addInput(String, Object)
.
pExecutor
- the form handler executor to which the input should be addedpLogin
- the loginpPassword
- the passwordjavax.servlet.ServletException
- if a problem occurred whilst adding input to the executorprotected void addInputsForLogout(FormHandlerExecutor pExecutor) throws javax.servlet.ServletException
To add additional input, call one of the variants of FormHandlerExecutor.addInput(String, Object)
.
pExecutor
- the form handler executor to which the input should be addedjavax.servlet.ServletException
- if a problem occurred whilst adding input to the executorpublic java.io.Serializable getLockKey()
getLockKey
in interface LockKeyProvider
protected RepresentationModel.Builder getRepresentationModelBuilder(java.lang.Object pState)
pState
- the state that will be added to the representation modelprotected RepresentationModel.Builder getRepresentationModelBuilderWithEmbeddedDetails(java.lang.Object pState) throws RestException
Also includes embedded addresses.
pState
- the state that will be added to the representation modelRestException
protected java.lang.String getAddressesUri()
public java.net.URI update(atg.service.jaxrs.ResourceUpdateInfo pRestResourceUpdateInfo) throws RestException
pRestResourceUpdateInfo
.
It will call updateEmbeddedResources()
to update any of the updateable resources configured on this resourceupdate
in interface UpdateableRestResource
pRestResourceUpdateInfo
- - currentUser update object, containing update data (request inputs and
any existing repository data) to be applied to its updateable embedded resourcesRestException
- - if an issue occurs performing the update