class ArtifactResource extends AbstractResource {

    @POST
    public Response postArtifact(@Auth final DbCredential credential, final Artifact artifact){
        if(!credential.getRoles().contains(AvailableRoles.DATA_UPDATER)){
            throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build());
        }
        
        LOG.info("Got a post Artifact request [" + artifact.getGavc() + "]");
        
        // setting default origin to maven
        if(artifact.getOrigin() == null || artifact.getOrigin().isEmpty()){
        	artifact.setOrigin("maven");
        }
        
        // Checks if the data is corrupted
        DataValidator.validatePostArtifact(artifact);

        
        // Store the Artifact
        final ArtifactHandler artifactHandler = getArtifactHandler();

        // checking artifact with same SHA256
        final DbArtifact artifactWithSameSHA = artifactHandler.getArtifactUsingSHA256(artifact.getSha256());
        
        if(artifactWithSameSHA != null){
        	throw new WebApplicationException(Response.serverError().status(HttpStatus.CONFLICT_409)
                        .entity("Artifact with same checksum already exists.").build());
        }
        
        // checking artifact with same SHA256
        DbArtifact artifactWithSameGAVC = null;
        try{
        	artifactWithSameGAVC = artifactHandler.getArtifact(artifact.getGavc());
        }catch(WebApplicationException e){
        	LOG.info("Validating result for artifact GAVC: No matching artifact found " + e);
        }
        
        if(artifactWithSameGAVC != null){
        	throw new WebApplicationException(Response.serverError().status(HttpStatus.CONFLICT_409)
                        .entity("Artifact with same GAVC already exists.").build());
        }

        artifact.setCreatedDateTime(new Date());
                
        final DbArtifact dbArtifact = getModelMapper().getDbArtifact(artifact);
        artifactHandler.store(dbArtifact);

        // Add the licenses
        for(final String license: artifact.getLicenses()){
            artifactHandler.addLicense(dbArtifact.getGavc(), license);
        }

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

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

}