Package com.onpositive.gae.tools

Source Code of com.onpositive.gae.tools.GaeBridge

package com.onpositive.gae.tools;

import java.io.File;
import java.io.FileNotFoundException;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;

import com.google.appengine.eclipse.core.resources.GaeProject;
import com.onpositive.gae.tools.core.WebRootDirProvider;

public class GaeBridge {

  public static IContainer getWebFolder(IProject project) throws FileNotFoundException{
    try {
      if (project.getProject().getNature(
          Constants.GOOGLE_APP_ENGINE_NATURE) == null) {
        return null;
      }
    } catch (CoreException e) {
      return null;
    }

    GaeProject create = GaeProject.create(project);

    if (create == null) {
      return null;
    }
    IContainer warFolder = WebRootDirProvider.calculate(project);
    if( !warFolder.exists()){
      throw new FileNotFoundException("Web Root Location Incorrect");
    }
    return warFolder;
  }

  public static String getAppId(IProject project) {
    try {
      if (project.getProject().getNature(
          Constants.GOOGLE_APP_ENGINE_NATURE) == null) {
        return null;
      }
    } catch (CoreException e) {
      Activator
          .getDefault()
          .getLog()
          .log(new Status(0, Activator.PLUGIN_ID,
              "CoreException || GAE Nature == null", e));
      return null;
    }
    // Activator.getDefault().getLog().log(new Status(0,
    // "com.onpositive.gae.tools.core", "INFO: GAE NATURE != null"));
    GaeProject create = null;
    try {
      create = GaeProject.create(project);
    } catch (Throwable e) {
      Activator.getDefault().getLog()
          .log(new Status(0, Activator.PLUGIN_ID, "Throwable", e));
      return null;
    }
    if (create == null) {
      Activator
          .getDefault()
          .getLog()
          .log(new Status(0, Activator.PLUGIN_ID,
              "Created GAE Project == null"));
      return null;
    }
    // IFolder warFolder2 = create.getWarFolder();

    IFolder warFolder = project.getFolder("war");
    if (warFolder == null) {
      Activator
          .getDefault()
          .getLog()
          .log(new Status(0, Activator.PLUGIN_ID,
              "War Folder for GAE Project == null"));
      return null;

    }
    /*
     * if (create.getSdk() == null) { return null; }
     */
    return create.getAppId();
  }

  public static String getVersion(IProject project) {
    try {
      if (project.getProject().getNature(
          Constants.GOOGLE_APP_ENGINE_NATURE) == null) {
        return null;
      }
    } catch (CoreException e) {
      return null;
    }

    GaeProject create = GaeProject.create(project);
    if (create == null) {
      return null;
    }
    IFolder warFolder = project.getFolder("war");
    if (warFolder == null) {
      return null;

    }
    // if (create.getSdk() == null) {
    // return null;
    // }
    return create.getAppVersion();
  }
}
TOP

Related Classes of com.onpositive.gae.tools.GaeBridge

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.