JavaHL.Unable to commit with my java application - java

I want to control my Subversion environment (Sliksvn 1.8.10) with a small Java programm on a Windows 7 64 bit machine. I need to use JavaHL (1.8.x) not SVNKIt. I have implemented a funktion to checkout a repository, add files to a work copy and commit files to repository. The checkout and the add function works fine so far. The problem ist now, that the commit-funktion don't work correctly.
public void commit()
{
Set<String> paths = new HashSet<String>();
paths.add( "C:\\Users\\XXX\\Documents\\SVNTEST\\Test3" );
Depth dep = Depth.infinity;
);
CommitMessageCallback handler = new CommitMessageCallback()
{
#Override
public String getLogMessage(Set<CommitItem> arg0) {
// TODO Auto-generated method stub
System.out.println(arg0.size());
return null;
}
};
CommitCallback callback = new CommitCallback()
{
#Override
public void commitInfo(CommitInfo arg0) {
// TODO Auto-generated method stub
System.out.println(arg0.getAuthor());
}
};
try
{
client.commit( paths, dep, true, false, null, null, handler, callback );
}
catch( ClientException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
When i process the commit function, then i get from the CommitMessageCallback function the amount of the commit items. This works still. My problem is now, that don't receive any CommitInfo from the CommitCallback function. I think maybe, the process breaks up in der subversion environment and my function get no result. After the process, the commit Items are still in svn status "Item is scheduled for Addition".
I work on this problem since a few days with different version of the JavaHL.jar api, but it was not successful. The big problem is also, that i receive no error message and i dont know what is wrong in code.
Have anybody a idea what is wrong in my commit function ?
Perhaps is the libsvnjavahl-1.dll file not compatible with certain JavaHL Api's ?
Thank you very much
Best regards Simon

Okay, i solved the problem now. The easy solution was to use the org.tigris.subversion instead of the org.apache.subversion library classes. But the question is, why exist two different version from the JavaHL library ?

Related

Eclipse Plugin Development - Detect/Listen File open in editor

I need to detect when a file (of any type) is opened in Eclipse and run some code when that happens.
I've tried with the following code but it seems to be calling the function multiple times:
Display.getDefault().asyncExec(new Runnable() {
#Override
public void run() {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener(new IPartListener2() {
#Override
public void partOpened(IWorkbenchPartReference partRef) {
System.out.println("File opened");
}
});
}
});
Is there a way to do this in Eclipse RCP?
IPartListener2.partOpened is the correct thing to use. Make sure you only set up the listener once.
partOpened will be called for all parts, so you will need to check for the ones you are interested in.
#Override
public void partOpened(final IWorkbenchPartReference partRef)
{
// Check for editor reference and get the editor part
if (partRef instanceof IEditorReference &&
partRef.getPart(false) instanceof IEditorPart editorPart) {
// Example getting current IFile being edited:
IFile file = editorPart.getEditorInput().getAdapter(IFile.class);
}
}
Note: Example code uses Java 16 type pattern, for older releases it will need revising.
Also note Display.asyncExec is not usually needed to set this up.

Wicket DropDownChoice onSelectionChanged method removed after version update

I was designated as a developer to upgrade our old wicket app from 6.x to 8.x. I am resolving multiple errors one by one, but (since I never worked with wicket) one I am unable to move on with.
In version 6.x it had DropDownChoice with overriden onSelectionChanged which no longer exists in version 8.x and I am unable to find any info about deprecation (going through 7.x versions...) so it seems they just removed it .. what are my alternatives here? The aforementioned code:
booleanType = new DropDownChoice<BooleanType>("booleanType", new PropertyModel<>(this, "selectedBooleanType"), booleanTypes) {
#Override
protected void onSelectionChanged(BooleanType newSelection) {
super.onSelectionChanged(newSelection);
selectedBooleanType = newSelection;
}
};
EDIT:
Similar question that I found only later
Wicket 6 to 8 upgrade: RadioGroup.onSelectionChanged() replacement
for those wondering how to update the value since it is not coming as an argument of the method anymore:
selectedType = (YourChoiceType) super.getFormComponent().getDefaultModelObject();
wantOnSelectionChangedNotifications moved to FormComponentUpdatingBehavior. From the changelog:
// Wicket 7.x
new CheckBox("id", model) {
protected boolean wantOnSelectionChangedNotifications() {
return true;
}
protected void onSelectionChanged(Boolean newSelection) {
// do something, page will be rerendered;
}
};
// Wicket 8.x
new CheckBox("id", model)
.add(new FormComponentUpdatingBehavior() {
protected void onUpdate() {
// do something, page will be rerendered;
}
protected void onError(RuntimeException ex) {
super.onError(ex);
}
});
(The example uses a CheckBox but it also applies to DropDownChoice).
For another example see the wiki.

Trying to get a list of Files in an internal Folder with libgdx

Im trying to make a level selection screen for a game
FileHandle dirHandle;
if(Gdx.app.getType() == ApplicationType.Android){
dirHandle = Gdx.files.internal("levels/");
} else{
dirHandle = Gdx.files.internal("./bin/levels");
}
for(FileHandle level : dirHandle.list()){
if(!level.name().equals("new_tileset.png") ){
Button mButton = new Button(buttonStyle);
mButton.addListener(new ChangeListener() {
#Override
public void changed(ChangeEvent event, Actor actor) {
// TODO Auto-generated method stub
game.setScreen(new GamePlay(game,level));
}
});
mTable.add(mButton);
}
}
this code seems to work on android and on desktop except when i export my project as an executable jar, there are no levels show, dirHandle.list() returns an empty array. Is there a work around for accessing files in my assets folder on desktop?
-Edit-
ok i tweaked my code a bit and it seems to work when i export it now. But it does not work when im running it from eclipse. Also when i upload the jar and download it and test it, the same thing happens, no levels show and dirHandle.list() is empty, i have no idea whats going on

Path requests must specify a user by using UserEnvironment

I am getting "Path requests must specify a user by using UserEnvironment" error by using
Environment.getExternalStorageDirectory().getPath()
I traced my code and I found that in java.io.Environment there is a function to produce this error :
private static void throwIfUserRequired() {
if (sUserRequired) {
Log.wtf(TAG, "Path requests must specify a user by using UserEnvironment",
new Throwable());
}
}
I searched in the web and found this solution from here
Environment.setUserRequired(false);
But this solution is not working for me because I cannot access to the "setUserRequired" method of Environment. I get compilation error. I searched this function in the Environment class and I found this :
/** {#hide} */
public static void setUserRequired(boolean userRequired) {
sUserRequired = userRequired;
}
Can anyone help me how can I access to my external storage of my phone? any solution ? it is emergency. Thanks a lot
You need to use UserEnvironment and get the path for this user.
int userId = UserHandle.myUserId();
sCurrentUser = new UserEnvironment(userId);
This code stolen from Environment.java and the code they use to initialize their internal user.
I could solve my problem by removing
Environment.getExternalStorageDirectory().getPath()
inside try-catch block and writing outside of the try-catch block,and it is working now.
Through the reflection to solve this problem
fun setUserRequired() {
var state = Environment.getExternalStorageDirectory()
if ("mounted".equals(state)) {
try {
var environmentcls = Class.forName("android.os.Environment");
var setUserRequiredM = environmentcls.getMethod("setUserRequired", Boolean::class.java);
setUserRequiredM.invoke(null, false);
} catch (e: Exception) {
e.printStackTrace()
}
}
}

Query Coherence using JMeter

This is the situation I'm in:
I have a web service that is using the Coherence grid to store data for faster results. The grid holds specific DTO objects -- When new data comes in from the users, I update these DTOs. Now, I need to write specific JMeter tests for this. I can add a EndPoint (Restful WS) to collect these DTOs to verify that the objects are being updated, but that's kind of mixing the QA and Dev.
Is there a way to connect directly to the Grid using JMeter and query it for my objects? Or even any way to create a stand-alone java app and run it through Jmeter (add specific params for querys) to return the objects..
Thanks guys!
Ninn
EDIT: java class to collect coherence objects
package disclosed.jmeter;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
import org.apache.jmeter.samplers.SampleResult;
import com.tangosol.net.CacheFactory;
import com.tangosol.net.NamedCache;
public class JmeterTest extends AbstractJavaSamplerClient{
#Override
public Arguments getDefaultParameters() {
// TODO Auto-generated method stub
return null;
}
#Override
public SampleResult runTest(JavaSamplerContext arg0) {
CacheFactory.getCluster().getMemberSet();
NamedCache cache = CacheFactory.getCache("myCache");
System.out.println("The value taken from the cache is: " + cache.get("message"));
SampleResult result = new SampleResult();
result.setResponseCode((String) cache.get("message"));
return result;
}
#Override
public void setupTest(JavaSamplerContext arg0) {
// TODO Auto-generated method stub
}
#Override
public void teardownTest(JavaSamplerContext arg0) {
// TODO Auto-generated method stub
}
}
Yes, you can query any service from JMeter, either if you have Java library to access it, or by simulating raw TCP/UDP network traffic.
Best way is to have existing Java library to access service. Then you may use it from BeanShell Sampler, or write custom Sampler, it's easy.
Further details strongly depends on library you choose.

Categories