Class MarketplaceServiceInternalImpl
java.lang.Object
org.craftercms.studio.impl.v2.service.marketplace.internal.MarketplaceServiceInternalImpl
- All Implemented Interfaces:
MarketplaceServiceInternal,org.springframework.beans.factory.InitializingBean
public class MarketplaceServiceInternalImpl
extends Object
implements MarketplaceServiceInternal, org.springframework.beans.factory.InitializingBean
Default implementation of
MarketplaceServiceInternal that proxies all request to the configured Marketplace- Since:
- 3.1.2
- Author:
- joseross
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ConfigurationServicestatic final Stringprotected final ContentServiceprotected StringRegular expression used to detect content-type definition filesprotected final ContentTypeServiceprotected final DependencyServiceprotected final DeploymentServiceprotected StringThe current CrafterCMS edition, sent with all requestsstatic final StringFolder mappings to use during plugin installationprotected final GitRepositoryHelperprotected org.springframework.http.HttpHeadersThe custom HTTP headers to sent with all requestsstatic final StringList of plugin types that can be installedprotected final InstanceServiceprotected final ReadWriteLockprotected com.fasterxml.jackson.databind.ObjectMapperstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Stringprotected Stringprotected final Stringprotected final org.craftercms.commons.plugin.PluginDescriptorReaderprotected StringThe path of the plugin registry in the siteprotected StringName of the folder to copy all plugin filesprotected final Lockprotected final org.craftercms.commons.rest.RestTemplateprotected RetryingRepositoryOperationFacadeprotected booleanIndicates if the search should include plugins pending of approvalprotected final SiteServiceprotected final SitesServiceprotected final StudioConfigurationstatic final Stringstatic final Stringstatic final Stringprotected StringCode injected in the templates for each pluginprotected StringComment added in the templates for each pluginMapping used to wire plugin files into the site templatesprotected StringThe Marketplace URL to useprotected StringThe current CrafterCMS version, sent with all requestsstatic final Stringstatic final Stringprotected org.apache.commons.configuration2.HierarchicalConfiguration<?> Mapping used to wire plugin files into the site configurationprotected org.springframework.core.io.ResourceXSLT template used to remove wired configurationsprotected final LockFields inherited from interface org.craftercms.studio.api.v2.service.marketplace.internal.MarketplaceServiceInternal
HEADER_JAVA_VERSION, HEADER_OS_ARCH, HEADER_OS_NAME, HEADER_OS_VERSION, HEADER_STUDIO_BUILD, HEADER_STUDIO_ID, HEADER_STUDIO_VERSION -
Constructor Summary
ConstructorsConstructorDescriptionMarketplaceServiceInternalImpl(InstanceService instanceService, SiteService siteService, SitesService sitesServiceInternal, ContentService contentService, StudioConfiguration studioConfiguration, org.craftercms.commons.plugin.PluginDescriptorReader pluginDescriptorReader, GitRepositoryHelper gitRepositoryHelper, String pluginDescriptorFilename, String templateCode, String templateComment, RetryingRepositoryOperationFacade retryingRepositoryOperationFacade, DeploymentService deploymentService, DependencyService dependencyService, ContentTypeService contentTypeService, ConfigurationService configurationService) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddIncludeIfNeeded(String siteId, String pluginId, List<String> paths, String includePath, String includeComment, String pluginPath, List<String> changedFiles) protected voidaddPluginToRegistry(String siteId, org.craftercms.commons.plugin.model.Plugin plugin, List<FileRecord> files, List<ConfigRecord> wiring) voidprotected org.dom4j.ElementbuildXml(org.craftercms.commons.plugin.model.Installation.Element element) protected voidclonePluginFromGit(MarketplacePlugin plugin, Path directory) protected voidcommitChanges(String siteId, List<String> changedFiles, boolean update, boolean publish, String message) voidCopy a plugin in a siteprotected List<FileRecord> copyPluginFiles(Path pluginDir, String siteId, org.craftercms.commons.plugin.model.Plugin plugin, Map<String, String> params) protected voidcreatePluginConfig(Path siteDir, String pluginId, Map<String, String> parameters, List<String> changedFiles) voidcreateSite(CreateSiteRequest request) Creates a site using the given blueprintprotected StringgetConfigurationPath(String module, String filePath) protected MarketplacePlugingetDescriptor(String id, org.craftercms.commons.plugin.model.Version version) getInstalledPlugins(String siteId) Returns a list of the plugins currently installed in the given siteorg.apache.commons.configuration2.HierarchicalConfiguration<?> getPluginConfiguration(String siteId, String pluginId) Load the configuration for a given plugin as an objectgetPluginConfigurationAsString(String siteId, String pluginId) Load the configuration for a given plugin as a stringprotected Optional<PluginRecord> getPluginRecord(String siteId, String pluginId) protected PluginRegistrygetPluginRegistry(String siteId) getPluginUsage(String siteId, String pluginId) List dependant items for a pluginprotected PathgetRepoDirectory(String siteId) voidinstallPlugin(String siteId, String pluginId, org.craftercms.commons.plugin.model.Version pluginVersion, Map<String, String> parameters) Install a plugin in a siteprotected booleanisPluginAlreadyInstalled(String siteId, String pluginId) protected voidperformConfigurationWiring(org.craftercms.commons.plugin.model.Plugin plugin, String siteId, List<String> changedFiles, List<ConfigRecord> wiring) protected voidperformTemplateWiring(org.craftercms.commons.plugin.model.Plugin plugin, String siteId, List<FileRecord> files, List<String> changedFiles) protected voidremoveConfigurationWiring(String pluginId, String siteId, List<String> changedFiles, List<ConfigRecord> changedConfigurations) voidremovePlugin(String siteId, String pluginId, boolean force) Removes a plugin from a siteprotected voidremovePluginConfig(Path siteDir, String pluginId, List<String> changedFiles) protected voidremovePluginFromRegistry(String siteId, String pluginId) protected voidremoveTemplateWiring(String pluginId, String siteId, List<String> changedFiles) protected voidresetChanges(String siteId, List<String> changedFiles) searchPlugins(String type, String keywords, boolean showIncompatible, long offset, long limit) Performs a search for all available plugins that match the given filtersvoidsetPluginRegistryPath(String pluginRegistryPath) voidsetPluginsFolder(String pluginsFolder) voidsetShowPending(boolean showPending) voidprotected voidvalidate()voidwritePluginConfiguration(String siteId, String pluginId, String content) Writes the configuration for a given plugin
-
Field Details
-
INSTALLABLE_TYPES_CONFIG_KEY
- See Also:
-
FOLDER_MAPPING_CONFIG_KEY
- See Also:
-
WIDGET_MAPPING_CONFIG_KEY
- See Also:
-
WIDGET_REMOVE_CONFIG_KEY
- See Also:
-
TEMPLATE_MAPPING_CONFIG_KEY
- See Also:
-
CONTENT_TYPE_PATTERN_CONFIG_KEY
- See Also:
-
PLUGIN_CONFIG_MODULE_CONFIG_KEY
- See Also:
-
PLUGIN_CONFIG_FILENAME_CONFIG_KEY
- See Also:
-
MODULE_CONFIG_KEY
- See Also:
-
PATH_CONFIG_KEY
- See Also:
-
TEMPLATE_CONFIG_KEY
- See Also:
-
SYSTEM_PATH_KEY
- See Also:
-
PLUGIN_PATTERN_KEY
- See Also:
-
PARAM_NEW_XML
- See Also:
-
PARAM_PARENT_XPATH
- See Also:
-
PARAM_PLUGIN_ID
- See Also:
-
PARAM_PLUGIN_PATH
- See Also:
-
instanceService
-
siteService
-
sitesServiceInternal
-
contentService
-
studioConfiguration
-
gitRepositoryHelper
-
pluginDescriptorReader
protected final org.craftercms.commons.plugin.PluginDescriptorReader pluginDescriptorReader -
pluginDescriptorFilename
-
restTemplate
protected final org.craftercms.commons.rest.RestTemplate restTemplate -
mapper
protected com.fasterxml.jackson.databind.ObjectMapper mapper -
lock
-
readLock
-
writeLock
-
configurationService
-
httpHeaders
protected org.springframework.http.HttpHeaders httpHeadersThe custom HTTP headers to sent with all requests -
version
The current CrafterCMS version, sent with all requests -
edition
The current CrafterCMS edition, sent with all requests -
url
The Marketplace URL to use -
pluginRegistryPath
The path of the plugin registry in the site -
showPending
protected boolean showPendingIndicates if the search should include plugins pending of approval -
installableTypes
List of plugin types that can be installed -
folderMapping
Folder mappings to use during plugin installation -
pluginsFolder
Name of the folder to copy all plugin files -
widgetMapping
protected org.apache.commons.configuration2.HierarchicalConfiguration<?> widgetMappingMapping used to wire plugin files into the site configuration -
widgetRemoveTemplate
protected org.springframework.core.io.Resource widgetRemoveTemplateXSLT template used to remove wired configurations -
templateMapping
Mapping used to wire plugin files into the site templates -
templateCode
Code injected in the templates for each plugin -
templateComment
Comment added in the templates for each plugin -
contentTypePattern
Regular expression used to detect content-type definition files -
pluginConfigModule
-
pluginConfigFilename
-
retryingRepositoryOperationFacade
-
deploymentService
-
dependencyService
-
contentTypeService
-
-
Constructor Details
-
MarketplaceServiceInternalImpl
@ConstructorProperties({"instanceService","siteService","sitesServiceInternal","contentService","studioConfiguration","pluginDescriptorReader","gitRepositoryHelper","pluginDescriptorFilename","templateCode","templateComment","retryingRepositoryOperationFacade","deploymentService","dependencyService","contentTypeService","configurationService"}) public MarketplaceServiceInternalImpl(InstanceService instanceService, SiteService siteService, SitesService sitesServiceInternal, ContentService contentService, StudioConfiguration studioConfiguration, org.craftercms.commons.plugin.PluginDescriptorReader pluginDescriptorReader, GitRepositoryHelper gitRepositoryHelper, String pluginDescriptorFilename, String templateCode, String templateComment, RetryingRepositoryOperationFacade retryingRepositoryOperationFacade, DeploymentService deploymentService, DependencyService dependencyService, ContentTypeService contentTypeService, ConfigurationService configurationService)
-
-
Method Details
-
setUrl
-
setPluginRegistryPath
-
setShowPending
public void setShowPending(boolean showPending) -
setPluginsFolder
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
IOException
-
searchPlugins
public Map<String,Object> searchPlugins(String type, String keywords, boolean showIncompatible, long offset, long limit) throws MarketplaceException Description copied from interface:MarketplaceServiceInternalPerforms a search for all available plugins that match the given filters- Specified by:
searchPluginsin interfaceMarketplaceServiceInternal- Parameters:
type- the type of plugins to searchkeywords- the keywords to filter pluginsshowIncompatible- indicates if incompatible plugins should be returnedoffset- the offset for paginationlimit- the limit for pagination- Returns:
- the result from the Marketplace
- Throws:
MarketplaceException- if there is any error performing the search
-
validate
- Throws:
MarketplaceException
-
getDescriptor
protected MarketplacePlugin getDescriptor(String id, org.craftercms.commons.plugin.model.Version version) throws MarketplaceException - Throws:
MarketplaceException
-
createSite
public void createSite(CreateSiteRequest request) throws RemoteRepositoryNotFoundException, InvalidRemoteRepositoryException, InvalidRemoteUrlException, ServiceLayerException, InvalidRemoteRepositoryCredentialsException Description copied from interface:MarketplaceServiceInternalCreates a site using the given blueprint- Specified by:
createSitein interfaceMarketplaceServiceInternal- Parameters:
request- the site information- Throws:
RemoteRepositoryNotFoundException- if there is an error with the remote repositoryInvalidRemoteRepositoryException- if there is an error with the remote repositoryInvalidRemoteUrlException- if there is an error with the remote repositoryServiceLayerException- if there is any unexpected errorInvalidRemoteRepositoryCredentialsException- if there is any error with the credentials
-
getInstalledPlugins
Description copied from interface:MarketplaceServiceInternalReturns a list of the plugins currently installed in the given site- Specified by:
getInstalledPluginsin interfaceMarketplaceServiceInternal- Parameters:
siteId- the id of the site- Returns:
- the list of plugins
- Throws:
MarketplaceException- if there is any error reading the plugin registry
-
getPluginRegistry
- Throws:
MarketplaceRegistryException
-
installPlugin
public void installPlugin(String siteId, String pluginId, org.craftercms.commons.plugin.model.Version pluginVersion, Map<String, String> parameters) throws MarketplaceExceptionDescription copied from interface:MarketplaceServiceInternalInstall a plugin in a site- Specified by:
installPluginin interfaceMarketplaceServiceInternal- Parameters:
siteId- the id of the sitepluginId- the id of the pluginpluginVersion- the version of the pluginparameters- the parameters for the plugin- Throws:
MarketplaceException- if there is any error installing the plugin
-
isPluginAlreadyInstalled
protected boolean isPluginAlreadyInstalled(String siteId, String pluginId) throws MarketplaceException - Throws:
MarketplaceException
-
clonePluginFromGit
protected void clonePluginFromGit(MarketplacePlugin plugin, Path directory) throws PluginInstallationException - Throws:
PluginInstallationException
-
copyPluginFiles
protected List<FileRecord> copyPluginFiles(Path pluginDir, String siteId, org.craftercms.commons.plugin.model.Plugin plugin, Map<String, String> params) throws IOException- Throws:
IOException
-
addPluginToRegistry
protected void addPluginToRegistry(String siteId, org.craftercms.commons.plugin.model.Plugin plugin, List<FileRecord> files, List<ConfigRecord> wiring) throws MarketplaceRegistryException, IOException -
removePluginFromRegistry
protected void removePluginFromRegistry(String siteId, String pluginId) throws MarketplaceRegistryException, IOException -
copyPlugin
public void copyPlugin(String siteId, String localPath, Map<String, String> parameters) throws MarketplaceExceptionDescription copied from interface:MarketplaceServiceInternalCopy a plugin in a site- Specified by:
copyPluginin interfaceMarketplaceServiceInternal- Parameters:
siteId- the id of the sitelocalPath- the path of the plugin folderparameters- the parameters for the plugin- Throws:
MarketplaceException- if there is any error copying the plugin
-
removePlugin
public void removePlugin(String siteId, String pluginId, boolean force) throws ServiceLayerException Description copied from interface:MarketplaceServiceInternalRemoves a plugin from a site- Specified by:
removePluginin interfaceMarketplaceServiceInternal- Parameters:
siteId- the id of the sitepluginId- the id of the pluginforce- indicates if the plugin should be removed even if there are dependant items- Throws:
ServiceLayerException
-
getPluginConfiguration
public org.apache.commons.configuration2.HierarchicalConfiguration<?> getPluginConfiguration(String siteId, String pluginId) throws ConfigurationException Description copied from interface:MarketplaceServiceInternalLoad the configuration for a given plugin as an object- Specified by:
getPluginConfigurationin interfaceMarketplaceServiceInternal- Parameters:
siteId- the id of the sitepluginId- the id of the plugin- Returns:
- the configuration object
- Throws:
ConfigurationException- if there is any error loading the configuration
-
getPluginConfigurationAsString
public String getPluginConfigurationAsString(String siteId, String pluginId) throws ContentNotFoundException Description copied from interface:MarketplaceServiceInternalLoad the configuration for a given plugin as a string- Specified by:
getPluginConfigurationAsStringin interfaceMarketplaceServiceInternal- Parameters:
siteId- the id of the sitepluginId- the id of the plugin- Returns:
- the configuration string
- Throws:
ContentNotFoundException- if there is any issue reading the file from the repository
-
writePluginConfiguration
public void writePluginConfiguration(String siteId, String pluginId, String content) throws UserNotFoundException, ServiceLayerException Description copied from interface:MarketplaceServiceInternalWrites the configuration for a given plugin- Specified by:
writePluginConfigurationin interfaceMarketplaceServiceInternal- Parameters:
siteId- the id of the sitepluginId- the id of the plugincontent- the new configuration- Throws:
UserNotFoundException- if there is any error authenticating the userServiceLayerException- if there is any error writing the configuration
-
createPluginConfig
protected void createPluginConfig(Path siteDir, String pluginId, Map<String, String> parameters, List<String> changedFiles) throws IOException, org.apache.commons.configuration2.ex.ConfigurationException- Throws:
IOExceptionorg.apache.commons.configuration2.ex.ConfigurationException
-
removePluginConfig
protected void removePluginConfig(Path siteDir, String pluginId, List<String> changedFiles) throws IOException - Throws:
IOException
-
getPluginRecord
protected Optional<PluginRecord> getPluginRecord(String siteId, String pluginId) throws MarketplaceRegistryException - Throws:
MarketplaceRegistryException
-
getPluginUsage
Description copied from interface:MarketplaceServiceInternalList dependant items for a plugin- Specified by:
getPluginUsagein interfaceMarketplaceServiceInternal- Parameters:
siteId- the id of the sitepluginId- the id of the plugin- Throws:
ServiceLayerException- if there is any error getting the dependant items
-
getRepoDirectory
-
resetChanges
protected void resetChanges(String siteId, List<String> changedFiles) throws IOException, org.eclipse.jgit.api.errors.GitAPIException - Throws:
IOExceptionorg.eclipse.jgit.api.errors.GitAPIException
-
commitChanges
protected void commitChanges(String siteId, List<String> changedFiles, boolean update, boolean publish, String message) throws IOException, org.eclipse.jgit.api.errors.GitAPIException, ServiceLayerException, UserNotFoundException - Throws:
IOExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionServiceLayerExceptionUserNotFoundException
-
performConfigurationWiring
protected void performConfigurationWiring(org.craftercms.commons.plugin.model.Plugin plugin, String siteId, List<String> changedFiles, List<ConfigRecord> wiring) throws TransformerException, IOException, ServiceLayerException, org.dom4j.DocumentException - Throws:
TransformerExceptionIOExceptionServiceLayerExceptionorg.dom4j.DocumentException
-
performTemplateWiring
protected void performTemplateWiring(org.craftercms.commons.plugin.model.Plugin plugin, String siteId, List<FileRecord> files, List<String> changedFiles) throws IOException - Throws:
IOException
-
addIncludeIfNeeded
protected void addIncludeIfNeeded(String siteId, String pluginId, List<String> paths, String includePath, String includeComment, String pluginPath, List<String> changedFiles) throws IOException - Throws:
IOException
-
buildXml
protected org.dom4j.Element buildXml(org.craftercms.commons.plugin.model.Installation.Element element) -
removeTemplateWiring
protected void removeTemplateWiring(String pluginId, String siteId, List<String> changedFiles) throws IOException - Throws:
IOException
-
removeConfigurationWiring
protected void removeConfigurationWiring(String pluginId, String siteId, List<String> changedFiles, List<ConfigRecord> changedConfigurations) throws IOException, TransformerException - Throws:
IOExceptionTransformerException
-
getConfigurationPath
-