google-code-export / orkut-os-client

Automatically exported from code.google.com/p/orkut-os-client
Apache License 2.0
1 stars 1 forks source link

Unable to run sample code "SampleApp" #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am unable to run sample code "SampleApp".The code link is given below
file:///home/teja/Downloads/orkut-os-client-1.0-007f393481/java/html/overview.ht
ml.

I am using following oauth properties.
# enter the consumer key and secret here
consumerKey=248308281354
consumerSecret= GByr6oNK1cz2/mzas2Wa0tNZ
accessUrl=https\://www.google.com/accounts/OAuthGetAccessToken
authorizationUrl=https\://www.google.com/accounts/OAuthAuthorizeToken
requestUrl=https\://www.google.com/accounts/OAuthGetRequestToken
saveAccessToken=true
scope=http\://sandbox.orkut.gmodules.com/social/rpc
serverUrl=http\://sandbox.orkut.com/social/rpc

When i enter the above oauth properties,run the sample App code the
following errors occur.

Exception in thread "main" java.io.FileNotFoundException:
sample/oauth.properties (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:137)
    at java.io.FileInputStream.<init>(FileInputStream.java:96)
    at com.google.orkut.client.config.FileConfig.<init>(FileConfig.java:36)
    at com.google.orkut.client.sample.Transport.<init>(Transport.java:63)
    at com.google.orkut.client.sample.SampleApp.<init>(SampleApp.java:34)
    at com.google.orkut.client.sample.SampleApp.main(SampleApp.java:43)

         Kindly help me
                                                                 Regards,
                                                                   teja.

Original issue reported on code.google.com by snchandr...@gmail.com on 31 May 2010 at 6:53

GoogleCodeExporter commented 9 years ago
The problem is in FileConfig.java of the Orkut API 
(orkut-os-client\java\src\com\google\orkut\client\config\FileConfig.java).

There's a variable called CONFIG_FILE as follows:

public final String CONFIG_FILE = "sample/oauth.properties";

That's OK for when you run the sample through command line, but when you try to 
build your own project with the orkut JAR it's a problem, because the JAR you 
have generated has that preestablished path into it.

My solution was to delete that variable declaration and pass it as a String to 
the FileConfig constructor like this:

public FileConfig(String propfile) throws IOException {
    FileInputStream fileInputStream = new FileInputStream(propfile);
    props = new Properties();
    props.load(fileInputStream);
    fileInputStream.close();
  }

This way every time you call FileConfig you have to pass YOUR propfile path.  
You should change all the calls to this constructor (there're not so many), in 
BatchTransaction.java and Transport.java.

After that rebuild the project with "ant" / "ant dist" to re-generate the 
"correct" JAR.  And that's all.

Hope that helps,

Natalia

Original comment by natalia....@gmail.com on 9 Nov 2010 at 2:53