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 ConfigurationService
static final String
protected final ContentService
protected String
Regular expression used to detect content-type definition filesprotected final ContentTypeService
protected final DependencyService
protected final DeploymentService
protected String
The current CrafterCMS edition, sent with all requestsstatic final String
Folder mappings to use during plugin installationprotected final GitRepositoryHelper
protected org.springframework.http.HttpHeaders
The custom HTTP headers to sent with all requestsstatic final String
List of plugin types that can be installedprotected final InstanceService
protected final ReadWriteLock
protected com.fasterxml.jackson.databind.ObjectMapper
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected String
protected String
protected final String
protected final org.craftercms.commons.plugin.PluginDescriptorReader
protected String
The path of the plugin registry in the siteprotected String
Name of the folder to copy all plugin filesprotected final Lock
protected final org.craftercms.commons.rest.RestTemplate
protected RetryingRepositoryOperationFacade
protected boolean
Indicates if the search should include plugins pending of approvalprotected final SiteService
protected final SitesService
protected final StudioConfiguration
static final String
static final String
static final String
protected String
Code injected in the templates for each pluginprotected String
Comment added in the templates for each pluginMapping used to wire plugin files into the site templatesprotected String
The Marketplace URL to useprotected String
The current CrafterCMS version, sent with all requestsstatic final String
static final String
protected org.apache.commons.configuration2.HierarchicalConfiguration
<?> Mapping used to wire plugin files into the site configurationprotected org.springframework.core.io.Resource
XSLT template used to remove wired configurationsprotected final Lock
Fields 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 void
addIncludeIfNeeded
(String siteId, String pluginId, List<String> paths, String includePath, String includeComment, String pluginPath, List<String> changedFiles) protected void
addPluginToRegistry
(String siteId, org.craftercms.commons.plugin.model.Plugin plugin, List<FileRecord> files, List<ConfigRecord> wiring) void
protected org.dom4j.Element
buildXml
(org.craftercms.commons.plugin.model.Installation.Element element) protected void
clonePluginFromGit
(MarketplacePlugin plugin, Path directory) protected void
commitChanges
(String siteId, List<String> changedFiles, boolean update, boolean publish, String message) void
Copy a plugin in a siteprotected List
<FileRecord> copyPluginFiles
(Path pluginDir, String siteId, org.craftercms.commons.plugin.model.Plugin plugin, Map<String, String> params) protected void
createPluginConfig
(Path siteDir, String pluginId, Map<String, String> parameters, List<String> changedFiles) void
createSite
(CreateSiteRequest request) Creates a site using the given blueprintprotected String
getConfigurationPath
(String module, String filePath) protected MarketplacePlugin
getDescriptor
(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 PluginRegistry
getPluginRegistry
(String siteId) getPluginUsage
(String siteId, String pluginId) List dependant items for a pluginprotected Path
getRepoDirectory
(String siteId) void
installPlugin
(String siteId, String pluginId, org.craftercms.commons.plugin.model.Version pluginVersion, Map<String, String> parameters) Install a plugin in a siteprotected boolean
isPluginAlreadyInstalled
(String siteId, String pluginId) protected void
performConfigurationWiring
(org.craftercms.commons.plugin.model.Plugin plugin, String siteId, List<String> changedFiles, List<ConfigRecord> wiring) protected void
performTemplateWiring
(org.craftercms.commons.plugin.model.Plugin plugin, String siteId, List<FileRecord> files, List<String> changedFiles) protected void
removeConfigurationWiring
(String pluginId, String siteId, List<String> changedFiles, List<ConfigRecord> changedConfigurations) void
removePlugin
(String siteId, String pluginId, boolean force) Removes a plugin from a siteprotected void
removePluginConfig
(Path siteDir, String pluginId, List<String> changedFiles) protected void
removePluginFromRegistry
(String siteId, String pluginId) protected void
removeTemplateWiring
(String pluginId, String siteId, List<String> changedFiles) protected void
resetChanges
(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 filtersvoid
setPluginRegistryPath
(String pluginRegistryPath) void
setPluginsFolder
(String pluginsFolder) void
setShowPending
(boolean showPending) void
protected void
validate()
void
writePluginConfiguration
(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:
afterPropertiesSet
in 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:MarketplaceServiceInternal
Performs a search for all available plugins that match the given filters- Specified by:
searchPlugins
in 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:MarketplaceServiceInternal
Creates a site using the given blueprint- Specified by:
createSite
in 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:MarketplaceServiceInternal
Returns a list of the plugins currently installed in the given site- Specified by:
getInstalledPlugins
in 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:MarketplaceServiceInternal
Install a plugin in a site- Specified by:
installPlugin
in 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:MarketplaceServiceInternal
Copy a plugin in a site- Specified by:
copyPlugin
in 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:MarketplaceServiceInternal
Removes a plugin from a site- Specified by:
removePlugin
in 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:MarketplaceServiceInternal
Load the configuration for a given plugin as an object- Specified by:
getPluginConfiguration
in 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:MarketplaceServiceInternal
Load the configuration for a given plugin as a string- Specified by:
getPluginConfigurationAsString
in 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:MarketplaceServiceInternal
Writes the configuration for a given plugin- Specified by:
writePluginConfiguration
in 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:
IOException
org.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:MarketplaceServiceInternal
List dependant items for a plugin- Specified by:
getPluginUsage
in 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:
IOException
org.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:
IOException
org.eclipse.jgit.api.errors.GitAPIException
ServiceLayerException
UserNotFoundException
-
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:
TransformerException
IOException
ServiceLayerException
org.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:
IOException
TransformerException
-
getConfigurationPath
-