How to import a type incuding its package name - openapi-generator

I'm using last version of openapi-generator-maven-plugin (6.0.1)
In order to handle some binary data properly I need to use typeMappings configuration as described here : https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/README.md
So I configure my pom as following :
<configuration>
<typeMappings>
<typeMapping>string+binary=org.springframework.core.io.Resource</typeMapping>
</typeMappings>
</configuration>
But the code-generator understand it as a OrgSpringframeworkCoreIoResource class. How can I tell it not to camel case my parameter?

I finally undertand the problem : it's a 2 step configuration.
<!-- First we map the OpenAPI type to a keyword -->
<typeMappings>
<typeMapping>string+binary=Resource</typeMapping>
</typeMappings>
<!-- Then we attach the keyword to an existing type -->
<importMappings>Resource=org.springframework.core.io.Resource</importMappings>
That's way it works!

Related

Exclude filter not working for filevault-package-maven-plugin

I have a content package with nodes I would like to exclude when this package is installed on AEM 6.5. The exclude configuration is defined in filter.xml (META-INF/vault/filter.xml).
Below is a representation of my filter.xml
<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
<filter root="/apps/amzn-biz">
<exclude pattern="/apps/amzn-biz/i18n(.*)"/>
</filter>
<filter root="/apps/sling"/>
</workspaceFilter>
My pom.xml has below configuration
<!-- ====================================================================== -->
<!-- V A U L T P A C K A G E P L U G I N S -->
<!-- ====================================================================== -->
<plugin>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>filevault-package-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<group>amzn-biz</group>
<acHandling>merge_preserve</acHandling>
<packageType>content</packageType>
<embeddeds>
<embedded>
<groupId>com.amazon.business</groupId>
<artifactId>amzn-biz-foundation.core</artifactId>
<target>/apps/amzn-biz/install</target>
</embedded>
</embeddeds>
<subPackages>
<subPackage>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.all</artifactId>
<filter>true</filter>
</subPackage>
<subPackage>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.examples</artifactId>
<filter>true</filter>
</subPackage>
</subPackages>
</configuration>
</plugin>
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<verbose>true</verbose>
<failOnError>true</failOnError>
</configuration>
</plugin>
I have tried multiple things by changing my exclude patterns to ./i18n. but it has not worked for me.
I have also tried adding filterSource to filevault-package-maven-plugin configuration but then i get the error Project contains filter.xml in META-INF/vault but also specifies a filter source.
You have to remove the nodes from the content package. You should not have any content in your content package, that is not explicitly covered by a filter-rule.
Your problem is weird backward-compatibility. At least in CQ5 were no filter-modes (mode="replace|merge|update") yet. In those days the rule was, that all content covered by a filter-rule is replaced. All other content is merged. When the filter-modes were introduced, they became non-intuitive but backward-compatible. In your case the i18n folder is merged.
Rule of thumb: A content package that is imported and exported again should be identical. (this would not be the case for you)
For more details see the table at https://jackrabbit.apache.org/filevault/filter.html#Usage_for_Import.2FInstallation for more information. For your i18n folder it says:
nodes which are ancestors of covered rules: deserialized from content package (for backwards compatibility reasons), nodes which are
not ancestors of covered rules: not touched. One should not rely on
this behaviour, i.e. all items in the content package should always be
covered by some filter rule to make the behaviour more explicit.
The issue may be relating to <packageType>content</packageType> instead of filter.xml. This type cannot have sub-packages nor embedded bundles. If <embeddeds> and <subPackages> are needed for the project, use <packageType>mixed</packageType> will reduce chance of unexpected build and installation behaviors.
The list of package types and behaviors are as following:
application: Package consists pure application content (aka. /apps/*). Does not contain any subpackages nor OSGi configuration or bundles.
content: Package consists only of content and user defined configuration. Does not contain any subpackages nor OSGi configuration or bundles.
container: Package only contains sub packages and OSGi configuration and bundles.
mixed: Catch all type for a combination of the above.
More details can be found at http://jackrabbit.apache.org/filevault-package-maven-plugin/generate-metadata-mojo.html#packageType

Remove browser layer on Plone 5

In previous versions of Plone, QuickInstaller took care of automagically removing some stuff on uninstall time; that was the case of browser layers and resource registry resources. Now in Plone 5 is a best practice to include a GenericSetup profile to explicitly uninstall those thins.
I folowed up Keul's blog post on uninstalls and added a browserlayer.xml file to my package uninstall profile as follows:
<?xml version="1.0"?>
<layers>
<layer name="collective.fingerpointing" remove="true" />
</layers>
but my package is not removing it.
any hints?
code is in: https://github.com/collective/collective.fingerpointing/pull/6
test results are in: https://travis-ci.org/collective/collective.fingerpointing/jobs/110195902
I'm just one test away of accomplish compatibility of my add-on!
For unregistering browser layers, the interface is ignored. Only the browser layer name is important. That has to match the name, under which the browser layer was registered before.
The problem was in the test: I was testing against the name of the interface and another package (in my case, plone.app.event) had a browser layer with the same name (IBrowserLayer):
(Pdb) registered_layers()[4]
<InterfaceClass plone.app.event.interfaces.IBrowserLayer>
I was using this:
def test_addon_layer_removed(self):
from plone.browserlayer.utils import registered_layers
layers = [l.getName() for l in registered_layers()]
self.assertNotIn('IBrowserLayer', layers)
I change it to the following:
def test_addon_layer_removed(self):
from collective.fingerpointing.interfaces import IBrowserLayer
from plone.browserlayer.utils import registered_layers
self.assertNotIn(IBrowserLayer, registered_layers())
That's why is important to have the right tests in place.

How do I add attributes to a root element when the class is generated by JAXB?

I'm developing a REST API that uses Spring MVC. The objects I consume and produce are generated (using JAXB) from NCPDP (http://www.ncpdp.org/) XSDs. I have everything working when requests come in, but I'd like to add additional attributes to the root element on outgoing requests.
Right now, my outgoing response looks as follows:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<transport:Message xmlns:transport="http://www.ncpdp.org/schema/transport">
<transport:Header>
...
</transport:Header>
<transport:Body>
<transport:Status>
<transport:Code>010</transport:Code>
<transport:Description>OK</transport:Description>
</transport:Status>
</transport:Body>
</transport:Message>
And it should look as follows:
<?xml version="1.0"?>
<transport:Message xmlns:transport="http://www.ncpdp.org/schema/transport" xmlns:datatypes="http://www.ncpdp.org/schema/datatypes"
xmlns:script="http://www.ncpdp.org/schema/script" xmlns:structures="http://www.ncpdp.org/schema/structures"
xmlns:pa-structures="http://www.ncpdp.org/schema/pa-structures" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
StructuresVersion="v2014041" ECLVersion="v2014041" DatatypesVersion="v2014041" PA-StructuresVersion="v2014041"
TransactionVersion="v2014041" TransportVersion="v2014041" TransactionDomain="SCRIPT">
<transport:Header>
...
</transport:Header>
<transport:Body>
<transport:Status>
<transport:Code>010</transport:Code>
</transport:Status>
</transport:Body>
</transport:Message>
I don't believe I need all the namespaces defined (since they're not used), but I do need the StructuresVersion and all other attributes. Is there a way to modify my bindings.xjb to include these attributes? Or do I have to copy the generated code into my source tree and add annotations to do this?
Thanks,
Matt
Since these attribute are declared in your XML schema, you should be getting appropriate properties in your schema-derived code.
It actually does not matter if this is a root element or some child element. Please re-check the generated code, look for something like getStructuresVersion(). So you don't need to do anything.
As for the namespaces, you will get them automatically declared, when you marshal. But you may first get them declared as ns0, ns1 etc. which is not very nice in terms of readability. Please see the following question:
Controlling namespace prefixes in JAXB
(the question itself, not the answers) for information on how to control these prefixes with a custom prefix mapper or this post by Blaise Doughan.

How to Remove Configlet from "Site Setup - Add-on Configuration"

I'm deprecating a Site Setup add-on configlet. The procedure I'm following is add the remove="true" property to controlpanel.xml
<!-- profiles/default/controlpanel.xml -->
<configlet
title="MyConfiglet" ...
remove="true">
<permission>Manage portal</permission>
</configlet>
and then execute an upgradeStep. I tried with
<!-- upgrades/configure.zcml -->
<genericsetup:upgradeSteps ...>
<genericsetup:upgradeDepends
title="Remove Configlet"
import_steps="plone.app.registry controlpanel"
/>
</genericsetup:upgradeSteps>
But after executing the upgrade step, I still can see the configlet in /##overview-controlpanel.
What am I missing? What do I need to remove the configlet from the control panel?
Thanks.
The process of removing something from Plone involves more or less the same steps you used to add it; in this specific case you have two ways of doing it: programmatically or using Generic Setup.
programmatically
I think this is easier as involves no more than a few lines of code and you can debug in case of problems.
just use the following code on your upgrade step:
def remove_configlet(self):
from plone import api
config_tool = api.portal.get_tool('portal_controlpanel')
configlet_id = 'MyConfigletId'
config_tool.unregisterConfiglet(configlet_id)
using Generic Setup
create a controlpanel.xml file inside the profile you're registering for your upgrade step; this file should contain exactly the same stuff used to add the configlet plus the remove="True" attribute.
you can find a working example of this on the upgrade_10_to_11 profile of Products.TinyMCE:
controlpanel.xml
upgrades.py
<?xml version="1.0"?>
<object name="portal_controlpanel" meta_type="Plone Control Panel Tool"
xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:domain="plone.tinymce">
<configlet title="TinyMCE"
action_id="tinymce" appId="TinyMCE"
category="Products"
condition_expr=""
url_expr="string:${portal_url}/portal_tinymce/##tinymce-controlpanel"
visible="True"
i18n:attributes="title"
remove="True">
<permission>Manage portal</permission>
</configlet>
...
</object>
def upgrade_10_to_11(setuptool):
"""Upgrade TinyMCE from 1.0 to 1.1"""
...
# Unregister old js and register new js
setuptool.runAllImportStepsFromProfile('profile-Products.TinyMCE:upgrade_10_to_11')
in case of doubts take a look at Luca Fabbri's excelent blog post on How to make your Plone add-on products uninstall cleanly.

five:protectName error with allowed_interfaces and allowed_attributes

in my browser / configure.zcml I've putted a directive to manage a view with a specific interface and method, in this way:
<browser:page
for="my.package.interfaces.ICartellaBandidiLavoro"
name="lavoroautonomo"
class=".cartellabandiview.cartellabandiView"
template="cartellabandiview.pt"
allowed_interface=".cartellabandiview.ICartellabandiView"
allowed_attributes="rss_bandi"
permission="zope.Public"
/>
in the cartellabandiview.py I have
[...]
class ICartellabandiView(Interface):
""" cartellabandi view interface """
def rss_bandi():
""" rss """
when I start the instance I obtain an error
raise ConfigurationConflictError(conflicts)
zope.configuration.config.ConfigurationConflictError: Conflicting configuration actions
For: ('five:protectName', <class 'Products.Five.metaclass.SimpleViewClass from /Users/vito/repos/my.package/my/package/browser/cartellabandiview.pt'>, u'rss_bandi')
Any suggestions?
Vito
If the code you pasted is right, probably is only an indentation problem. rss_bandi is not a method inside the ICartellaView class. it seems is an external module level function.
As Mathias noted already noted: yes, you only need allowed_interface.

Resources