ENTAXY-480 release version 1.8.3
This commit is contained in:
@ -0,0 +1,61 @@
|
||||
[#ftl attributes={"generated.type":"blueprint.fragment"}]
|
||||
[#--
|
||||
|
||||
~~~~~~licensing~~~~~~
|
||||
file-adapter
|
||||
==========
|
||||
Copyright (C) 2020 - 2023 EmDev LLC
|
||||
==========
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
~~~~~~/licensing~~~~~~
|
||||
|
||||
--]
|
||||
|
||||
<!-- <service interface="org.apache.camel.Component" ref="[=objectId]">
|
||||
<service-properties>
|
||||
<entry key="connection.name" value="[=objectId]"/>
|
||||
</service-properties>
|
||||
</service> -->
|
||||
|
||||
[#if properties??]
|
||||
[#if properties.ext_createResourceProvider??]
|
||||
[#if properties.ext_createResourceProvider]
|
||||
<!-- RESOURCE PROVIDER BEAN -->
|
||||
<bean id="[=objectId].resourceProvider" class="ru.entaxy.esb.resources.provider.FileResourceProvider">
|
||||
<property name="protocol" value="[=objectId]" />
|
||||
<property name="rootDirectory" value="[=properties.rootDirectory]" />
|
||||
</bean>
|
||||
|
||||
<service interface="ru.entaxy.esb.resources.EntaxyResourceProvider" ref="[=objectId].resourceProvider">
|
||||
<service-properties>
|
||||
<entry key="connection.name" value="[=objectId]"/>
|
||||
<entry key="protocol" value="[=objectId]"/>
|
||||
</service-properties>
|
||||
</service>
|
||||
[/#if]
|
||||
[/#if]
|
||||
[/#if]
|
||||
|
||||
<bean id="[=objectId]" class="ru.entaxy.platform.adapter.file.ExtendedFileComponent">
|
||||
[#if properties??]
|
||||
[#list properties as key, value]
|
||||
[#if !key?starts_with("##") && !key?starts_with("__") && !key?starts_with("ext_")] [#-- we skip additional properties --]
|
||||
[#if key?starts_with("file_")] [#-- we add parent component properties --]
|
||||
<property name="[=key[5..]]" value="[=value]"/>
|
||||
[#else]
|
||||
<property name="[=key]" value="[=value]"/>
|
||||
[/#if]
|
||||
[/#if]
|
||||
[/#list]
|
||||
[/#if]
|
||||
</bean>
|
@ -0,0 +1,24 @@
|
||||
[#ftl attributes={"generated.type":"blueprint.fragment"}]
|
||||
[#--
|
||||
|
||||
~~~~~~licensing~~~~~~
|
||||
file-adapter
|
||||
==========
|
||||
Copyright (C) 2020 - 2023 EmDev LLC
|
||||
==========
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
~~~~~~/licensing~~~~~~
|
||||
|
||||
--]
|
||||
<reference id="[=objectId]" interface="org.apache.camel.Component"
|
||||
filter="(connection.name=[=objectId])"/>
|
@ -0,0 +1,64 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* generator-api
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.base.generator.template.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
import org.osgi.service.component.annotations.Reference;
|
||||
import org.osgi.service.component.annotations.ReferenceCardinality;
|
||||
import org.osgi.service.url.AbstractURLStreamHandlerService;
|
||||
import org.osgi.service.url.URLStreamHandlerService;
|
||||
|
||||
import ru.entaxy.base.generator.template.Template;
|
||||
import ru.entaxy.base.generator.template.TemplateService;
|
||||
|
||||
@Component(service = URLStreamHandlerService.class, property = "url.handler.protocol=templates", immediate = true)
|
||||
public class TemplateServiceURLResolver extends AbstractURLStreamHandlerService {
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY)
|
||||
TemplateService templateService;
|
||||
|
||||
@Override
|
||||
public URLConnection openConnection(URL url) throws IOException {
|
||||
String templateId = url.toString();
|
||||
templateId = templateId.replace("templates:", "");
|
||||
templateId = templateId.replace("/", ".");
|
||||
|
||||
Template template = templateService.getTemplateById(templateId);
|
||||
if (template == null) {
|
||||
// we'll try without file extension
|
||||
int index = templateId.lastIndexOf(".");
|
||||
if (index>0)
|
||||
templateId = templateId.substring(0, index);
|
||||
template = templateService.getTemplateById(templateId);
|
||||
}
|
||||
|
||||
if (template == null)
|
||||
return null;
|
||||
|
||||
String templateUrl = template.getTemplateLocation().toString() + template.getTemplateFullName();
|
||||
URL resultUrl = new URL(templateUrl);
|
||||
return resultUrl.openConnection();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user