IT Certificaions

Google Cloud Platform

Tuesday, December 16, 2014

Generate Random file name in Java

You can create a random string for a file name using following code snippet.

public static String getRandomString(String fileName) {
char fileNameArray[] = fileName.toCharArray();
int fileNameLen = fileNameArray.length;
int c = 'A';
int r1 = 0, z=0;
StringBuilder pw = new StringBuilder("");
for (int j = 0; j < 25; j++) {
r1 = (int) (Math.random() * 4);
switch (r1) {
case 0:
c = '0' + (int) (Math.random() * 9);
if (c>'9'){
z = reset(z,fileNameLen);
c = fileNameArray[z];
}
break;
case 1:
c = 'a' + (int) (Math.random() * 25);
if (c<'a' && c>'z'){
z = reset(z,fileNameLen);
c = fileNameArray[z];
}
break;
case 2:
c = 'A' + (int) (Math.random() * 25);
if (c<'A' && c>'Z'){
z = reset(z,fileNameLen);
c = fileNameArray[z];
}
break;
}
pw.append((char) c);
}
fileNameArray = null;
String s="";
try{
s =fileName.substring(fileName.lastIndexOf(".")); 
if (s.equalsIgnoreCase(".tmp")){
s=".jpg";
}
}catch(ArrayIndexOutOfBoundsException arrayExp){
s="";
}
return new String(pw+s.trim());
}

private static int reset(int z, int len){
if (z>=len){
z=0;
}
return z;
}

Wednesday, December 10, 2014

Tomcat 7: Set context path for your application in tomcat 7

Set context path for your application in tomcat 7

If you want to change context path for your application, you can do by changing
{catalina_base}/conf/server.xml file.
Suppose, you have deployed your application in tomcat 7,
              http://localhost:8080/MyApp
You want to set context path to newMyApp,
Modify, host element in server.xml under tomcat/conf

<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="false">
....
... .
<Context path="/ newMyApp "  docBase="/ MyApp " reloadable="true">
 </Context>



 </Host>

For detailed information, visit http://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html#A_word_on_Contexts

Maven :: Include servlet-api only at local maven install not during building war

Include  servlet-api  only at local maven install not during building war
Add scope element with value as ‘Provided’. Now maven will not include this jar in lib whiling

building war file so that you can deploy it on tomcat.

 <dependency>
 <groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>

For all scopes in maven, please visit http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope

JAXB:GlobalBinding :: cvc-complex-type.2.4.b: The content of element 'jaxb:globalBindings' is not complete

Error ::
 cvc-complex-type.2.4.b: The content of element 'jaxb:globalBindings' is not complete. One of '{"http://

 java.sun.com/xml/ns/jaxb":javaType, "http://java.sun.com/xml/ns/jaxb":serializable, WC[##other:"http://

 java.sun.com/xml/ns/jaxb"]}' is expected.


Solution :

  Check  <jaxb:globalBindings> tag in your bindings.xml, you may be missing some required tag (If you are using latest eclipse like eclipse-Luna or latest).
 Add this tag if missing,

<jaxb:globalBindings>
            <jaxb:javaType name="java.util.Calendar" xmlType="xs:dateTime" 
parseMethod="javax.xml.bind.DatatypeConverter.parseDateTime" 
printMethod="javax.xml.bind.DatatypeConverter.printDateTime" />
            <xjc:noValidator />

    </jaxb:globalBindings>  

Thursday, October 9, 2014

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 stream
    BufferedOutputStream outStream = new BufferedOutputStream(Channels.newOutputStream(outputChannel));
    
    // read the input stream
    byte[] buffer = new byte[1024];
    //List<byte[]> allBytes = new LinkedList<byte[]>();
    InputStream reader = new ByteArrayInputStream(csvDate.getBytes());
    while(true) {
        int bytesRead = reader.read(buffer);
        //log.info("bytesRead:"+bytesRead);
        if (bytesRead == -1) {
            break; // have a break up with the loop.
        } else if (bytesRead < 1024) {
            byte[] temp = Arrays.copyOf(buffer, bytesRead);
            outStream.write(temp);
           
        } else {
        outStream.write(buffer);
        }
    }

    outStream.close();
    outputChannel.close();
    String uploadedFileURL="gs://"+bucketName+"/"+dirName+"/"+fileName;
    log.info("uploadedFileURL : "+uploadedFileURL);
    return uploadedFileURL;
  }

Tuesday, August 12, 2014

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 return blank value as isTest is conflicting with getter method isTest();
</s:if>

<s:if test="hasCheck">
  // This will work whatever the value you have set from action
</s:if>

Wednesday, June 4, 2014

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

Change it to write only for root user
---------------------------------------------------

root@media-Vostro-1540:~/.ssh# chmod 700 id_rsa

root@media-Vostro-1540:~/.ssh# ls -lrt
total 12
-rw-r--r-- 1 root root 2160 Jun  4 15:05 known_hosts
-rwx------ 1 root root 1766 Jun  4 15:12 id_rsa
-rw-r--r-- 1 root root  415 Jun  4 15:12 id_rsa.pub
root@media-Vostro-1540:~/.ssh# ssh -T git@github.com

Tuesday, May 20, 2014

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 -oYou 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              LISTENING       4
 TCP    0.0.0.0:49152          0.0.0.0:0              LISTENING       432
 TCP    0.0.0.0:49153          0.0.0.0:0              LISTENING       756
 TCP    0.0.0.0:49154          0.0.0.0:0              LISTENING       788
 TCP    0.0.0.0:49155          0.0.0.0:0              LISTENING       548
 TCP    0.0.0.0:49156          0.0.0.0:0              LISTENING       540
 TCP    10.0.0.69:139          0.0.0.0:0              LISTENING       4
 TCP    10.0.0.69:59690        74.125.23.125:5222     ESTABLISHED     1396
 TCP    127.0.0.1:8080         0.0.0.0:0              LISTENING       2004
.................
............
..........

Note the PID, and give second command as below.
Suppose you have PID= 2004 then enter following command
2)  Taskkill /PID 2004 /F

It will stop the process.

Thursday, May 15, 2014

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.ads.common.lib.factory.BaseAdsServiceClientFactory.getServiceClientAsInterface(BaseAdsServiceClientFactory.java:79)
    com.google.api.ads.common.lib.factory.BaseServices.get(BaseServices.java:60)
    com.example.dfp.api.DFPReportService.downloadReport(DFPReportService.java:2210)
    com.example.dfp.api.DFPReportService.getDFPTargetReportByAccountIds(DFPReportService.java:3243)
    com.example.web.action.LinDigitalDFPTargetReportAction.runNonFinaliseLinDigitalReport(LinDigitalDFPTargetReportAction.java:253)
    com.example.web.action.LinDigitalDFPTargetReportAction.dailyLinDigitalReport(LinDigitalDFPTargetReportAction.java:72)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:45)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:468)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    org.mortbay.jetty.Server.handle(Server.java:326)
    org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
    com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
    com.google.tracing.CurrentContext.runInContext(CurrentContext.java:188)
    com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
    com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
    com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
    java.lang.Thread.run(Thread.java:724)
   

java.lang.ExceptionInInitializerError

    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    java.lang.Class.newInstance(Class.java:370)
    javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:49)
    javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:134)
    javax.xml.ws.spi.Provider.provider(Provider.java:127)
    javax.xml.ws.Service.(Service.java:77)
    com.google.api.ads.dfp.jaxws.v201311.ReportService.(ReportService.java:42)
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    java.lang.reflect.Constructor.newInstance(Constructor.java:33)
    com.google.api.ads.common.lib.soap.jaxws.JaxWsHandler.createSoapClient(JaxWsHandler.java:185)
    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.ads.common.lib.factory.BaseAdsServiceClientFactory.getServiceClientAsInterface(BaseAdsServiceClientFactory.java:79)
    com.google.api.ads.common.lib.factory.BaseServices.get(BaseServices.java:60)
    com.example.dfp.api.DFPReportService.downloadReport(DFPReportService.java:2210)
    com.example.dfp.api.DFPReportService.getDFPTargetReportByAccountIds(DFPReportService.java:3243)
    com.example.web.action.LinDigitalDFPTargetReportAction.runNonFinaliseLinDigitalReport(LinDigitalDFPTargetReportAction.java:253)
    com.example.web.action.LinDigitalDFPTargetReportAction.dailyLinDigitalReport(LinDigitalDFPTargetReportAction.java:72)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:45)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:468)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    org.mortbay.jetty.Server.handle(Server.java:326)
    org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
    com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
    com.google.tracing.CurrentContext.runInContext(CurrentContext.java:188)
    com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
    com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
    com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
    java.lang.Thread.run(Thread.java:724)
   

java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader")

    com.google.appengine.runtime.Request.process-30ea8b5c7cfe9cdd(Request.java)
    java.security.AccessControlContext.checkPermission(AccessControlContext.java:375)
    java.security.AccessController.checkPermission(AccessController.java:565)
    java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    java.lang.ClassLoader.checkClassLoaderPermission(ClassLoader.java:1556)
    java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1475)
    com.sun.xml.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:515)
    com.sun.xml.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:58)
    com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:249)
    com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:100)
    com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:81)
    com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:209)
    com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:95)
    com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:81)
    com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:315)
    com.sun.xml.bind.v2.model.impl.TypeRefImpl.calcRef(TypeRefImpl.java:92)
    com.sun.xml.bind.v2.model.impl.TypeRefImpl.getTarget(TypeRefImpl.java:69)
    com.sun.xml.bind.v2.model.impl.RuntimeTypeRefImpl.getTarget(RuntimeTypeRefImpl.java:58)
    com.sun.xml.bind.v2.model.impl.RuntimeTypeRefImpl.getTarget(RuntimeTypeRefImpl.java:51)
    com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl$1.get(ElementPropertyInfoImpl.java:74)
    com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl$1.get(ElementPropertyInfoImpl.java:77)
    java.util.AbstractList$Itr.next(AbstractList.java:358)
    com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:255)
    com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:100)
    com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:81)
    com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:209)
    com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:95)
    com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:81)
    com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:315)
    com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:330)
    com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:441)
    com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:288)
    com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1111)
    com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
    com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:253)
    javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:240)
    javax.xml.bind.ContextFinder.find(ContextFinder.java:440)
    javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)
    javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
    com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:220)
    com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:218)
    java.security.AccessController.doPrivileged(AccessController.java:34)
    com.sun.xml.ws.spi.ProviderImpl.getEPRJaxbContext(ProviderImpl.java:217)
    com.sun.xml.ws.spi.ProviderImpl.(ProviderImpl.java:88)
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    java.lang.Class.newInstance(Class.java:370)
    javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:49)
    javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:134)
    javax.xml.ws.spi.Provider.provider(Provider.java:127)
    javax.xml.ws.Service.(Service.java:77)
    com.google.api.ads.dfp.jaxws.v201311.ReportService.(ReportService.java:42)
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    java.lang.reflect.Constructor.newInstance(Constructor.java:33)
    com.google.api.ads.common.lib.soap.jaxws.JaxWsHandler.createSoapClient(JaxWsHandler.java:185)
    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.ads.common.lib.factory.BaseAdsServiceClientFactory.getServiceClientAsInterface(BaseAdsServiceClientFactory.java:79)
    com.google.api.ads.common.lib.factory.BaseServices.get(BaseServices.java:60)
    com.example.dfp.api.DFPReportService.downloadReport(DFPReportService.java:2210)
    com.example.dfp.api.DFPReportService.getDFPTargetReportByAccountIds(DFPReportService.java:3243)
    com.example.web.action.LinDigitalDFPTargetReportAction.runNonFinaliseLinDigitalReport(LinDigitalDFPTargetReportAction.java:253)
    com.example.web.action.LinDigitalDFPTargetReportAction.dailyLinDigitalReport(LinDigitalDFPTargetReportAction.java:72)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:45)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:468)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    org.mortbay.jetty.Server.handle(Server.java:326)
    org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
    com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
    com.google.tracing.CurrentContext.runInContext(CurrentContext.java:188)
    com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
    com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
    com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
    java.lang.Thread.run(Thread.java:724)
   
--------------------------------------------------------------------------------------------------------------------   

Solution- Remove these dependencies from pom.xml
<dependency>
            <groupId>org.jvnet.jaxb2_commons</groupId>
            <artifactId>runtime</artifactId>
            <version>0.4.1.5</version>
            <exclusions>
                <exclusion>
                    <artifactId>jaxb-impl</artifactId>
                    <groupId>com.sun.xml.bind</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>jaxb-api</artifactId>
                    <groupId>javax.xml.bind</groupId>
                </exclusion>
            </exclusions>
        </dependency>

Either comment them or delete them.

Tuesday, April 8, 2014

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.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson.JacksonFactory;
import com.lin.dfp.api.DFPReportService;
import com.lin.dfp.api.IDFPReportService;
import com.lin.web.gaebigquery.BigQueryUtil;
import com.lin.web.util.LinMobileConstants;
import com.lin.web.util.LinMobileVariables;


public class GAEZipFileDownloader extends HttpServlet {

  private static final long serialVersionUID = 1L;

  private static final String GCS_URI = "http://commondatastorage.googleapis.com";
  static final String UPLOAD_URL="https://www.googleapis.com/upload/storage/v1beta2/b/linmobile_qa/o?uploadType=multipart";

  /** Global configuration of Google Cloud Storage OAuth 2.0 scope. */
  private static final String STORAGE_SCOPE =
      "https://www.googleapis.com/auth/devstorage.read_write";


  private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
  private static final JsonFactory JSON_FACTORY = new JacksonFactory();
  private static final Logger log = Logger.getLogger(BigQueryUtil.class.getName());
  private static List<String> SCOPES=new ArrayList<>();
 
  private static GoogleCredential credential;
  
  static final int BUFFER_SIZE = 2* 1024 * 1024;
 
 
  public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException  {
      System.out.println("here........");
      ByteArrayOutputStream zipBaos = new ByteArrayOutputStream();
    try {
        String fileURL="http://storage.googleapis.com/myBucket/test.csv.gz";
        IDFPReportService dfpReportService=new DFPReportService();
        String csvData=dfpReportService.readCSVGZFile(fileURL);
        StorageServiceServlet st=new StorageServiceServlet();
        System.out.println("csv data:"+csvData);
      
        InputStream in = new ByteArrayInputStream(csvData.getBytes());
      
     
        ZipOutputStream zipOut = new ZipOutputStream(zipBaos);
      
        byte[] file1Contents = IOUtils.toByteArray(in);
      
        ZipEntry zipEntry1 = new ZipEntry("testFile.csv");     // Create new zip entry                                                                     // the constructor parameter is filename of the entry
        zipOut.putNextEntry(zipEntry1);            // add the zip entry to the ZipOutputStream
        zipOut.write(file1Contents);               // write contents (byte array) to the ZipOutputStream
        zipOut.closeEntry();  
        zipOut.close();
      
     
      
      /*  String csPath=st.uploadViaZip(csvData, "test_proc.csv.gz", "test", LinMobileVariables.APPLICATION_BUCKET_NAME);
        System.out.println("csPath:"+csPath); */ 
        System.out.println("Done............");
      
      } catch (Throwable e) {
          e.printStackTrace();
          // Creation of the zip file failed; inform the browser about it
          res.sendError(500, "Creation of the zip file failed with exception:\n\n" + e.getLocalizedMessage());
         return;
    }
  
    // Get the zip data from the ByteArrayOutputStream
    byte[] zipData = zipBaos.toByteArray();


    // Serve the data to response's stream
    String filename = "MyZipFile.zip";

    // following header statement instructs the web browser
    // to treat the file as attachment (= to download the file)
    res.setHeader("Content-Disposition", "attachment; filename=" + filename);

    res.setContentType("application/x-download");
    res.setContentLength(zipData.length);
    res.getOutputStream().write(zipData);  
  }
 
  
 
}