Class ApachePublishDelegate
- java.lang.Object
-
- com._1c.g5.v8.dt.platform.services.core.publication.apache.ApachePublishDelegate
-
- All Implemented Interfaces:
IWebServerPublishDelegate
- Direct Known Subclasses:
ApachePublishDelegateLinux
,ApachePublishDelegateMock
,ApachePublishDelegateWin32
public abstract class ApachePublishDelegate extends Object implements IWebServerPublishDelegate
Configures publications for Apache Web Server.Apache Web Server is configured by placing directives in plain text configuration files. The main configuration file is usually called
httpd.conf
. The location of this file is set at compile-time, but may be overridden. Changes to the main configuration files are only recognized by web server when it is started or restarted.Apache Web Server publication process is actually changing web server configuration file: publication
Directory
will be created or modified during publication process.
-
-
Field Summary
Fields Modifier and Type Field Description static String
APACHE_CONFIGURATION_FILE
static String
APACHE_CONFIGURATION_FOLDER
-
Constructor Summary
Constructors Constructor Description ApachePublishDelegate()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
contains(WebServer webServer, Publication publication)
Checks existence of a publication instance in the given web server.protected String
formatIfExtists(Path target)
Formats target path, if file for this path exists.protected abstract String
formatPathToWebExtensionComponent(String componentPath)
Formats path to the web extension component of the 1C:Enterprise runtime depending on the OS.Publication
get(WebServer webServer, String name)
Returns a publication with the given name from the given web server.List<Publication>
getAll(WebServer webServer)
Returns all registered on the given web server publications.Path
getDefaultPublicationLocation(WebServer webServer)
Returns default location for the new publications for the given web server.URL
getPublicationUrl(WebServer webServer, String name)
ReturnsURL
of the publication by the provided publication name in the web server instance.Path
getWebExtension(Publication publication, WebServer webServer)
Returns path to the registered 1C:Enterprise runtime ornull
if no 1C:Enterprise runtime web extension component was registered.protected abstract String
getWebServerExecutableFileName(WebServer webServer)
Returns the web server executable file name.boolean
isPublishSupported(WebServer webServer, PublicationType type)
Check support of publish process on the given web server instance.boolean
isWebExtensionConfigured(Publication publication, Path webExtensions, WebServer webServer)
Returns whether the provided 1C:Enterprise runtime web extension component is correctly configured for the web server publication.void
publish(Publication publication, WebServer webServer, Path webExtensions)
Publish the given publication instance on the given web server.protected void
publishTypeSpecificSettings(Publication publication)
Publishes publication type-specific settings for the publication instance.boolean
remove(WebServer webServer, Publication publication)
Removes publication with given name from given web server.boolean
restart(WebServer webServer)
Restart the target web server.void
update(Publication publication, String name, WebServer webServer, Path webExtensions)
Edit the given publication on the server.
-
-
-
Field Detail
-
APACHE_CONFIGURATION_FILE
public static final String APACHE_CONFIGURATION_FILE
- See Also:
- Constant Field Values
-
APACHE_CONFIGURATION_FOLDER
public static final String APACHE_CONFIGURATION_FOLDER
- See Also:
- Constant Field Values
-
-
Method Detail
-
publish
public void publish(Publication publication, WebServer webServer, Path webExtensions) throws WebServerAccessException
Publish the given publication instance on the given web server. Publications can configure the web server ability to work with 1C:Enterprise web clients, mobile devices, etc.Publication process depends on the
publication type
and may be various.Also can register the given 1C:Enterprise runtime web extension component on the given web server. Note, that some publication types does not support working without 1C:Enterprise runtime web extension component registration.
Apache Web Server implementation converts publication instances to object
Directory
.Directory
will be appended to the web server configuration file.- Specified by:
publish
in interfaceIWebServerPublishDelegate
- Parameters:
publication
- the publication instance to publish, cannot benull
webServer
- the web server to publish the given publication instance to, cannot benull
webExtensions
- the path to 1C:Enterprise runtime web component, ornull
if component publishing is not needed- Throws:
WebServerAccessException
- if publication process fails with some reason
-
update
public void update(Publication publication, String name, WebServer webServer, Path webExtensions) throws WebServerAccessException
Description copied from interface:IWebServerPublishDelegate
Edit the given publication on the server. Searches publication by the given name in the target web server. Does nothing, if publication not found. Overwrite old publication properties with new values from the given publication.Publication process depends on the
publication type
and may be various.Also can register the given 1C:Enterprise runtime web extension component on the given web server. Note, that some publication types does not support working without 1C:Enterprise runtime web extension component registration.
- Specified by:
update
in interfaceIWebServerPublishDelegate
- Parameters:
publication
- the publication instance to overwrite found publication with, cannot benull
name
- of publication to edit, cannot benull
or emptywebServer
- the web server to edit the given publication instance in, cannot benull
webExtensions
- the path to registered 1C:Enterprise runtime web component, ornull
if component publishing is not needed- Throws:
WebServerAccessException
- if publication process fails with some reason
-
remove
public boolean remove(WebServer webServer, Publication publication) throws WebServerAccessException
Removes publication with given name from given web server. Returns whether specified publication was actually removed.Note, that actual publication content will not be deleted, but only removed from web server configuration.
Apache Web Server implementation removes the container
Directory
with the description of publication by the given name of the publication from the target web server.- Specified by:
remove
in interfaceIWebServerPublishDelegate
- Parameters:
webServer
- the web server to remove publication from, cannot benull
publication
- to remove, cannot benull
, publication must contain non-null and non-empty name and location values- Returns:
- whether if an element was removed as a result of this call
- Throws:
WebServerAccessException
- if removing fails
-
getAll
public List<Publication> getAll(WebServer webServer) throws WebServerAccessException
Description copied from interface:IWebServerPublishDelegate
Returns all registered on the given web server publications.- Specified by:
getAll
in interfaceIWebServerPublishDelegate
- Parameters:
webServer
- web server to get publications for, cannot benull
- Returns:
- list of all registered on the given web server publications, never
null
- Throws:
WebServerAccessException
- request fails
-
get
public Publication get(WebServer webServer, String name) throws WebServerAccessException
Description copied from interface:IWebServerPublishDelegate
Returns a publication with the given name from the given web server.- Specified by:
get
in interfaceIWebServerPublishDelegate
- Parameters:
webServer
- the web server to get publication on, cannot benull
name
- of publication to get, cannot benull
- Returns:
- found publication with given name, or
null
if publication not found - Throws:
WebServerAccessException
- request fails
-
getDefaultPublicationLocation
public Path getDefaultPublicationLocation(WebServer webServer)
Description copied from interface:IWebServerPublishDelegate
Returns default location for the new publications for the given web server. The default publication location is a folder, that can contain sub-folders with publications. Can returnnull
, if not defined or web server does not support default publication location.- Specified by:
getDefaultPublicationLocation
in interfaceIWebServerPublishDelegate
- Parameters:
webServer
- the web server to get default publication location for, cannot benull
- Returns:
- default location for the new publications for the given web server or
null
, if not defined
-
getWebExtension
public Path getWebExtension(Publication publication, WebServer webServer) throws WebServerAccessException
Description copied from interface:IWebServerPublishDelegate
Returns path to the registered 1C:Enterprise runtime ornull
if no 1C:Enterprise runtime web extension component was registered. However returned web extension may not be correctly configured and clients need to check whether web extensionis configured
.- Specified by:
getWebExtension
in interfaceIWebServerPublishDelegate
webServer
- the web server to get default publication location for, cannot benull
- Returns:
- default location for the new publications for the given web server or
null
if not defined - Throws:
WebServerAccessException
-
isWebExtensionConfigured
public boolean isWebExtensionConfigured(Publication publication, Path webExtensions, WebServer webServer) throws WebServerAccessException
Description copied from interface:IWebServerPublishDelegate
Returns whether the provided 1C:Enterprise runtime web extension component is correctly configured for the web server publication. Iffalse
is returned then re-publish is required for this publication with this web extension for correct work.- Specified by:
isWebExtensionConfigured
in interfaceIWebServerPublishDelegate
- Parameters:
publication
- the publication to check, cannot benull
webExtensions
- path to the 1C:Enterprise runtime web extension component, cannot benull
webServer
- the web server to check, cannot benull
- Returns:
- whether the provided 1C:Enterprise runtime web extension component is correctly configured for the web server publication
- Throws:
WebServerAccessException
- if request fails
-
getPublicationUrl
public URL getPublicationUrl(WebServer webServer, String name) throws WebServerAccessException
ReturnsURL
of the publication by the provided publication name in the web server instance.- Specified by:
getPublicationUrl
in interfaceIWebServerPublishDelegate
- Parameters:
webServer
- the web server to get URL for web server, cannot benull
name
- the name of publication, cannot benull
or empty- Returns:
- the URL of publication, never
null
- Throws:
WebServerAccessException
- if directive 'Listen
' is missing in the Apache Web Server configuration file
-
contains
public boolean contains(WebServer webServer, Publication publication) throws WebServerAccessException
Description copied from interface:IWebServerPublishDelegate
Checks existence of a publication instance in the given web server.- Specified by:
contains
in interfaceIWebServerPublishDelegate
- Parameters:
webServer
- the web server to check publication existence on, cannot benull
publication
- to check for the existence in the web server, cannot benull
- Returns:
- whether the given publication exists on the target web server
- Throws:
WebServerAccessException
- if request fails
-
isPublishSupported
public boolean isPublishSupported(WebServer webServer, PublicationType type)
Description copied from interface:IWebServerPublishDelegate
Check support of publish process on the given web server instance.- Specified by:
isPublishSupported
in interfaceIWebServerPublishDelegate
- Parameters:
webServer
- the web server to check publish support for, cannot benull
type
- the publication type to check, cannot benull
- Returns:
true
if web server supports publishing with the given publication type,false
otherwise
-
restart
public boolean restart(WebServer webServer) throws WebServerAccessException
Description copied from interface:IWebServerPublishDelegate
Restart the target web server.Returns whether web server was successfully restarted. If delegate does not support restarting, it can return
false
immediately in method implementation.- Specified by:
restart
in interfaceIWebServerPublishDelegate
- Returns:
- whether the web server was successfully restarted
- Throws:
WebServerAccessException
- if request fails
-
publishTypeSpecificSettings
protected void publishTypeSpecificSettings(Publication publication) throws WebServerAccessException
Publishes publication type-specific settings for the publication instance.- Parameters:
publication
- the publication to publish type-specific settings for, cannot benull
- Throws:
WebServerAccessException
- if publish fails
-
formatIfExtists
protected String formatIfExtists(Path target)
Formats target path, if file for this path exists.- Parameters:
target
- the target path to format, cannot benull
- Returns:
- formatted path or
null
if file for this path does not exists
-
formatPathToWebExtensionComponent
protected abstract String formatPathToWebExtensionComponent(String componentPath)
Formats path to the web extension component of the 1C:Enterprise runtime depending on the OS. Formatted path will be written in the web server configuration file.- Parameters:
componentPath
- the web extension component to format, cannot benull
- Returns:
- formatted path to the web extension component of the 1C:Enterprise runtime,
never
null
-
-