release version 1.10.0
This commit is contained in:
@ -0,0 +1,130 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* file-adapter
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.runtime.connections.ftps;
|
||||
|
||||
import org.apache.camel.ExtendedCamelContext;
|
||||
import org.apache.camel.component.file.GenericFileEndpoint;
|
||||
import org.apache.camel.component.file.remote.FtpsComponent;
|
||||
import org.apache.camel.spi.PropertyConfigurer;
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
import ru.entaxy.platform.base.support.CommonUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class FtpsConnectionComponent extends FtpsComponent {
|
||||
|
||||
private static final String COMPONENT_CONFIGURER = "ftps-component-configurer";
|
||||
private static final String ENDPOINT_CONFIGURER = "ftps-endpoint-configurer";
|
||||
private static final String PATH_PLACEHOLDER = "PATH_PLACEHOLDER";
|
||||
|
||||
protected String username = "";
|
||||
protected String password = "";
|
||||
protected String host = "";
|
||||
protected String port = "";
|
||||
protected String directoryName = "";
|
||||
|
||||
private volatile PropertyConfigurer componentPropertyConfigurerLocal;
|
||||
private volatile PropertyConfigurer endpointPropertyConfigurerLocal;
|
||||
|
||||
@Override
|
||||
protected void doBuild() {
|
||||
|
||||
componentPropertyConfigurerLocal = getCamelContext().adapt(ExtendedCamelContext.class).getConfigurerResolver()
|
||||
.resolvePropertyConfigurer(COMPONENT_CONFIGURER, getCamelContext());
|
||||
log.debug("componentPropertyConfigurerLocal: {}", componentPropertyConfigurerLocal);
|
||||
|
||||
endpointPropertyConfigurerLocal = getCamelContext().adapt(ExtendedCamelContext.class).getConfigurerResolver()
|
||||
.resolvePropertyConfigurer(ENDPOINT_CONFIGURER, getCamelContext());
|
||||
log.debug("endpointPropertyConfigurerLocal: {}", endpointPropertyConfigurerLocal);
|
||||
}
|
||||
|
||||
protected GenericFileEndpoint<FTPFile> createEndpoint(String uri, String remaining, Map<String, Object> parameters)
|
||||
throws Exception {
|
||||
|
||||
// doBuild method called to force configurer initialization (doBuild not invoked in some scenario)
|
||||
doBuild();
|
||||
uri = uri.replace(PATH_PLACEHOLDER, buildPath());
|
||||
log.debug("CREATING ENDPOINT FOR [{}]", uri);
|
||||
if (CommonUtils.isValid(username)) {
|
||||
parameters.put("username", username);
|
||||
}
|
||||
if (CommonUtils.isValid(password)) {
|
||||
parameters.put("password", password);
|
||||
}
|
||||
|
||||
return super.createEndpoint(uri, remaining, parameters);
|
||||
}
|
||||
|
||||
private String buildPath() {
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
|
||||
if (CommonUtils.isValid(host)) {
|
||||
path.append(host.trim());
|
||||
}
|
||||
if (CommonUtils.isValid(port)) {
|
||||
path.append(":");
|
||||
path.append(port.trim());
|
||||
}
|
||||
if (CommonUtils.isValid(directoryName)) {
|
||||
if (!directoryName.startsWith("/")) {
|
||||
path.append("/");
|
||||
}
|
||||
path.append(directoryName.trim());
|
||||
}
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public void setPort(String port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void setDirectoryName(String directoryName) {
|
||||
this.directoryName = directoryName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyConfigurer getComponentPropertyConfigurer() {
|
||||
return componentPropertyConfigurerLocal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyConfigurer getEndpointPropertyConfigurer() {
|
||||
return endpointPropertyConfigurerLocal;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,9 @@
|
||||
[#ftl]
|
||||
<bean id="[=objectId]" class="ru.entaxy.platform.runtime.connections.ftps.FtpsConnectionComponent">
|
||||
[=utils.createBeanProperties(properties, "camel_", true)]
|
||||
[#if properties.username??]<property name="username" value="[=properties.username]"/>[/#if]
|
||||
[#if properties.password??]<property name="password" value="[=properties.password]"/>[/#if]
|
||||
<property name="host" value="[=properties.host]"/>
|
||||
[#if properties.port??]<property name="port" value="[=properties.port]"/>[/#if]
|
||||
[#if properties.directoryName??]<property name="directoryName" value="[=properties.directoryName]"/>[/#if]
|
||||
</bean>
|
@ -0,0 +1,19 @@
|
||||
[#ftl attributes={"generated.type":"blueprint"}]
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
|
||||
xsi:schemaLocation="
|
||||
http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"
|
||||
>
|
||||
|
||||
[#import "templates:object-commons/common-utils.ftl" as utils]
|
||||
[#include "templates:ftps-connection/init.body.ftl"]
|
||||
|
||||
<service interface="org.apache.camel.Component" ref="[=objectId]">
|
||||
<service-properties>
|
||||
<entry key="connection.name" value="[=objectId]"/>
|
||||
</service-properties>
|
||||
</service>
|
||||
|
||||
</blueprint>
|
@ -0,0 +1,3 @@
|
||||
[#ftl attributes={"generated.type":"blueprint.fragment"}]
|
||||
[#import "templates:object-commons/common-utils.ftl" as utils]
|
||||
[#include "templates:ftps-connection/init.body.ftl"]
|
Reference in New Issue
Block a user