class VersionPolicyHandler extends ComponentSupport implements Handler {

  @Nonnull
  @Override
  public Response handle(@Nonnull final Context context) throws Exception {
    final MavenPath path = context.getAttributes().require(MavenPath.class);
    final MavenFacet mavenFacet = context.getRepository().facet(MavenFacet.class);
    final VersionPolicy versionPolicy = mavenFacet.getVersionPolicy();
    final Coordinates coordinates = path.getCoordinates();
    if (coordinates != null && !versionPolicyValidator.validArtifactPath(versionPolicy, coordinates)) {
      return createResponse(context,
          "Repository version policy: " + versionPolicy + " does not allow version: " + coordinates.getVersion());
    }
    if (!versionPolicyValidator.validMetadataPath(versionPolicy, path.main().getPath())) {
      return createResponse(context,
          "Repository version policy: " + versionPolicy + " does not allow metadata in path: " + path.getPath());
    }
    return context.proceed();
  }

  @Inject public  VersionPolicyHandler(final VersionPolicyValidator versionPolicyValidator);

}