How to get config file for Cordapp? - corda

How to get config file for Cordapp in Java like in sample?
serviceHub.getAppContext().config
After getAppContext() i can't find anything about config file.

This feature is not available in Corda 3. As of this answer, it is only part of the unstable master branch. It will be included in a future release of Corda.
However, you can implement this manually for now as follows: How to provide a CorDapp with custom config in Corda?.

Related

The transaction currently built is missing an attachment for class - Attempted to find a suitable attachment but could not find any in the storage

Full Error:
transactions.TransactionBuilder. - The transaction currently built is missing an attachment for class: com/gibtn/corda/printutilities/PrintLedgerTransaction. Attempted to find a suitable attachment but could not find any in the storage.
This has been asked here and here but I hope to get better clarification.
Problem:
I have built a set of libraries to perform common tasks in my Flows that I include in all my CorDapps. For now I just copy the JARs into each project, make some changes to the gradle files and everything works great.
I recently put together a small library for performing common tasks in Contracts and added the JAR the same way.
This works fine with MockNodes. But when I test with real nodes I will get this error in the CRaSH shell and the transaction will fail with a NoClassDefFoundError exception.
Question:
Is what I am doing even possible? Or do I always have to keep my utility classes inside the Contracts module in IntelliJ so they are bundled together with the Contracts into a single JAR? That way when the node starts the JAR (containing the Contracts and any utilities) is added to Attachment storage as a single Attachment.
I found a way to solve this. It's a bit dirty but initial testing seems to work. I just created a blank class in my utilities JAR that implements Contract. It's verify() method is empty. Now when the Corda node starts it sees this Contract and adds the JAR to Attachment storage. So from the CRaSH shell if I run:
attachments trustInfo
...my utility JAR will be listed (it wasn't before). I see when I use one of the utility methods in a Contract the utility JAR will be included as a separate Attachment in the WireTransaction.
I'm not crazy about this solution and will probably stop using a utility JAR for Contracts. I'll go back to copying the classes into each project. Nevertheless there is a way to do it. I would just need a more experienced Corda developer to give it their blessing before I'd go forward into production with it.

debugging contract test cases in spring cloud contract

I have a question related to spring cloud contract framework.Is it possible to debug the test cases which are auto-generated by spring cloud contracts. usually I do gradle build to execute the contracts.But to understand the actual problem, I would like to do debug and see the results.
The Spring Cloud Contract Plugin generates standard Junit test files based on your contracts. For Maven you can find these in the target/generated-test-sources/contracts directory (Gradle will have similar output in the build directory).
When opening the files in this directory, you can have a look at the generated code. If the intention is to debug these tests, they can be copy/pasted from this directory into the actual test sources directory in your project. Then you can directly run the tests in debug mode (as previously pointed out by Marcin). To avoid the copy/pasting, add the target/generated-test-sources/contracts directory as test sources folder in your IDE.

CorDapp Suite and Dependencies

Let's say I want to use a cash-based CorDapp for DVP with my CP Trading CorDapp (But I do not want to be responsible for updating/developing cash). How does one note CorDapp dependencies for deployment? What if the cash CorDapp updates their state or contract definition?
If cash is too specific, let's say I want to use an API that reaches out to another data source for enrichment or validation of my state. Does this have to be an Oracle? Can we implement this API call as a CorDapp that's installed in a CorDapp Suite so it stays decentralized or must it contain a signature of an oracle in order to keep the transaction valid?
You specify the dependencies of your CorDapp in the dependencies section of your build.gradle file. For example, the following line would include the corda-finance module, which includes cash:
cordapp "net.corda:corda-finance:$corda_release_version"
As you can see, you specify the version of the CorDapp that you wish to use.
By default, when you build a CorDapp, the CorDapp jar's name is determined by:
The name of the module where the sources are defined
The version property in a project's gradle.properties file
So if the version number is 0.1, and your module is called clemens-dvp, building the CorDapp jar will create a file called clemens-dvp-0.1.jar.
See further information here: https://docs.corda.net/cordapp-build-systems.html. The docs state:
"The filename of the jar must include some sort of unique identifier to deduplicate it from other releases of the same CorDapp. This is typically done by appending the version string. It should not change once the jar has been deployed on a node."

Can I run code at Alfresco startup?

I have an Alfresco module that I would like to have do some cleanup when a new version of it is installed.
In the current situation, an older version of the module created a folder node with custom properties at the root of the repository. We've since decided to have multiple such nodes, and none of them at that location. I'd like to put into the next version of the module code that would run at Alfresco startup, check for the existence of the old node, copy its properties into the appropriate new nodes, and delete the old node.
Is such a thing possible? I've looked at the Bootstrap configuration file, but that appears to only allow one to add things to the repository, not modify or delete them.
My suggestion is that you write a patch. That is a class that implements
org.alfresco.repo.admin.patch.AbstractPatch
Then you can do pretty much anything you want on bootstrap (except executing searches against solr since it wont be available).
Add some spring configuration, take a look at the file patch-services-context.xml for inspiration.
Yes you can do that, probably you missed the correct place in the documentation about that:
If you open Import Strategy you'll find a section Per BootstrapView, you should be using something like REPLACE_EXISTING or UPDATE_EXISTING for your ACP packaged content (if you're using ACPs as your bootstrap importing strategy).
Here is a more detailed description of the UUID Bindings values.
Hope that helps.
You can use patches.
When alfresco server starts it applies patches and executes database updates etc.
Definition :
A patch is a piece of Java code that executes once when Alfresco
Content Services starts. Custom patches can be implemented.
Documentation Link

Apache Karaf - bundle starts but does nothing?

I'm new to Karaf. I have a jar that has a class App with a method main. When I drop the jar in the The Karaf log service console says the bundle is started but nothing seems to happen. The first thing (the jar) does is a simple database write so I can see if it's running (no log file is generated although one is expected).
The jar depends on lots of other jars. Our sysadmin will not install Maven on the production servers. Where does one put helper jars (like mysql-connector-java-[version].jar)?
Does Karaf use the Manifest file to find the main class? Do I have to implement some special interface or something?
thanks for any help.
As Karaf is a OSGi Container, you should first read some stuff on how to write proper OSGi bundles.
First of all you'll need a Activator that'll start your bundle (just like a main). A Main Class is never interpreted. Yes Karaf, as it is a OSGi container, does "read" the Manifest, but to make sure first it's a proper OSGi bundle second how the resolving should take place by reading Package-Import/-Export.
Regarding the "Packaging" - using lot's of other jar's/bunldes - , you'd either can built a custom Karaf (read the Karaf documentation on how to do this) or create a KAR for your Bundles containing your bundles and a feature.xml (again take a look at the documentation at Karaf)

Resources