How to plugin into grpc-java to modify code generation and add setNameOrClear(null) methods? - protocol-buffers

We are having too many issues around all this extra code for every database field with regard to
if(databaseObj.getName() != null)
builder.setName(databaseObj.getName());
and I read square wired into protobuf adding setOrClear methods in java. How do we do this when we generate as well using gradle?
We are using the gradle code from this page right now..
https://github.com/grpc/grpc-java
thanks,
Dean

You can accomplish that via protoc_insertion_points. When you generate the Java code you will see comments like // ##protoc_insertion_point(...). That is where the insertion will occur.
While appearing useful, this approach has serious drawbacks for .protos used in multiple projects. All projects using the same .proto and in the same language should use the same plugins, otherwise it causes the diamond dependency problem. This is why gRPC did not use this approach and instead generates its classes in separate files from the normal message generation. I strongly discourage against this approach, as it paints you into a corner and you don't know when you will need to "pay the piper."
To insert into a point, your plugin needs to run in the same protoc command-line invocation as the java builtin. Your plugin would then need to set CodeGeneratorResponse.file.insertion_point and content for each file you want to inject code.

Related

FilterServletResponseWrapper replacement when migrating Richfaces to Primefaces. For file download

I am migrating a project from Richfaces to Primefaces and I am having problems getting file download to work again. The original uses a standard h:commandLink which tells the webflow to start the download by calling a function on the controller. The actual downloading is written to the output stream instead of being returned as a file.
Now my problem is the previous code sends a FilterServletResponseWrapper, but after changing the rich tags to prime, it now returns HttpSessionSecurityContextRepository$SaveToSessionResponseWrapper. These wrappers are not specified anywhere and I suspect rich sends such a type internally. So if I want to specify my own wrapper to send, how could I possibly go about that? In particular I want to use Spring's ContentCachingResponseWrapper since I need to use it's .getContentInputStream() method.
P.S. I have intentionally omitted the code, because of NDA, I am hoping this is enough information to represent the problem sufficiently. If not I will be glad to clear out any questions.
Thanks

How can I produce github annotations by creating report files on disk?

I am trying to find a portable way to produce code annotations for GitHub in a way that would avoid a vendor-lockin.
Mainly I want to dump annotations inside a file (yaml, json,...) during build process and have a task at the end that does transform this file into github annotations.
The main goal here is to avoid hardcoding support for github-annotation into the tools that produce them, so other CI/CD systems could also consume the annotation-reports and display them in their UI.
linters -> annotations.report -> github-upload
Tools like flake8 are able to produce output in parsable format file:line:column: message, but I need to know if there is any attempt to standardize annotations so we can collect and combine them from multiple tools and feed them to the CI/CD engine.
Today I googled up what the heck those "Github Action Annotations" are all, and this was among the hits:
https://github.com/marketplace/actions/annotations-action
GitHub action for creating annotations from JSON file
As of now that page also contains:
This repository uses npm packages from #attest scope on github; we are working hard to open source these packages.
Annotations Action is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.
I didn't try it, again, just a random google hit.
I am currently using https://github.com/yuzutech/annotations-action
Sample action code:
- name: Annotate
uses: yuzutech/annotations-action#v0.3.0
with:
repo-token: ${{secrets.GITHUB_TOKEN}}
input: ./annotations.json
title: 'Findings'
ignore-missing-file: true
It does its job well but with one minor defect. If you have a findings on a commit/PR you get to see the finding with a beautiful annotation right where you need it. If you re-push changes, even if the finding persists, the annotation is not displayed on later commits. I have opened an issue but I have not yet received an answer.
The annotations-action mentioned above has not been updated and it does not work with me at all (deprecated calls).
I haven't found anything else that worked exactly as I wanted it to.
Update: I found that you can use reviewdog to annotate based on findings. I also created a GitHub action that can be used for Static Code Analysis here https://github.com/tsigouris007/action-semgrep-reviewdog. You can visit the entrypoint.sh file and check how I piped the custom output to reviewdog utilizing jq.

Resources - Properties : Possible to dynamically build?

I'm new to Thymeleaf / Spring and have just introduced a message_en.properties file. I see the benefits of using it, however, it's a bit of a pain to populate it.
I have a form, I've just added several inputs, I know need to add each of these as keys in the message file. Is there a way of doing this on the fly for me?
To automatically populate the message properties, you may have to consider using a scaffolding solution like jHipster or something similar.
refer http://jhipster.github.io

GWT : Automate tests of UIs with Selenium/FluentLenium

I have such a big problem and I really need your help.
Basically, I'm working on a project whose core technology is GWT and I have to make functional tests and the tests of UIs. In fact, I have also to use Cucumber the framework which is BDD-based framework.
Now I come to the main problem : Indeed, at every Maven build, GWT generates automatically the ids of the widgets. Then, Selenium could not find these widgets because of the recent updates/changes of their Ids. Moreover, I can't find some widgets with the methods (findByName/xPath/cssSelector etc.). I'm working now on the FluentLenium which is an overlay of Selenium.. I don't know how to fix this problem because I have no control of how GWT generates the Ids behind ..
Does anynone met the same problem before ?
Thank you a lot.
I've worked with GWT/Selenium/Cucumber. We had a single class file with public static String fields for each ID used in the whole application. These id's were set with ensureDebugId. This same class file is then used in Selenium/Cubumber tests to find the widgets by id. I don't know if this works for you. But in our case the tester was in control of the id's.

Sonar - Can we use for OSB/BPEL code review?

I am new to sonar,just heard about this tool.
Can we use this tool to perform code review for FMW(Fusion Middleware) -OSB(Oracle Service Bus)/BPEL project ?
If so can anyone give some inputs on this?
The official plugin-List : http://docs.codehaus.org/display/SONAR/Sonar+Plugin+Library/ does not mention support for your tools.
But sonar can be extended with custom plugins, so you may be able to write your own plugins to provide metrics for your tools.
What level of review you want to cover? It is really easy to make your own review tool for BPEL. All BPEL resources are XML files. For example if you want to check for naming convetion of BPEL activities, you can define a simple XPath based rule.
Ex:
//sequence/#name ~= "^sequence.*".
A Java program can use the above XPath to pull-out all sequence names from the xxxx.bpel file and compare it against a regular expression. Similar rules can be created for checking WSDL usage, partner links, end-point addresses, usage of Error handling etc.

Resources