Bypassing Google’s Internet Censorship

A few days ago, I started developing on android, and I want to see some tutorials in android developers web site, so navigate my browser to developer.android.com , but I got this error :

Forbidden
Your client does not have permission to get URL / from this server. (Client IP address: <my-ip>)

You are accessing this page from a forbidden country.

Yes, google applies US sanction against some countries, or we can say that google is another department of US government .
So, I tried to use anonymous browsing applications such as Vidalia and Your Freedom to get result, but the result was the same, Forbidden !
Then I tried a vpn connection, and I was thinking that this should work, but this solution did not work, too !
I remembered that Opera Mini has a mechanism that can bypass internet censorship, so browsed this address in my android phone with opera mini …
This time, google could not detect my ip, and the page opened normally .
( perhaps if google did not restrict this site access,  I could damage US peaple or militaries ! lol )

Opera mini solved the problem, just in mobile, but I want to see that website in computer . With a search by google ! I found that there is a micro emulator that can run MIDlet files, and because Opera mini has a java me version, I could  run it on my computer .
I had to download this micro emulator form google ,code.google.com , becuase that project resides on google codes,  and also this site has restricted access . But there was another way to download, Maven !

I had an option,  to add the micro emulator project, as a dependency to my maven projects.
So I added this code snippets to one of my maven projects :

<repository>
    <id>pyx4j-web-snapshot</id>
    <url>http://repository.pyx4j.com/maven2-snapshot</url>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
    <releases>
        <enabled>false</enabled>
    </releases>
</repository>

and :

<dependency>
    <groupId>org.microemu</groupId>
    <artifactId>microemulator</artifactId>
    <version>2.0.4</version>
    <scope>provided</scope>
</dependency>

And with a maven install command, I downloaded the micro emulator !
Everything was OK to browse developer.android.com on my computer, using Opera Mini jar file and Micro Emulator jar file !

Now, what do you think !?
If we can access to google services normally, what will lose google !?

Posted in Java | 2 Comments

Dirty Status in Spring RCP

Spring RCP ( Rich Client Project ) does not provide a public API for updating dirty status of user forms, so if you want to update this status, you must implement your own way.

Usually, you need three functionalities regarding dirty status in a form :
First, you need to query the form status, to know that the form is dirty or not. Spring RCP provides a public method by AbstractFormModel class that returns the status of a form :

/**
* Returns true if this formModel or any of its children has
* dirty valueModels.
*/
public boolean isDirty() {
return dirtyValueAndFormModels.size() > 0;
}

Second, you need to update this status manually, specially if you have implemented customized binding or validation regarding your business requirements. Spring RCP has a protected method by AbstractFormModel class that do this. So you must extend this class and override this method :

import org.springframework.binding.form.support.AbstractFormModel;

public class MyFormModel extends AbstractFormModel {
...

/**
* Fires the necessary property change event for changes to the dirty
* property. Must be called whenever the value of dirty is changed.
*/
protected void dirtyUpdated() {
super.dirtyUpdated();
//TODO : implement your own dirtyUpdated ...
}

...

}

Third, sometimes you may want to put an object in dirty status or say that an object is not dirty. The class AbstractFormModel, has a property that keeps all dirty objects and form models :

private final Set dirtyValueAndFormModels = new HashSet();

You can add an object to this property, if you want to say that this object is in dirty status, or remove the object from this property, if the object or form model is clean :

public class MyFormModel extends AbstractFormModel {
...

/**
* Add input object to dirtyValueAndFormModels .
*/
public void addDirtyObject( Object anObject ) {
	Field dirtyValueAndFormModelsField = AbstractFormModel.class.getDeclaredField("dirtyValueAndFormModels");
	HashSet dirtyValueAndFormModels = (HashSet) dirtyValueAndFormModelsField.get( this );
	dirtyValueAndFormModels.add( getFormObject() );
}

/**
* Remove input object from dirtyValueAndFormModels .
*/
public void removeDirtyObject( Object anObject ) {
	Field dirtyValueAndFormModelsField = AbstractFormModel.class.getDeclaredField("dirtyValueAndFormModels");
	HashSet dirtyValueAndFormModels = (HashSet) dirtyValueAndFormModelsField.get( this );
	dirtyValueAndFormModels.remove( getFormObject() );
}

...

}
Posted in Java | Leave a comment