Class SiteServiceImpl
java.lang.Object
org.craftercms.studio.impl.v1.service.site.SiteServiceImpl
- All Implemented Interfaces:
SiteService
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
public class SiteServiceImpl
extends Object
implements SiteService, org.springframework.context.ApplicationContextAware
Note: consider renaming
A site in Crafter Studio is currently the name for a WEM project being managed.
This service provides access to site configuration
- Author:
- russdanner
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContext
protected AuditServiceInternal
protected ConfigurationService
protected ConfigurationService
protected ContentRepository
protected ContentRepository
protected ContentService
protected DependencyService
protected DependencyServiceInternal
protected Deployer
protected DeploymentService
protected DmPageNavigationOrderService
protected org.craftercms.commons.entitlements.validator.EntitlementValidator
protected GroupServiceInternal
protected ItemServiceInternal
protected RetryingDatabaseOperationFacade
protected SecurityService
protected SiteFeedMapper
protected SitesService
protected StudioConfiguration
protected StudioDBScriptRunnerFactory
protected StudioUpgradeManager
protected UserDAO
protected UserServiceInternal
protected WorkflowServiceInternal
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
addRemote
(String siteId, String remoteName, String remoteUrl, String authenticationType, String remoteUsername, String remotePassword, String remoteToken, String remotePrivateKey) Add remote repository for site content repositoryvoid
checkSiteExists
(String site) Checks if a site exists.int
void
createSiteFromBlueprint
(String blueprintId, @Size(max=50) String siteId, String siteName, String sandboxBranch, String desc, Map<String, String> params, boolean createAsOrphan) Create a new site based on an existing blueprintprotected boolean
createSiteFromBlueprintGit
(String blueprintLocation, String siteId, String sandboxBranch, Map<String, String> params, String creator) void
createSiteWithRemoteOption
(@Size(max=50) String siteId, String siteName, String sandboxBranch, String description, String blueprintName, String remoteName, String remoteUrl, String remoteBranch, boolean singleBranch, String authenticationType, String remoteUsername, String remotePassword, String remoteToken, String remotePrivateKey, String createOption, Map<String, String> params, boolean createAsOrphan) Create a new site with remote option (clone from remote or push to remote repository)@jakarta.validation.Valid boolean
deleteSite
(String siteId) remove a site from the system@jakarta.validation.Valid boolean
enablePublishing
(String siteId, boolean enabled) Enable/Disable publishing for given site@jakarta.validation.Valid boolean
Check if site already exists@jakarta.validation.Valid boolean
existsById
(String siteId) Check if site already exists@jakarta.validation.Valid boolean
existsByName
(String siteName) Check if site already existsGet list of all sites with state = CREATEDget a list of available blueprintsGet deleted sites@Valid SiteFeed
Get site feed for given sitegetSiteDetails
(String siteId) Get site details.getSitesPerUser
(int start, int number) Get sites that user is allowed access to for current usergetSitesPerUser
(String username, int start, int number) Get sites that user is allowed access to for given username@jakarta.validation.Valid int
Get total number of sites that user is allowed access to for current user@jakarta.validation.Valid int
getSitesPerUserTotal
(String username) Get total number of sites that user is allowed access to for given usernamegetSiteState
(String siteId) boolean
isPublishedRepoCreated
(String siteId) @jakarta.validation.Valid boolean
isPublishingEnabled
(String siteId) Check if publishing is enabled for given sitelistRemote
(String siteId) List remote repositories for given siteboolean
removeRemote
(String siteId, String remoteName) Remove remote with given name for siteprotected void
replaceFileContentGit
(String site, String path, String find, String replace) void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setAuditServiceInternal
(AuditServiceInternal auditServiceInternal) void
setConfigurationService
(ConfigurationService configurationService) void
setConfigurationServiceInternal
(ConfigurationService configurationServiceInternal) void
void
setContentRepositoryV2
(ContentRepository contentRepositoryV2) void
setContentService
(ContentService contentService) void
setDependencyService
(DependencyService dependencyService) void
setDependencyServiceInternal
(DependencyServiceInternal dependencyServiceInternal) void
setDeployer
(Deployer deployer) void
setDeploymentService
(DeploymentService deploymentService) void
setDmPageNavigationOrderService
(DmPageNavigationOrderService dmPageNavigationOrderService) void
setEntitlementValidator
(org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator) void
setGroupServiceInternal
(GroupServiceInternal groupServiceInternal) void
setItemServiceInternal
(ItemServiceInternal itemServiceInternal) void
setPublishedRepoCreated
(String siteId) void
setRetryingDatabaseOperationFacade
(RetryingDatabaseOperationFacade retryingDatabaseOperationFacade) void
setSecurityService
(SecurityService securityService) void
setSitesServiceInternal
(SitesService sitesServiceInternal) void
setSiteState
(String siteId, String state) void
setStudioConfiguration
(StudioConfiguration studioConfiguration) void
setStudioDBScriptRunner
(StudioDBScriptRunnerFactory studioDBScriptRunner) void
setUpgradeManager
(StudioUpgradeManager upgradeManager) void
setUserDao
(UserDAO userDao) void
setUserServiceInternal
(UserServiceInternal userServiceInternal) void
setWorkflowServiceInternal
(WorkflowServiceInternal workflowServiceInternal) void
updateLastCommitId
(String site, String commitId) @jakarta.validation.Valid boolean
updatePublishingStatus
(String siteId, String status) Update publishing status message for given site
-
Field Details
-
deployer
-
contentService
-
contentRepository
-
contentRepositoryV2
-
dependencyService
-
securityService
-
deploymentService
-
groupServiceInternal
-
userServiceInternal
-
upgradeManager
-
studioConfiguration
-
sitesServiceInternal
-
auditServiceInternal
-
configurationService
-
configurationServiceInternal
-
itemServiceInternal
-
workflowServiceInternal
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext -
siteFeedMapper
-
entitlementValidator
protected org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator -
studioDBScriptRunnerFactory
-
dependencyServiceInternal
-
retryingDatabaseOperationFacade
-
userDao
-
-
Constructor Details
-
SiteServiceImpl
public SiteServiceImpl()
-
-
Method Details
-
getAllAvailableSites
- Specified by:
getAllAvailableSites
in interfaceSiteService
-
countSites
public int countSites()- Specified by:
countSites
in interfaceSiteService
-
createSiteFromBlueprint
@Valid public void createSiteFromBlueprint(String blueprintId, @Size(max=50) @Size(max=50) String siteId, String siteName, String sandboxBranch, String desc, Map<String, String> params, boolean createAsOrphan) throws SiteAlreadyExistsException, SiteCreationException, DeployerTargetException, BlueprintNotFoundException, MissingPluginParameterExceptionDescription copied from interface:SiteService
Create a new site based on an existing blueprint- Specified by:
createSiteFromBlueprint
in interfaceSiteService
- Parameters:
blueprintId
- blueprint name to create sitesiteId
- site identifiersiteName
- site namesandboxBranch
- sandbox branch namedesc
- descriptionparams
- site parameterscreateAsOrphan
- create the site from a remote repository as orphan (no git history)- Throws:
SiteAlreadyExistsException
- site already existsSiteCreationException
- error during site creation processDeployerTargetException
- error creating deployer targetsBlueprintNotFoundException
- blueprint not foundMissingPluginParameterException
- missing mandatory blueprint parameters
-
createSiteFromBlueprintGit
protected boolean createSiteFromBlueprintGit(String blueprintLocation, String siteId, String sandboxBranch, Map<String, String> params, String creator) throws Exception- Throws:
Exception
-
replaceFileContentGit
protected void replaceFileContentGit(String site, String path, String find, String replace) throws Exception - Throws:
Exception
-
createSiteWithRemoteOption
@Valid public void createSiteWithRemoteOption(@Size(max=50) @Size(max=50) String siteId, String siteName, String sandboxBranch, String description, String blueprintName, String remoteName, String remoteUrl, String remoteBranch, boolean singleBranch, String authenticationType, String remoteUsername, String remotePassword, String remoteToken, String remotePrivateKey, String createOption, Map<String, String> params, boolean createAsOrphan) throws ServiceLayerException, InvalidRemoteRepositoryException, InvalidRemoteRepositoryCredentialsException, RemoteRepositoryNotFoundExceptionDescription copied from interface:SiteService
Create a new site with remote option (clone from remote or push to remote repository)- Specified by:
createSiteWithRemoteOption
in interfaceSiteService
- Parameters:
siteId
- site identifiersiteName
- the name of the sitesandboxBranch
- sandbox branch namedescription
- descriptionblueprintName
- name of the blueprint to create siteremoteName
- remote repository nameremoteUrl
- remote repository urlremoteBranch
- remote repository branch to create site fromsingleBranch
- clone single branch if true, otherwise clone whole repoauthenticationType
- remote repository authentication typeremoteUsername
- remote repository username to use for authenticationremotePassword
- remote repository username to use for authenticationremoteToken
- remote repository username to use for authenticationremotePrivateKey
- remote repository username to use for authenticationcreateOption
- remote repository username to use for authenticationparams
- site parameterscreateAsOrphan
- create the site from a remote repository as orphan (no git history)- Throws:
ServiceLayerException
- general service errorInvalidRemoteRepositoryException
- invalid remote repositoryInvalidRemoteRepositoryCredentialsException
- invalid credentials for remote repositoryRemoteRepositoryNotFoundException
- remote repository not found
-
deleteSite
Description copied from interface:SiteService
remove a site from the system- Specified by:
deleteSite
in interfaceSiteService
- Parameters:
siteId
- site identifier- Returns:
- true if successfully deleted, otherwise false
-
getAvailableBlueprints
Description copied from interface:SiteService
get a list of available blueprints- Specified by:
getAvailableBlueprints
in interfaceSiteService
- Returns:
- list of blueprints
-
updateLastCommitId
- Specified by:
updateLastCommitId
in interfaceSiteService
-
exists
Description copied from interface:SiteService
Check if site already exists- Specified by:
exists
in interfaceSiteService
- Parameters:
site
- site ID- Returns:
- true if site exists, false otherwise
-
checkSiteExists
Description copied from interface:SiteService
Checks if a site exists. If it does not, it throws aSiteNotFoundException
- Specified by:
checkSiteExists
in interfaceSiteService
- Parameters:
site
- site ID- Throws:
SiteNotFoundException
- if no site is found for the given site ID
-
existsById
Description copied from interface:SiteService
Check if site already exists- Specified by:
existsById
in interfaceSiteService
- Parameters:
siteId
- site ID in DB- Returns:
- true if site exists, false otherwise
-
existsByName
Description copied from interface:SiteService
Check if site already exists- Specified by:
existsByName
in interfaceSiteService
- Parameters:
siteName
- site name in DB- Returns:
- true if site exists, false otherwise
-
getSitesPerUserTotal
@Valid public @jakarta.validation.Valid int getSitesPerUserTotal() throws UserNotFoundException, ServiceLayerExceptionDescription copied from interface:SiteService
Get total number of sites that user is allowed access to for current user- Specified by:
getSitesPerUserTotal
in interfaceSiteService
- Returns:
- number of sites
- Throws:
UserNotFoundException
ServiceLayerException
-
getSitesPerUserTotal
@Valid public @jakarta.validation.Valid int getSitesPerUserTotal(String username) throws UserNotFoundException, ServiceLayerException Description copied from interface:SiteService
Get total number of sites that user is allowed access to for given username- Specified by:
getSitesPerUserTotal
in interfaceSiteService
- Parameters:
username
- username- Returns:
- number of sites
- Throws:
UserNotFoundException
- user not foundServiceLayerException
- general service error
-
getSitesPerUser
@Valid public @Valid List<SiteFeed> getSitesPerUser(int start, int number) throws UserNotFoundException, ServiceLayerException Description copied from interface:SiteService
Get sites that user is allowed access to for current user- Specified by:
getSitesPerUser
in interfaceSiteService
- Parameters:
start
- start position for paginationnumber
- number of sites per page- Returns:
- number of sites
- Throws:
UserNotFoundException
ServiceLayerException
-
getSitesPerUser
@Valid public @Valid List<SiteFeed> getSitesPerUser(String username, int start, int number) throws UserNotFoundException, ServiceLayerException Description copied from interface:SiteService
Get sites that user is allowed access to for given username- Specified by:
getSitesPerUser
in interfaceSiteService
- Parameters:
username
- usernamestart
- start position for paginationnumber
- number of sites per page- Returns:
- number of sites
- Throws:
UserNotFoundException
- user not foundServiceLayerException
- general service error
-
getSite
Description copied from interface:SiteService
Get site feed for given site- Specified by:
getSite
in interfaceSiteService
- Parameters:
siteId
- site id- Returns:
- SiteFeed object for the requested site
- Throws:
SiteNotFoundException
- site not found
-
getSiteDetails
Description copied from interface:SiteService
Get site details. This will include the site feed info and the blob store configuration details- Specified by:
getSiteDetails
in interfaceSiteService
- Parameters:
siteId
- site id- Returns:
- SiteDetails object for the requested site
- Throws:
ServiceLayerException
- if an error occurs while retrieving the site details
-
isPublishingEnabled
Description copied from interface:SiteService
Check if publishing is enabled for given site- Specified by:
isPublishingEnabled
in interfaceSiteService
- Parameters:
siteId
- site id- Returns:
- true if publishing is enabled for given site, otherwise false
-
enablePublishing
@Valid public @jakarta.validation.Valid boolean enablePublishing(String siteId, boolean enabled) throws SiteNotFoundException Description copied from interface:SiteService
Enable/Disable publishing for given site- Specified by:
enablePublishing
in interfaceSiteService
- Parameters:
siteId
- site idenabled
- true to enable publishing, false to disable publishing- Returns:
- true if operation was successful, otherwise false
- Throws:
SiteNotFoundException
- site not found
-
updatePublishingStatus
@Valid public @jakarta.validation.Valid boolean updatePublishingStatus(String siteId, String status) throws SiteNotFoundException Description copied from interface:SiteService
Update publishing status message for given site- Specified by:
updatePublishingStatus
in interfaceSiteService
- Parameters:
siteId
- site idstatus
- status- Returns:
- true if publishing status message is successfully updated
- Throws:
SiteNotFoundException
- site not found
-
addRemote
public boolean addRemote(String siteId, String remoteName, String remoteUrl, String authenticationType, String remoteUsername, String remotePassword, String remoteToken, String remotePrivateKey) throws InvalidRemoteUrlException, ServiceLayerException Description copied from interface:SiteService
Add remote repository for site content repository- Specified by:
addRemote
in interfaceSiteService
- Parameters:
siteId
- site identifierremoteName
- remote nameremoteUrl
- remote urlauthenticationType
- authentication typeremoteUsername
- remote usernameremotePassword
- remote passwordremoteToken
- remote tokenremotePrivateKey
- remote private key- Returns:
- true if operation was successful
- Throws:
InvalidRemoteUrlException
- invalid remote urlServiceLayerException
- general service error
-
removeRemote
Description copied from interface:SiteService
Remove remote with given name for site- Specified by:
removeRemote
in interfaceSiteService
- Parameters:
siteId
- site identifierremoteName
- remote name- Returns:
- true if operation was successful
- Throws:
SiteNotFoundException
- site not found
-
listRemote
public List<RemoteRepositoryInfoTO> listRemote(String siteId) throws ServiceLayerException, org.craftercms.commons.crypto.CryptoException Description copied from interface:SiteService
List remote repositories for given site- Specified by:
listRemote
in interfaceSiteService
- Parameters:
siteId
- site identifier- Returns:
- list of names of remote repositories
- Throws:
org.craftercms.commons.crypto.CryptoException
- git repository helper errorServiceLayerException
-
getDeletedSites
Description copied from interface:SiteService
Get deleted sites- Specified by:
getDeletedSites
in interfaceSiteService
- Returns:
- List of deleted sites from DB
-
getAllCreatedSites
Description copied from interface:SiteService
Get list of all sites with state = CREATED- Specified by:
getAllCreatedSites
in interfaceSiteService
- Returns:
- list of sites
-
setSiteState
- Specified by:
setSiteState
in interfaceSiteService
-
getSiteState
- Specified by:
getSiteState
in interfaceSiteService
-
isPublishedRepoCreated
- Specified by:
isPublishedRepoCreated
in interfaceSiteService
-
setPublishedRepoCreated
- Specified by:
setPublishedRepoCreated
in interfaceSiteService
-
getDefaultGroups
-
setApplicationContext
public void setApplicationContext(@NonNull org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-
setContentService
-
setContentRepository
-
setDependencyService
-
setSecurityService
-
setDeploymentService
-
setStudioConfiguration
-
setDeployer
-
setEntitlementValidator
public void setEntitlementValidator(org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator) -
setGroupServiceInternal
-
setUserServiceInternal
-
setUpgradeManager
-
setSitesServiceInternal
-
setAuditServiceInternal
-
setConfigurationService
-
setConfigurationServiceInternal
-
setContentRepositoryV2
-
setItemServiceInternal
-
setWorkflowServiceInternal
-
setStudioDBScriptRunner
-
setDependencyServiceInternal
-
setRetryingDatabaseOperationFacade
public void setRetryingDatabaseOperationFacade(RetryingDatabaseOperationFacade retryingDatabaseOperationFacade) -
setUserDao
-