Google API in Java application without a web server - java

I am working on a small Java Swing based application, and want to add a decorative feature in it to sync files with Google Drive. But, all the documentation / discussions about Google API's that I see talks about putting this code into a web application. Also, the credentials of the client on https://cloud.google.com/console require the origin URL, without which the API will not work.
I know I can either embed a Jetty or take the hard way of sending and receiving HTTP requests. But either would be an overkill for this petty application that I am making. So, I was wondering if there is a way to include a Jar file that just lets me login and then access the folders on the Google drive.
Do you know of one? Is this possible with the existing API's? Thanks for your help!

If you have a look at the detailed installation instructions then there is a section for general purpose java applications. That is your case.
The following are the jars from the dependencies folder required for general purpose Java 5 applications (or a newer compatible version of each dependency):
google-api-client-1.17.0-rc.jar
google-oauth-client-1.17.0-rc.jar
google-http-client-1.17.0-rc.jar
commons-logging-1.1.1.jar
gson-2.1.jar httpclient-4.0.3.jar
httpcore-4.0.1.jar
jackson-core-2.1.3.jar
jsr305-1.3.9.jar
protobuf-java-2.2.0.jar
xpp3-1.1.4c.jar
You can use the GooglePromptReceiver to ask the end user to paste the authorization code from the browser to your application. You can find examples in the samples. The cmdline samples apply to your case.

Related

How to ¿connect? a website and a Java App

This is just an introductory question for a problem that I'd be required to solve in the following weeks.
I have a website and a Java WebApp, both currently unrelated.
Website is BootStrap and Java App runs under Apache Tomcat.
The website is in one domain, and its core file is index.htm
The App is in other domain, and core is index.jsp, enclosed in a .war file
We will redesign the site , leave BootStrap and move to WordPress.
BUT, and this what I don't know how to do it, from the WordPress site I'd be required to LOGIN into Java App.
That is to create the typical user/pass miniform.
The web works at port 80, Java at 8080.... Any way, not being an expert is hard for me to imagine how to invoque Java Login from HTML, as the website is not going to be included inside the project.
I'm sure this is quite basic... Thank you!
It's a nice question you have.
I think the best solution is install a plugin in your wordpress project: **https://wordpress.org/plugins/json-api-auth**
with this plugin you can get a rest api login and then you only need to consume this api from your java application.

Adding e-commerce functionality and blog feature in local java application

I am a student working on college project. A newbie in web development.
I developed a local java application for book management system for a bookstore using JSP/Servlets in eclipse and tomcat server. It has registration screen, login screen etc. I have included session management.
Now, I am asked to include following features in the same project.
Requirement-
Add: a) E-commerce functionality to it (Online Store, Shopping Kart, Payment Gateway). You may integrate the open source code available easily.
b) Add a blog feature (again you may integrate available codes)
I am not sure how we can include these features in local application.
Could you please help?
You've got 3 architectural options to choose from:
1. integrate an open source library into your own server
2. run an open source server next to your Tomcat
3. use a hosted solution and integrate with it
(3) I'm not sure what are the exercise restrictions, but #3 is the easiest by far. You can use Shopify, Magento or even Wix to easily create a store. Wix also have blogs available. The integration should be as easy as adding a link from your JSP to that hosted solution.
(2) If that's not acceptable, you can run use an open source e-commerce/blog solution that you will run next to your Tomcat. OpenCart is the leading solution here.
(1) Now, if you really really need to integrate the source code into your own Tomcat, you're left with small libraries and code fragments available online. I must admit I recommend none of them as the headache of integrating them is usually greater than the good of using them.

Edit files (read/edit/save) in java based web application via webdav

im searching for informations how to implement a service in our servlet based java web application which can handle online editing (reading / editing / saving) of some common file types like the programs of the office suite via webdav.
We have a tomcat 7 running and using webdav already for mounting folders on client computers (implemented by an colleague) which works fine.
Now im having the request to research ways to implement this online editing features (for example open a .doc file in our webapp, edit the file in word and save it automaticly in our webapp) and couldn't find that many informations/howtos about this topic.
From what i could find so far i could see that using this webdav feature some response header values needs to be set and a own servlet needs to be implemented.
But im still not sure where to start and if im right...
Does anybody knows any good resoures for this? (documentations, simple webapp example, ...whatever)?
You should use Milton, its intended for exactly the purpose you describe. Its pretty simple to implement, you create annotatated methods which make the information in your web application available via webdav. This includes file and folder browsing, as well as uploading, downloading and locking (required for MS Office)
There are tutorials on the milton website which guide you through the implementation process.
Here's a simple hello world implementation from the first tutorial:
https://github.com/miltonio/milton2/blob/master/examples/tuts-anno1/src/main/java/com/helloworld/HelloWorldController.java
Milton comes with a free community edition which supports DAV level 1 only. That will work with most 3rd party webdav clients like Bitkinex, Cyberduck, etc. But for compatibility with operating system webdav clients, including Win7, MacOS, MS Office, you need the enterprise edition which is available on a commercial license.
Please see the milton site for details - http://milton.io
(I'm the author)

Need Help On using APIs of open sources

I have started working on various open source frameworks like zookeeper, Hadoop, Solr. I have learnt their architecture . But when it comes to develop applications using JAVA API , where will i get the packages containing API that will be compatible with the version of framework . Is it like when i download the framework(Zookeeper) , the jar files (needed for API) also comes along with it. I am a beginner with java , and it might seem a silly question to all of you. Please help me out by sharing your knowledge.
Thanks
The depends on what tools you use. First, understand that if you "download the framework" as you state what you are doing is downloading the "jar files (needed for the API)". That is the only thing to be downloaded. In some cases there might be a core jar and an api jar but this is what constitutes the "framework" and what must be downloaded and added to your applications classpath.
That said, if you use a tool like Maven, it will take care of a lot of this for you once you add the framework as a dependency.

Newbie using Google App Engine

I've just started using Google App Engine and I have a few questions about it. I hope you can help me:
Once my Java web application is running on Google App Engine. What if one day I decide to run it on my own server. Which programs/services would I need? Is it difficult to configure?
I have a Javascript code that I would like to store on Google Application Engine, so that external webpages can run it directly. Is it possible? Otherwise could I deploy a Java application on Google App which returns this Javascript code? How could an external site ask on "execution time" for this code and run it?
THANKS!!
AppScale supports Java and allows users to deploy and host their own Google App Engine applications
Of course you can, although GAE is not meant to be used as a CDN.
Have a look to Static Files and Resource Files documentation.
It depends on what services you actually use. Take a look at AppScale, it will facilitate running your application on your own servers. I would also suggest looking at TyphoonAE (Python only), to see another software 'stack' providing similar services.
See the section on static files and resources in the docs.

Categories