예제 #1
0
  public int compareTo(Object obj) {
    if (!(obj instanceof PluginPackage)) {
      return -1;
    }

    PluginPackage pluginPackage = (PluginPackage) obj;

    return getName().compareTo(pluginPackage.getName());
  }
예제 #2
0
  public boolean equals(Object obj) {
    if (!(obj instanceof PluginPackage)) {
      return false;
    }

    PluginPackage pluginPackage = (PluginPackage) obj;

    EqualsBuilder equalsBuilder = new EqualsBuilder();

    equalsBuilder.append(getModuleId(), pluginPackage.getModuleId());
    equalsBuilder.append(getRepositoryURL(), pluginPackage.getRepositoryURL());

    return equalsBuilder.isEquals();
  }
  public List<PluginPackage> getPluginPackages(String groupId, String artifactId) {

    List<PluginPackage> pluginPackages = new ArrayList<PluginPackage>();

    for (PluginPackage pluginPackage : _pluginPackages.values()) {
      if (pluginPackage.getGroupId().equals(groupId)
          && pluginPackage.getArtifactId().equals(artifactId)) {

        pluginPackages.add(pluginPackage);
      }
    }

    return pluginPackages;
  }
  public PluginPackage getLatestPluginPackage(String groupId, String artifactId) {

    PluginPackage latestPluginPackage = null;

    for (PluginPackage pluginPackage : _pluginPackages.values()) {
      if (pluginPackage.getGroupId().equals(groupId)
          && pluginPackage.getArtifactId().equals(artifactId)
          && ((latestPluginPackage == null)
              || pluginPackage.isLaterVersionThan(latestPluginPackage))) {

        latestPluginPackage = pluginPackage;
      }
    }

    return latestPluginPackage;
  }
  public void addPluginPackage(PluginPackage pluginPackage) {
    if (pluginPackage.getContext() == null) {
      if (_log.isDebugEnabled()) {
        _log.debug(
            "Plugin package cannot be registered because it does not "
                + "have an installation context");
      }

      return;
    }

    _pendingPackages.remove(pluginPackage.getContext());
    _pendingPackages.remove(pluginPackage.getModuleId());

    _pluginPackages.remove(pluginPackage.getContext());
    _pluginPackages.put(pluginPackage.getContext(), pluginPackage);
  }
  public void removePluginPackage(PluginPackage pluginPackage) throws PortalException {

    _pluginPackages.remove(pluginPackage.getContext());

    Indexer indexer = IndexerRegistryUtil.getIndexer(PluginPackage.class);

    indexer.delete(pluginPackage);
  }
  public void registerPluginPackageInstallation(PluginPackage pluginPackage) {
    if (pluginPackage.getContext() != null) {
      PluginPackage previousPluginPackage = _pluginPackages.get(pluginPackage.getContext());

      if (previousPluginPackage == null) {
        addPluginPackage(pluginPackage);
      }
    }

    String key = pluginPackage.getContext();

    if (key == null) {
      key = pluginPackage.getModuleId();
    }

    _pendingPackages.put(key, pluginPackage);
  }
예제 #8
0
  @Override
  public void executeRead(
      HttpServletRequest request, JSONObject responseJSONObject, Queue<String> arguments) {

    JSONObject pluginPackageJSONObject = JSONFactoryUtil.createJSONObject();

    String context = arguments.poll();

    PluginPackage pluginPackage = DeployManagerUtil.getInstalledPluginPackage(context);

    boolean installed = true;

    if (pluginPackage == null) {
      installed = false;
    }

    pluginPackageJSONObject.put("installed", installed);

    boolean started = true;

    if (pluginPackage == null) {
      started = false;
    }

    pluginPackageJSONObject.put("started", started);

    List<String> types = new ArrayList<>();

    if (pluginPackage != null) {
      types = pluginPackage.getTypes();
    }

    JSONArray typesJSONArray = JSONFactoryUtil.createJSONArray();

    for (String type : types) {
      typesJSONArray.put(type);
    }

    pluginPackageJSONObject.put("types", typesJSONArray);

    responseJSONObject.put(JSONKeys.OUTPUT, pluginPackageJSONObject);
  }
  public void registerPluginPackageInstallation(String deploymentContext) {
    PluginPackage pluginPackage = getPluginPackage(deploymentContext);

    if (pluginPackage == null) {
      String moduleId =
          deploymentContext
              + StringPool.SLASH
              + deploymentContext
              + StringPool.SLASH
              + Version.UNKNOWN
              + StringPool.SLASH
              + "war";

      pluginPackage = new PluginPackageImpl(moduleId);

      pluginPackage.setName(deploymentContext);
      pluginPackage.setContext(deploymentContext);
    }

    registerPluginPackageInstallation(pluginPackage);
  }
예제 #10
0
 public boolean isSameVersionAs(PluginPackage pluginPackage) {
   return _moduleId.isSameVersionAs(pluginPackage.getVersion());
 }
예제 #11
0
 public boolean isPreviousVersionThan(PluginPackage pluginPackage) {
   return _moduleId.isPreviousVersionThan(pluginPackage.getVersion());
 }
  @AccessControlled(guestAccessEnabled = true)
  @Override
  public SyncContext getSyncContext() throws PortalException {
    try {
      User user = getGuestOrUser();

      SyncContext syncContext = new SyncContext();

      String authType =
          PrefsPropsUtil.getString(
              CompanyThreadLocal.getCompanyId(),
              PropsKeys.COMPANY_SECURITY_AUTH_TYPE,
              PropsUtil.get(PropsKeys.COMPANY_SECURITY_AUTH_TYPE));

      syncContext.setAuthType(authType);

      boolean oAuthEnabled =
          PrefsPropsUtil.getBoolean(
              user.getCompanyId(),
              PortletPropsKeys.SYNC_OAUTH_ENABLED,
              PortletPropsValues.SYNC_OAUTH_ENABLED);

      if (oAuthEnabled) {
        String oAuthConsumerKey =
            PrefsPropsUtil.getString(user.getCompanyId(), PortletPropsKeys.SYNC_OAUTH_CONSUMER_KEY);

        syncContext.setOAuthConsumerKey(oAuthConsumerKey);

        String oAuthConsumerSecret =
            PrefsPropsUtil.getString(
                user.getCompanyId(), PortletPropsKeys.SYNC_OAUTH_CONSUMER_SECRET);

        syncContext.setOAuthConsumerSecret(oAuthConsumerSecret);
      }

      syncContext.setOAuthEnabled(oAuthEnabled);

      PluginPackage syncWebPluginPackage = DeployManagerUtil.getInstalledPluginPackage("sync-web");

      syncContext.setPluginVersion(syncWebPluginPackage.getVersion());

      if (!user.isDefaultUser()) {
        syncContext.setPortalBuildNumber(ReleaseInfo.getBuildNumber());

        PluginPackage soPortletPluginPackage =
            DeployManagerUtil.getInstalledPluginPackage("so-portlet");

        syncContext.setPortletPreferencesMap(getPortletPreferencesMap());

        if (soPortletPluginPackage != null) {
          syncContext.setSocialOfficeInstalled(true);
        } else {
          syncContext.setSocialOfficeInstalled(false);
        }

        syncContext.setUser(user);
        syncContext.setUserSitesGroups(getUserSitesGroups());
      }

      return syncContext;
    } catch (PortalException pe) {
      throw new PortalException(SyncUtil.buildExceptionMessage(pe), pe);
    }
  }