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.ApplicationContextprotected AuditServiceInternalprotected String[]protected ConfigurationServiceprotected ConfigurationServiceprotected ContentRepositoryprotected ContentRepositoryprotected ContentServiceprotected DependencyServiceprotected DependencyServiceInternalprotected Deployerprotected DeploymentServiceprotected DmPageNavigationOrderServiceprotected org.craftercms.commons.entitlements.validator.EntitlementValidatorprotected GroupServiceInternalprotected ItemServiceInternalprotected RebuildRepositoryMetadataprotected RetryingDatabaseOperationFacadeprotected SecurityServiceprotected SiteFeedMapperprotected SitesServiceprotected StudioConfigurationprotected StudioDBScriptRunnerFactoryprotected SyncDatabaseWithRepositoryprotected StudioUpgradeManagerprotected UserDAOprotected UserServiceInternalprotected WorkflowServiceInternal -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddRemote(String siteId, String remoteName, String remoteUrl, String authenticationType, String remoteUsername, String remotePassword, String remoteToken, String remotePrivateKey) Add remote repository for site content repositoryvoidcheckSiteExists(String site) Checks if a site exists.booleancheckSiteUuid(String siteId, String siteUuid) Checks if the currently existent site with the given ID also has the same siteUuid.intvoidcreateSiteFromBlueprint(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 booleancreateSiteFromBlueprintGit(String blueprintLocation, String siteId, String sandboxBranch, Map<String, String> params, String creator) voidcreateSiteWithRemoteOption(@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)@javax.validation.Valid booleandeleteSite(String siteId) remove a site from the system@javax.validation.Valid booleanenablePublishing(String siteId, boolean enabled) Enable/Disable publishing for given site@javax.validation.Valid booleanCheck if site already exists@javax.validation.Valid booleanexistsById(String siteId) Check if site already exists@javax.validation.Valid booleanexistsByName(String siteName) Check if site already existsGet list of all sites with state = CREATEDget a list of available blueprintsGet deleted sitesgetLastCommitId(String siteId) get last commit id for sitegetLastSyncedGitlogCommitId(String siteId) get last audited git log commit id for sitegetLastVerifiedGitlogCommitId(String siteId) get last verified git log commit id for site@Valid SiteFeedGet 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@javax.validation.Valid intGet total number of sites that user is allowed access to for current user@javax.validation.Valid intgetSitesPerUserTotal(String username) Get total number of sites that user is allowed access to for given usernamegetSiteState(String siteId) protected voidinvalidateConfigurationCacheIfRequired(String siteId, String path) booleanisPublishedRepoCreated(String siteId) @javax.validation.Valid booleanisPublishingEnabled(String siteId) Check if publishing is enabled for given sitelistRemote(String siteId) List remote repositories for given sitevoidrebuildDatabase(String site) Rebuild database for sitebooleanremoveRemote(String siteId, String remoteName) Remove remote with given name for siteprotected voidreplaceFileContentGit(String site, String path, String find, String replace) voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetAuditServiceInternal(AuditServiceInternal auditServiceInternal) voidsetConfigurationPatterns(String[] configurationPatterns) voidsetConfigurationService(ConfigurationService configurationService) voidsetConfigurationServiceInternal(ConfigurationService configurationServiceInternal) voidvoidsetContentRepositoryV2(ContentRepository contentRepositoryV2) voidsetContentService(ContentService contentService) voidsetDependencyService(DependencyService dependencyService) voidsetDependencyServiceInternal(DependencyServiceInternal dependencyServiceInternal) voidsetDeployer(Deployer deployer) voidsetDeploymentService(DeploymentService deploymentService) voidsetDmPageNavigationOrderService(DmPageNavigationOrderService dmPageNavigationOrderService) voidsetEntitlementValidator(org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator) voidsetGroupServiceInternal(GroupServiceInternal groupServiceInternal) voidsetItemServiceInternal(ItemServiceInternal itemServiceInternal) voidsetPublishedRepoCreated(String siteId) voidsetRebuildRepositoryMetadata(RebuildRepositoryMetadata rebuildRepositoryMetadata) voidsetRetryingDatabaseOperationFacade(RetryingDatabaseOperationFacade retryingDatabaseOperationFacade) voidsetSecurityService(SecurityService securityService) voidsetSitesServiceInternal(SitesService sitesServiceInternal) voidsetSiteState(String siteId, String state) voidsetStudioConfiguration(StudioConfiguration studioConfiguration) voidsetStudioDBScriptRunner(StudioDBScriptRunnerFactory studioDBScriptRunner) voidsetSyncDatabaseWithRepository(SyncDatabaseWithRepository syncDatabaseWithRepository) voidsetUpgradeManager(StudioUpgradeManager upgradeManager) voidsetUserDao(UserDAO userDao) voidsetUserServiceInternal(UserServiceInternal userServiceInternal) voidsetWorkflowServiceInternal(WorkflowServiceInternal workflowServiceInternal) @javax.validation.Valid booleansyncDatabaseWithRepo(String site, String fromCommitId) Synchronize our internal database with the underlying repository.@javax.validation.Valid booleansyncDatabaseWithRepo(String site, String fromCommitId, boolean generateAuditLog) Synchronize our internal database with the underlying repository.voidsyncRepository(String site) Synchronize Database with repositoryvoidupdateLastCommitId(String site, String commitId) voidupdateLastSyncedGitlogCommitId(String site, String commitId) Update last audited gitlog commit idvoidupdateLastVerifiedGitlogCommitId(String site, String commitId) @javax.validation.Valid booleanupdatePublishingStatus(String siteId, String status) Update publishing status message for given site
-
Field Details
-
deployer
-
contentService
-
contentRepository
-
contentRepositoryV2
-
dependencyService
-
securityService
-
deploymentService
-
rebuildRepositoryMetadata
-
syncDatabaseWithRepository
-
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 -
configurationPatterns
-
studioDBScriptRunnerFactory
-
dependencyServiceInternal
-
retryingDatabaseOperationFacade
-
userDao
-
-
Constructor Details
-
SiteServiceImpl
public SiteServiceImpl()
-
-
Method Details
-
getAllAvailableSites
- Specified by:
getAllAvailableSitesin interfaceSiteService
-
countSites
public int countSites()- Specified by:
countSitesin 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:SiteServiceCreate a new site based on an existing blueprint- Specified by:
createSiteFromBlueprintin 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, RemoteRepositoryNotFoundException, InvalidRemoteUrlExceptionDescription copied from interface:SiteServiceCreate a new site with remote option (clone from remote or push to remote repository)- Specified by:
createSiteWithRemoteOptionin 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 foundInvalidRemoteUrlException- invalid remote url
-
deleteSite
Description copied from interface:SiteServiceremove a site from the system- Specified by:
deleteSitein interfaceSiteService- Parameters:
siteId- site identifier- Returns:
- true if successfully deleted, otherwise false
-
getAvailableBlueprints
Description copied from interface:SiteServiceget a list of available blueprints- Specified by:
getAvailableBlueprintsin interfaceSiteService- Returns:
- list of blueprints
-
syncRepository
Description copied from interface:SiteServiceSynchronize Database with repository- Specified by:
syncRepositoryin interfaceSiteService- Parameters:
site- site id- Throws:
SiteNotFoundException- site not found
-
rebuildDatabase
Description copied from interface:SiteServiceRebuild database for site- Specified by:
rebuildDatabasein interfaceSiteService- Parameters:
site- site id
-
updateLastCommitId
- Specified by:
updateLastCommitIdin interfaceSiteService
-
updateLastVerifiedGitlogCommitId
- Specified by:
updateLastVerifiedGitlogCommitIdin interfaceSiteService
-
updateLastSyncedGitlogCommitId
Description copied from interface:SiteServiceUpdate last audited gitlog commit id- Specified by:
updateLastSyncedGitlogCommitIdin interfaceSiteService- Parameters:
site- site identifiercommitId- commit ID
-
syncDatabaseWithRepo
@Valid public @javax.validation.Valid boolean syncDatabaseWithRepo(String site, String fromCommitId) Description copied from interface:SiteServiceSynchronize our internal database with the underlying repository. This is required when a user bypasses the UI and manipulates the underlying repository directly.- Specified by:
syncDatabaseWithRepoin interfaceSiteService- Parameters:
site- site to syncfromCommitId- commit ID to start at and sync up until current commit- Returns:
- true if successful, false otherwise
-
syncDatabaseWithRepo
@Valid public @javax.validation.Valid boolean syncDatabaseWithRepo(String site, String fromCommitId, boolean generateAuditLog) Description copied from interface:SiteServiceSynchronize our internal database with the underlying repository. This is required when a user bypasses the UI and manipulates the underlying repository directly.- Specified by:
syncDatabaseWithRepoin interfaceSiteService- Parameters:
site- site to syncfromCommitId- commit ID to start at and sync up until current commitgenerateAuditLog- if true add operations to audit log- Returns:
- true if successful, false otherwise
-
invalidateConfigurationCacheIfRequired
-
exists
Description copied from interface:SiteServiceCheck if site already exists- Specified by:
existsin interfaceSiteService- Parameters:
site- site ID- Returns:
- true if site exists, false otherwise
-
checkSiteExists
Description copied from interface:SiteServiceChecks if a site exists. If it does not, it throws aSiteNotFoundException- Specified by:
checkSiteExistsin interfaceSiteService- Parameters:
site- site ID- Throws:
SiteNotFoundException- if no site is found for the given site ID
-
existsById
Description copied from interface:SiteServiceCheck if site already exists- Specified by:
existsByIdin interfaceSiteService- Parameters:
siteId- site ID in DB- Returns:
- true if site exists, false otherwise
-
existsByName
Description copied from interface:SiteServiceCheck if site already exists- Specified by:
existsByNamein interfaceSiteService- Parameters:
siteName- site name in DB- Returns:
- true if site exists, false otherwise
-
getSitesPerUserTotal
@Valid public @javax.validation.Valid int getSitesPerUserTotal() throws UserNotFoundException, ServiceLayerExceptionDescription copied from interface:SiteServiceGet total number of sites that user is allowed access to for current user- Specified by:
getSitesPerUserTotalin interfaceSiteService- Returns:
- number of sites
- Throws:
UserNotFoundExceptionServiceLayerException
-
getSitesPerUserTotal
@Valid public @javax.validation.Valid int getSitesPerUserTotal(String username) throws UserNotFoundException, ServiceLayerException Description copied from interface:SiteServiceGet total number of sites that user is allowed access to for given username- Specified by:
getSitesPerUserTotalin 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:SiteServiceGet sites that user is allowed access to for current user- Specified by:
getSitesPerUserin interfaceSiteService- Parameters:
start- start position for paginationnumber- number of sites per page- Returns:
- number of sites
- Throws:
UserNotFoundExceptionServiceLayerException
-
getSitesPerUser
@Valid public @Valid List<SiteFeed> getSitesPerUser(String username, int start, int number) throws UserNotFoundException, ServiceLayerException Description copied from interface:SiteServiceGet sites that user is allowed access to for given username- Specified by:
getSitesPerUserin 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:SiteServiceGet site feed for given site- Specified by:
getSitein interfaceSiteService- Parameters:
siteId- site id- Returns:
- SiteFeed object for the requested site
- Throws:
SiteNotFoundException- site not found
-
getSiteDetails
Description copied from interface:SiteServiceGet site details. This will include the site feed info and the blob store configuration details- Specified by:
getSiteDetailsin 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:SiteServiceCheck if publishing is enabled for given site- Specified by:
isPublishingEnabledin interfaceSiteService- Parameters:
siteId- site id- Returns:
- true if publishing is enabled for given site, otherwise false
-
enablePublishing
@Valid public @javax.validation.Valid boolean enablePublishing(String siteId, boolean enabled) throws SiteNotFoundException Description copied from interface:SiteServiceEnable/Disable publishing for given site- Specified by:
enablePublishingin 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 @javax.validation.Valid boolean updatePublishingStatus(String siteId, String status) throws SiteNotFoundException Description copied from interface:SiteServiceUpdate publishing status message for given site- Specified by:
updatePublishingStatusin 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:SiteServiceAdd remote repository for site content repository- Specified by:
addRemotein 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:SiteServiceRemove remote with given name for site- Specified by:
removeRemotein 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:SiteServiceList remote repositories for given site- Specified by:
listRemotein 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:SiteServiceGet deleted sites- Specified by:
getDeletedSitesin interfaceSiteService- Returns:
- List of deleted sites from DB
-
getLastCommitId
Description copied from interface:SiteServiceget last commit id for site- Specified by:
getLastCommitIdin interfaceSiteService- Parameters:
siteId- site identifier- Returns:
- last commit id for local studio node
-
getLastVerifiedGitlogCommitId
Description copied from interface:SiteServiceget last verified git log commit id for site- Specified by:
getLastVerifiedGitlogCommitIdin interfaceSiteService- Parameters:
siteId- site identifier- Returns:
- last verified git log commit id for local studio node
-
getAllCreatedSites
Description copied from interface:SiteServiceGet list of all sites with state = CREATED- Specified by:
getAllCreatedSitesin interfaceSiteService- Returns:
- list of sites
-
setSiteState
- Specified by:
setSiteStatein interfaceSiteService
-
getSiteState
- Specified by:
getSiteStatein interfaceSiteService
-
isPublishedRepoCreated
- Specified by:
isPublishedRepoCreatedin interfaceSiteService
-
setPublishedRepoCreated
- Specified by:
setPublishedRepoCreatedin interfaceSiteService
-
getLastSyncedGitlogCommitId
Description copied from interface:SiteServiceget last audited git log commit id for site- Specified by:
getLastSyncedGitlogCommitIdin interfaceSiteService- Parameters:
siteId- site identifier- Returns:
- last audited git log commit id for local studio node
-
getDefaultGroups
-
checkSiteUuid
Description copied from interface:SiteServiceChecks if the currently existent site with the given ID also has the same siteUuid.- Specified by:
checkSiteUuidin interfaceSiteService- Parameters:
siteId- ID of the site to testsiteUuid- site UUID- Returns:
- true if the site UUID file exists and contains the same siteUUID value, false otherwise
-
setApplicationContext
public void setApplicationContext(@NonNull org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
setContentService
-
setContentRepository
-
setDependencyService
-
setSecurityService
-
setDeploymentService
-
setRebuildRepositoryMetadata
-
setSyncDatabaseWithRepository
-
setStudioConfiguration
-
setDeployer
-
setEntitlementValidator
public void setEntitlementValidator(org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator) -
setGroupServiceInternal
-
setUserServiceInternal
-
setUpgradeManager
-
setSitesServiceInternal
-
setAuditServiceInternal
-
setConfigurationService
-
setConfigurationServiceInternal
-
setContentRepositoryV2
-
setItemServiceInternal
-
setConfigurationPatterns
-
setWorkflowServiceInternal
-
setStudioDBScriptRunner
-
setDependencyServiceInternal
-
setRetryingDatabaseOperationFacade
public void setRetryingDatabaseOperationFacade(RetryingDatabaseOperationFacade retryingDatabaseOperationFacade) -
setUserDao
-