class ModuleResource extends AbstractResource {

    @POST
    @Produces(MediaType.TEXT_HTML)
    public Response postModule(@Auth final DbCredential credential, final Module module) {
        if (!credential.getRoles().contains(AvailableRoles.DEPENDENCY_NOTIFIER)) {
            throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build());
        }

        if(LOG.isInfoEnabled()) {
            LOG.info(String.format("Got a post Module request [%s]", module == null ? "NULL" : module.getName()));
        }

        // Checks if the data is corrupted
        DataValidator.validate(module);

        // turn it into DbModel
        final DbModule dbModule = getModelMapper().getDbModule(module);
        final DbOrganization organization = getOrganizationHandler().getMatchingOrganization(dbModule);
        if (organization != null) {
            dbModule.setOrganization(organization.getName());
        }

        // Save the module
        getModuleHandler().store(dbModule);

        final ArtifactHandler artifactHandler = getArtifactHandler();

        // Add the artifacts
        final Set<Artifact> artifacts = DataUtils.getAllArtifacts(module);
        for (final Artifact artifact : artifacts) {
            artifactHandler.store(getModelMapper().getDbArtifact(artifact));
        }

        // Add dependencies that does not already exist
        for (final Dependency dep : DataUtils.getAllDependencies(module)) {
            final DbArtifact dbDependency = getModelMapper().getDbArtifact(dep.getTarget());
            artifactHandler.storeIfNew(dbDependency);
        }

        return Response.ok().status(HttpStatus.CREATED_201).build();
    }

    public  ModuleResource(final RepositoryHandler repoHandler, final GrapesServerConfig dmConfig);

}