Examples of PlexusResourceException


Examples of org.sonatype.plexus.rest.resource.PlexusResourceException

      RepositoryGroupResource resource = groupRequest.getData();

      if (StringUtils.isEmpty(resource.getId())) {
        getLogger().warn("Repository group id is empty! ");

        throw new PlexusResourceException(
            Status.CLIENT_ERROR_NOT_FOUND,
            "Repository group id is empty! ",
            getNexusErrorResponse("repositories", "Repository group id can't be empty! "));
      }

      createOrUpdateRepositoryGroup(resource, false);

      try {
        result.setData(buildGroupResource(request, groupRequest.getData().getId()));
      }
      catch (NoSuchRepositoryException e) {
        throw new PlexusResourceException(
            Status.CLIENT_ERROR_NOT_FOUND,
            "Repository group id is somehow invalid! ",
            getNexusErrorResponse("repositories", "Repository group id is invalid! "));
      }
    }
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResourceException

      throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, msg);
    }
    catch (NoSuchUserManagerException e) {
      ErrorResponse errorResponse = getErrorResponse("*", e.getMessage());

      throw new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Unable to update account '"
          + dto.getUserId() + "'.", errorResponse);
    }
    catch (AuthorizationException e) {
      throw new ResourceException(Status.CLIENT_ERROR_FORBIDDEN, "Not allowed to update account '" + dto.getUserId()
          + "'.");
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResourceException

      PrivilegeResource resource = resourceRequest.getData();

      // currently we are allowing only of repotarget privs, so enforcing checkfor it
      if (!TargetPrivilegeDescriptor.TYPE.equals(resource.getType())) {
        throw new PlexusResourceException(
            Status.CLIENT_ERROR_BAD_REQUEST,
            "Configuration error.",
            getErrorResponse("type", "Not allowed privilege type!"));
      }

      List<String> methods = resource.getMethod();

      if (methods == null || methods.size() == 0) {
        throw new PlexusResourceException(
            Status.CLIENT_ERROR_BAD_REQUEST,
            "Configuration error.",
            getErrorResponse("method", "No method(s) supplied, must select at least one method."));
      }
      else {
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResourceException

          else if (resource.isSecurityAnonymousAccessEnabled()) {
            // the supplied anon auth info is wrong/empty
            getLogger().warn(
                "Nexus refused to apply configuration, the supplied anonymous username/pwd information is empty.");

            throw new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, getNexusErrorResponse(
                "securityAnonymousUsername", "Cannot be empty when Anonynous access is enabled"));
          }
          else {
            getNexusConfiguration().setAnonymousAccess(false, null, null);
          }

          if (resource.getGlobalRestApiSettings() != null) {
            RestApiSettings restApiSettings = resource.getGlobalRestApiSettings();

            getGlobalRestApiSettings().setForceBaseUrl(restApiSettings.isForceBaseUrl());

            if (StringUtils.isEmpty(resource.getGlobalRestApiSettings().getBaseUrl())) {
              getGlobalRestApiSettings().setBaseUrl(null);
            }
            else {
              getGlobalRestApiSettings().setBaseUrl(
                  new Reference(restApiSettings.getBaseUrl()).getTargetRef().toString());
            }

            getGlobalRestApiSettings().setUITimeout(restApiSettings.getUiTimeout() * 1000);
          }
          else {
            getGlobalRestApiSettings().disable();
          }

          // NEXUS-3064: to "inform" global remote storage context (and hence, all affected proxy
          // repositories) about the change, but only if config is saved okay
          // TODO: this is wrong, the config framework should "tell" this changed, but we have some
          // design flaw here: the globalRemoteStorageContext is NOT a component, while the settings are
          boolean remoteConnectionSettingsIsDirty = ((DefaultGlobalRemoteConnectionSettings)getGlobalRemoteConnectionSettings()).isDirty();

          boolean remoteProxySettingsIsDirty = ((DefaultGlobalRemoteProxySettings)getGlobalRemoteProxySettings()).isDirty();

          getNexusConfiguration().saveConfiguration();

          // NEXUS-3064: to "inform" global remote storage context (and hence, all affected proxy
          // repositories) about the change, but only if config is saved okay
          // TODO: this is wrong, the config framework should "tell" this changed, but we have some
          // design flaw here: the globalRemoteStorageContext is NOT a component, while the settings are
          if (remoteConnectionSettingsIsDirty) {
            getNexusConfiguration().getGlobalRemoteStorageContext().setRemoteConnectionSettings(
                getGlobalRemoteConnectionSettings());
          }

          if (remoteProxySettingsIsDirty) {
            getNexusConfiguration().getGlobalRemoteStorageContext().setRemoteProxySettings(
                getGlobalRemoteProxySettings()
            );
          }
        }
        catch (IOException e) {
          getLogger().warn("Got IO Exception during update of Nexus configuration.", e);

          throw new ResourceException(Status.SERVER_ERROR_INTERNAL);
        }
        catch (InvalidConfigurationException e) {
          // TODO: this should be removed from the Global config, as it is NO longer part of the nexus.xml
          getLogger().debug("Configuraiton Exception while setting security values", e);
          this.handleInvalidConfigurationException(e);
        }
        catch (ConfigurationException e) {
          getLogger().warn("Nexus refused to apply configuration.", e);

          throw new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, e.getMessage(),
              getNexusErrorResponse("*", e.getMessage()));
        }
      }
    }
    // TODO: this method needs some serious cleaning up...
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResourceException

    }
    catch (NoSuchRepositoryAccessException e) {
      // access denied 403
      getLogger().warn("Repository referenced by Repository Group Access Eenied, ID=" + model.getId(), e);

      throw new PlexusResourceException(
          Status.CLIENT_ERROR_BAD_REQUEST,
          "Repository referenced by Repository Group Access Denied, GroupId="
              + model.getId(),
          e,
          getNexusErrorResponse("repositories",
              "Repository referenced by Repository Group Access Denied"));
    }
    catch (NoSuchRepositoryException e) {
      getLogger().warn("Repository referenced by Repository Group Not Found, ID=" + model.getId(), e);

      throw new PlexusResourceException(
          Status.CLIENT_ERROR_BAD_REQUEST,
          "Repository referenced by Repository Group Not Found, GroupId="
              + model.getId(),
          e,
          getNexusErrorResponse("repositories",
              "Repository referenced by Repository Group Not Found"));
    }
    catch (InvalidGroupingException e) {
      getLogger().warn("Invalid grouping detected!, GroupId=" + model.getId(), e);

      throw new PlexusResourceException(
          Status.CLIENT_ERROR_BAD_REQUEST,
          "Invalid grouping requested, GroupId=" + model.getId(),
          e,
          getNexusErrorResponse("repositories",
              e.getMessage()));
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResourceException

         * getNexusErrorResponse( "repositories", "Repository referenced by Repository Group Access Denied" ) ); }
         */
    catch (NoSuchRepositoryException e) {
      getLogger().warn("Repository referenced by group does not exists!, GroupId=" + model.getId(), e);

      throw new PlexusResourceException(
          Status.CLIENT_ERROR_BAD_REQUEST,
          "Repository referenced by group does not exists, GroupId="
              + model.getId(),
          e,
          getNexusErrorResponse("repositories",
              "Repository referenced by Repository Group does not exists!"));
    }
    catch (InvalidGroupingException e) {
      getLogger().warn("Invalid grouping detected!, GroupId=" + model.getId(), e);

      throw new PlexusResourceException(
          Status.CLIENT_ERROR_BAD_REQUEST,
          "Invalid grouping requested, GroupId=" + model.getId(),
          e,
          getNexusErrorResponse("repositories", e.getMessage()));
    }
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResourceException

        result.setData(buildGroupResource(request, resource.getId()));

        return result;
      }
      catch (NoSuchRepositoryException e) {
        throw new PlexusResourceException(
            Status.CLIENT_ERROR_BAD_REQUEST,
            "The group was somehow not found!",
            getNexusErrorResponse("repositories", "Group id not found!"));
      }
    }
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResourceException

      catch (ConfigurationException e) {
        handleConfigurationException(e);
      }
      catch (StorageException e) {
        ErrorResponse nexusErrorResponse = getNexusErrorResponse("*", e.getMessage());
        throw new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Configuration error.",
            nexusErrorResponse);
      }
      catch (IOException e) {
        getLogger().warn("Got IO Exception!", e);

View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResourceException

    }
    else {
      errorResponse = getErrorResponse("*", e.getMessage());
    }

    throw new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Configuration error.", errorResponse);
  }
View Full Code Here

Examples of org.sonatype.plexus.rest.resource.PlexusResourceException

    UserToRoleResource userToRole = mappingRequest.getData();

    Set<RoleIdentifier> roleIdentifiers = this.restToSecurityModel(userToRole);

    if (roleIdentifiers.size() == 0) {
      throw new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Configuration error.",
          getErrorResponse("roles", "User requires one or more roles."));
    }

    try {
      // this will throw if we cannot find the user, in that case we will create one.
View Full Code Here
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.