Posts

How to match date filed in Google Datastore

How to match date filed in Google Datastore Suppose you have an 'Employee' entity with updatedOn field (Date or timestamp type). You can use Date function to parse date string and filter your data. In GQL, you can use:   SELECT * FROM EmployeeObj where updatedOn > Date ('2014-09-25') Similarly in objectify, you can use filter           Objectify obfy = OfyService.ofy();           List<EmployeeObj> resultList = obfy.load().type(EmployeeObj.class) .filter("updatedOn > ", Date('2014-09-25'))                                                  .list();

Upload csv file at Google Cloud Storage using java

First do all required pre requiste as per google doc https://cloud.google.com/appengine/docs/java/googlestorage/ Now see the sample code for a csv file uploader using latest api public String uploadFileUsingGCSClient(String csvDate, String fileName, String dirName,String bucketName) throws IOException {  // init the bucket access     GcsService gcsService = GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());     GcsFilename filename = new GcsFilename(bucketName+"/"+dirName, fileName);     GcsFileOptions fileOptions = new GcsFileOptions.Builder()    .mimeType("application/CSV")       .acl("public-read")    //.addUserMetadata("myfield1", "my field value")    .build();     GcsOutputChannel outputChannel = gcsService.createOrReplace(filename, fileOptions);          // write file using this st...

Struts 2 - struts tag with boolean property

Struts 2 - struts tag <s:if test= "booleanVaue" > with boolean property Always remember two points -- 1) Check your bean (.java) file for getter, setter for boolean type value   private boolean isTest;   private boolean hasCheck;    public boolean isTest() {         return isTest;     }     public void setTest(boolean isTest) {         this.isTest= isTest;     }    public boolean isHasCheck() {         return hasCheck;     }     public void setHasCheck(boolean hasCheck) {         this.hasCheck= hasCheck;     } ------------------------------------------------------------------------- On a jsp page if you are using these two variables in a <s:if> conditions <s:if test=" isTest "> // This will not work, will always ret...

Can not connect to git using ssh (Permissions 0644 for '/root/.ssh/id_rsa' are too open.

Permissions 0644 for '/root/.ssh/id_rsa' are too open. It is required that your private key files are NOT accessible by others. ------------------------ root@media-Vostro-1540:~/.ssh# ssh -T git@github.com @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for '/root/.ssh/id_rsa' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. bad permissions: ignore key: /root/.ssh/id_rsa Permission denied (publickey). Solution : First check the permission on id_rsa directory root@media-Vostro-1540:~/.ssh# ls -lrt total 12 -rw-r--r-- 1 root root 2160 Jun  4 15:05 known_hosts -rw-r--r-- 1 root root 1766 Jun  4 15:12 id_rsa -rw-r--r-- 1 root root  415 Jun  4 15:12 id_rsa.pub Ch...

appengine:devserver_stop not working in Windows 8/eclipse

If you have added appengine:devserver_stop in eclipse as a debug goal in maven goals and still you are not able to stop the server then you can manually close the server on given port. Let's take an example that your server is running on 8080 that you want to stop. 1) Open command line prompt:    netstat -a -n -o You will get following output......  Proto  Local Address          Foreign Address        State           PID  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       700  TCP    0.0.0.0:445            0.0.0.0:0         ...

DFP API works fine at localhost but failed Google App engine (access denied ("java.lang.RuntimePermission" "getClassLoader")

DFP API works fine at localhost but failed Google App engine (access denied ("java.lang.RuntimePermission" "getClassLoader") --------------------------------------------------------------------------  com.google.api.ads.common.lib.exception.ServiceException: Unexpected Exception.     com.google.api.ads.common.lib.soap.jaxws.JaxWsHandler.createSoapClient(JaxWsHandler.java:210)     com.google.api.ads.common.lib.soap.jaxws.JaxWsHandler.createSoapClient(JaxWsHandler.java:1)     com.google.api.ads.common.lib.factory.helper.BaseAdsServiceClientFactoryHelper.createSoapClient(BaseAdsServiceClientFactoryHelper.java:106)     com.google.api.ads.common.lib.factory.helper.BaseAdsServiceClientFactoryHelper.createAdsServiceClient(BaseAdsServiceClientFactoryHelper.java:71)     com.google.api.ads.common.lib.factory.AdsServiceClientFactory.getServiceClient(AdsServiceClientFactory.java:73)     com.google.api...

Writing a zip file on Google App engine

package com.lin.web.servlet; import java.io.BufferedWriter; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.io.IOUtils; import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.client.http.ByteArrayContent; import com.google.api.client.http.GenericUrl; import com.google.api.client.http.HttpRequest; import com.google.api.client.http.HttpRequestFactory; import com.google.api.client.http.HttpResponse; import com.google.api.client.http.HttpTransport; import com.google.api.cl...