Subclipse API from a command line java application - subclipse

I am trying to create a command line application tool that will download a project from the SVN database.
I have written the code in java. I have called a method that is responsible to open the specified database with the give user credentials.
Here, I need SVNProviderPlugin instance to get the SVNClientManager, Repositories and all other attributes.
But, for Non-IDE appliaction the SVNProviderPlugin instance is null.
I want to know how to retrieve the SVNClientManager in a java command line application using Subclipse APIs?

It does not make sense to try to use Subclipse for this. Subclipse provides an API layer called SVNClientAdapter that is a separate and can be used in any Java app. You might use that but we do not easily package it.
I would consider just using JavaHL or SVNKit, which are the two different SVN API implementation that SVNClientAdapter serves as a wrapper for. IOW, as long as you can control the deployment, just use one of those directly.
Or, if all you need to is simple checkout, why not just run the SVN Command line directly from Java? I wrote a SVN Benchmark tool in Java that just uses the command line. It is so easy to do why not? The only reason to use JavaHL or SVNKit is if you really need deep info you could not easily get out of the command line tool.

Related

Sonarlint-core hook points for new grammar

I am doing a POC where I am trying to write grammar/creating a new analyser.
I am able to run the grammar using the sonar-qube and sonar-scanner.
Now,I need to integrate the same with sonar-lint eclipse plugin.
I have git copied the sonarlint-eclipse code and found that it is internally using sonarlint core to load the jars of different grammars like Java,Javascript using helper classes like PluginRepository.
I have found that at below path C:\Users\xyzUser\runtime-EclipseApplication\.sonarlint\storage\localhost\global, "plugin_references.pb" file contains the key,hash and jar name.
Can somebody please explain the exact hook points to introduce new grammar jar for sonar-lint eclipse plugin?
I am trying to run it in both Standalone mode and Connected Mode.
You're not going to be able to run your new grammar in SonarLint; it maintains a whitelist of plugins it will run. Inevitably, yours is not on it.

Is there any way to upload Artifacts to the Apache ACE server without Web UI?

We are working on an enterprise system writed by Java. And we use an Apache ACE server to deploy the OSGi bundles, a Jenkins as CI server. When we want to update a bundle, we make a jar file in Eclipse, and upload it to ACE server through Web UI. When we want to release a new version, we must upload all bundles through Web UI. I think that is foolish.
I think there must be a simple way just like when I finish coding, then I can do something just in Elipse to upload the bundle to the ACE server. When we release a version, the Jenkins should also update all of the bundles to ACE server itself.
Certainly, you basically have two options if you want to automate things:
Use the REST based interface to talk to ACE.
Use the shell based interface to script to ACE.
Both are explained on the website, so for more detailed steps refer to:
http://ace.apache.org/docs/rest-api.html
http://ace.apache.org/docs/shell-api.html

A good strategy for knowing the versions of deployed applications?

In order to know which revision number the application is built from, we use to give the ears we deploy to Glassfish names like myapp_2012-01-20_rev22123.ear. Then we can simply login to Glassfish and see what version is deployed in the web interface (as the appname is the name of the ear file). A downside of this approach is that we need to do a manual undeploy/redeploy to update the name...
But I would like to script the undeploy/deploy process, and having each version of an ear get a different name is not very suitable to scripting this redeployment process. Glassfish 2 does not support the "list applications" goal that Glassfish 3 has, which I could have used to retrieve the application name to undeploy.
So is there any good strategy that will easily allow us to see what version is deployed of an application, and that does not suffer from the above fault?
It would be preferable if this meant we did not have to change the existing applications (like add a jsp page or something to show the current scm revision), but a change in a Maven build script would be acceptable.
I faced a similar issue, I finally came around it by using maven-buildnumber-plugin and writing a simple servlet to get build information. You can find the details in the blog post I made.
Why not use the built-in GlassFish Server versioning to assign a version number at deploy time? This will also enable you to rollback to prior versions. For example:
asadmin deploy --name MyApplication:2012-01-20_rev22123 MyApplication.ear
There is more information on application versioning here:
http://docs.oracle.com/cd/E18930_01/html/821-2417/gihzx.html#gkhhv
Hope this helps.

Create new user in sonar

Is it possible to create a new user in sonar without using the web interface?
I need to write a script that inserts the same users for some tools, including sonar.
There are three ways you can do this:
Write directly to the database (there is a simple table called users).
Use the LDAP plugin, if you specify sonar.authenticator.createUsers: true in sonar.properties, it will create the users in the sonar database automatically the first time they authenticate.
Write a java application that depends on the sonar plugin API, you can then use constructor injection to get a Sonar hibernate session and persist the user you want. See Here.
Since SonarQube version 3.6, there is support for user management in webservice API:
https://sonarqube.com/web_api/api/users
http://docs.sonarqube.org/display/DEV/Web+API
The web service API does not seem to support user management. Anything's possible, but it doesn't look like this is offered directly via Sonar.
You could probably use some web automation library (webbrowser, webunit, watir, twill) to do it through the running server; it might even be possible to just use something like 'curl' by looking carefully at the page source for the users/create form.
Or, if you want to go straight to the database, you could try to pull out the user creation functionality from the code and mess with the sonar.users table directly.
There is the LDAP Plugin, which would take care of authentication, but it still requires you to create the users in Sonar, so that wouldn't solve your problem.

How to deal with database initialization?

As also described here, I'm trying to determine the best way to initialize and update my application's database. I use EclipseLink-JPA2. I distribute a NetBeans platform application.
Considered options:
use create-tables ddl-generation:
The problem with this is that everytime the application runs it will throw exceptions, failing to create the tables. It will be useful only at setup time. This would be similar to placing checking code in the module restored() method.
include the database with the application distribution: the ddl-generation strategy becomes do nothing. I could still use the JPA (at development time) to generate the database files (embedded Java DB).
The best solution would be for the installer/setup (first-time) to call initializing code that creates the database. This precisely what I do with JWS in here. But I don't know how to do that without JWS. A script/jar executed by the installer?
Distribute your NetBeans Platform application via JWS.
It seems like you already have this problem sorted out with JWS, so just use that solution to deploy your NetBeans platform app.
EDIT
An alternative approach would be to use a Module Installer that checks for the existence of a config file. If the file exists then the application has been run before and the setup is not required. If the file doesn't exist then run your setup steps.
Have a look at this tutorial, they're using a module installer to create a login dialog.

Resources