Ejemplo n.º 1
0
  public String getVersion() {
    if (version == null) {
      IPath sdkLocation = getLocation().makeAbsolute();

      if (!sdkLocation.isEmpty()) {
        try {
          version = SDKUtil.readSDKVersion(sdkLocation.toOSString());

          if (version.equals(ILiferayConstants.V611.toString())) {
            Properties buildProperties =
                getProperties(sdkLocation.append("build.properties").toFile()); // $NON-NLS-1$

            if (hasAppServerSpecificProps(buildProperties)) {
              version = ILiferayConstants.V612.toString();
            }
          }

          if (version.equals(ILiferayConstants.V6120.toString())) {
            Properties buildProperties =
                getProperties(sdkLocation.append("build.properties").toFile()); // $NON-NLS-1$

            if (hasAppServerSpecificProps(buildProperties)) {
              version = ILiferayConstants.V6130.toString();
            }
          }
        } catch (Exception e) {
          SDKCorePlugin.logError("Could not detect the sdk version.", e); // $NON-NLS-1$
        }
      }
    }

    return version;
  }
Ejemplo n.º 2
0
  public boolean isValid() {
    IPath sdkLocation = getLocation();

    if (sdkLocation == null) {
      return false;
    }

    if (!SDKUtil.isSDKSupported(sdkLocation.toOSString())) {
      return false;
    }

    if (!SDKUtil.isValidSDKLocation(sdkLocation.toOSString())) {
      return false;
    }

    return true;
  }
Ejemplo n.º 3
0
  public IStatus validate(final boolean reload) {
    MultiStatus status = new MultiStatus(SDKCorePlugin.PLUGIN_ID, IStatus.OK, "", null);

    boolean validLocation = SDKUtil.isValidSDKLocation(getLocation().toOSString());

    boolean buildXmlExists = getLocation().append("build.xml").toFile().exists(); // $NON-NLS-1$

    if (!validLocation) {
      status.add(SDKCorePlugin.createErrorStatus(Msgs.SDKLocationInvalid));
      return status;
    }

    if (!buildXmlExists) {
      status.add(SDKCorePlugin.createErrorStatus(Msgs.buildXmlFileNotExist));
      return status;
    }

    Map<String, Object> sdkProperties = null;

    try {
      sdkProperties = getBuildProperties(reload);

      if (sdkProperties == null) {
        status.add(SDKCorePlugin.createErrorStatus("Could not find any sdk settting."));
        return status;
      }
    } catch (Exception e) {
      status.add(SDKCorePlugin.createErrorStatus(e.getMessage()));
      return status;
    }

    for (String propertyKey : APP_SERVER_PROPERTIES_KEYS) {
      final String propertyValue = (String) sdkProperties.get(propertyKey);

      if (propertyValue == null) {
        status.add(SDKCorePlugin.createErrorStatus(propertyKey + " is null."));
      } else {
        switch (propertyKey) {
          case "app.server.type":
            {
              if (!SUPPORTED_SERVER_TYPES.contains(propertyValue)) {
                status.add(
                    SDKCorePlugin.createErrorStatus(
                        "The "
                            + propertyKey
                            + "("
                            + propertyValue
                            + ") server is not supported by Liferay IDE."));
              }

              break;
            }

          case "app.server.dir":
          case "app.server.deploy.dir":
          case "app.server.lib.global.dir":
          case "app.server.parent.dir":
          case "app.server.portal.dir":
            {
              IPath propertyPath = new Path(propertyValue);

              if (!propertyPath.isAbsolute()) {
                status.add(
                    SDKCorePlugin.createErrorStatus(
                        "The " + propertyKey + "(" + propertyValue + ") is not absolute path."));
              }

              if (!propertyPath.toFile().exists()) {
                status.add(
                    SDKCorePlugin.createErrorStatus(
                        "The " + propertyKey + "(" + propertyValue + ") is not exsit."));
              }

              break;
            }
          default:
        }
      }
    }

    return status;
  }