Add a license to an artifact

@param gavc
@param licenseId
@throws GrapesCommunicationException
@throws javax.naming.AuthenticationException
167484
public void addLicense(final String gavc, final String licenseId, final String user, final String password) throws GrapesCommunicationException, AuthenticationException{
        final Client client = getClient(user, password);
        final WebResource resource = client.resource(serverURL).path(RequestUtils.getArtifactLicensesPath(gavc));
        final ClientResponse response = resource.queryParam(ServerAPI.LICENSE_ID_PARAM, licenseId).post(ClientResponse.class);

        client.destroy();
        if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){
            final String message = "Failed to add license " + licenseId + " to artifact " + gavc;
            if(LOG.isErrorEnabled()) {
                LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
            }
            throw new GrapesCommunicationException(message, response.getStatus());
        }
    }
660692
public void setLicense( final CharSequence license) {
		if ( license != null) format.getHeader().createEntry( LICENSE, license);
	}
691256
@GET
    @Produces({MediaType.APPLICATION_JSON})
    @Path("/{gavc}" + ServerAPI.GET_LICENSES)
    public Response getLicenses(@PathParam("gavc") final String gavc, @Context final UriInfo uriInfo){

        if(LOG.isInfoEnabled()) {
            LOG.info(String.format("Got a get artifact licenses request [%s]", gavc));
        }
        final LicenseListView view = new LicenseListView("Licenses of " + gavc);

        final FiltersHolder filters = new FiltersHolder();
        filters.init(uriInfo.getQueryParameters());

        final List<DbLicense> dbLicenses = getArtifactHandler().getArtifactLicenses(gavc,filters);
        for(final DbLicense license: dbLicenses){
            view.add(getModelMapper().getLicense(license));
        }

        return Response.ok(view).build();
    }
1199932
@GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/{gavc}" + ServerAPI.SET_DO_NOT_USE)
    public Response getDoNotUse(@PathParam("gavc") final String gavc){
        if(LOG.isInfoEnabled()) {
            LOG.info(String.format("Got a get doNotUse artifact request [%s]", gavc));
        }

        final DbArtifact artifact = getArtifactHandler().getArtifact(gavc);

        return Response.ok(artifact.getDoNotUse()).build();
    }
1216619
public void setAddLicenseSpecifications(java.util.Collection<LicenseSpecification> addLicenseSpecifications) {
        if (addLicenseSpecifications == null) {
            this.addLicenseSpecifications = null;
            return;
        }

        this.addLicenseSpecifications = new java.util.ArrayList<LicenseSpecification>(addLicenseSpecifications);
    }
322579
protected function configureLicenseKey(InputInterface $input, OutputInterface $output, $licenseKey)
    {
        if (!is_string($licenseKey)) {
            throw new \InvalidArgumentException('Config "licenseKey" must be string type.');
        }

        $licenseFileContent = "<" . "? $" . "LICENSE_KEY = \"" . EscapePHPString($licenseKey) . "\"; ?" . ">";
        File::putFileContents(Application::getDocumentRoot() . BX_ROOT . '/license_key.php', $licenseFileContent);
    }
629326
public void setLicenseSpecifications(java.util.Collection<LicenseSpecification> licenseSpecifications) {
        if (licenseSpecifications == null) {
            this.licenseSpecifications = null;
            return;
        }

        this.licenseSpecifications = new java.util.ArrayList<LicenseSpecification>(licenseSpecifications);
    }
119354
private ExtensionLicense getExtensionLicense(License license)
    {
        if (license.getName() == null) {
            return new ExtensionLicense("noname", null);
        }

        return createLicenseByName(license.getName());
    }
1190750
public void setLicenses(java.util.Collection<LicenseConfiguration> licenses) {
        if (licenses == null) {
            this.licenses = null;
            return;
        }

        this.licenses = new com.amazonaws.internal.SdkInternalList<LicenseConfiguration>(licenses);
    }
1138944
public void setLicense(String photoId, int licenseId) throws FlickrException {
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("method", METHOD_SET_LICENSE);
        parameters.put("photo_id", photoId);
        parameters.put("license_id", Integer.toString(licenseId));

        // Note: This method requires an HTTP POST request.
        Response response = transportAPI.post(transportAPI.getPath(), parameters, apiKey, sharedSecret);
        if (response.isError()) {
            throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
        }
        // This method has no specific response - It returns an empty sucess response if it completes without error.

    }
1354650
@DELETE
    @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
    @Path("/{name}")
    public Response delete(@Auth final DbCredential credential, @PathParam("name") final String name){
        if(!credential.getRoles().contains(AvailableRoles.DATA_DELETER)){
            throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build());
        }

        LOG.info("Got a delete license request.");
        getLicenseHandler().deleteLicense(name);
        cacheUtils.clear(CacheName.PROMOTION_REPORTS);
        return Response.ok("done").build();
    }
460053
public void addCACertificatesToTrustStore(BufferedInputStream bis) throws CryptoException, InvalidArgumentException {

        if (bis == null) {
            throw new InvalidArgumentException("The certificate stream bis cannot be null");
        }

        try {
            final Collection<? extends Certificate> certificates = cf.generateCertificates(bis);
            for (Certificate certificate : certificates) {
                addCACertificateToTrustStore(certificate);
            }

        } catch (CertificateException e) {
            throw new CryptoException("Unable to add CA certificate to trust store. Error: " + e.getMessage(), e);
        }
    }
1280944
public void addBundledSignatures(String name, String jdkTargetVersion) throws IOException,ParseException {
    final Set<String> missingClasses = new TreeSet<String>();
    addBundledSignatures(name, jdkTargetVersion, true, missingClasses);
    reportMissingSignatureClasses(missingClasses);
  }
733115
@Override
    public void addAuthorization(FoxHttpAuthorizationScope foxHttpAuthorizationScope, FoxHttpAuthorization foxHttpAuthorization) {
        if (foxHttpAuthorizations.containsKey(foxHttpAuthorizationScope.toString())) {
            foxHttpAuthorizations.get(foxHttpAuthorizationScope.toString()).add(foxHttpAuthorization);
        } else {
            foxHttpAuthorizations.put(foxHttpAuthorizationScope.toString(), new ArrayList<>(Collections.singletonList(foxHttpAuthorization)));
        }

    }
652426
public void deleteArtifact(final String gavc, final String user, final String password) throws GrapesCommunicationException, AuthenticationException{
        final Client client = getClient(user, password);
        final WebResource resource = client.resource(serverURL).path(RequestUtils.getArtifactPath(gavc));
        final ClientResponse response = resource.delete(ClientResponse.class);

        client.destroy();
        if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){
            final String message = "Failed to DELETE artifact " + gavc;
            if(LOG.isErrorEnabled()) {
                LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
            }
            throw new GrapesCommunicationException(message, response.getStatus());
        }
    }
841986
public synchronized void addIceCandidate(IceCandidate candidate) throws OpenViduException {
		if (!this.isWeb()) {
			throw new OpenViduException(Code.MEDIA_NOT_A_WEB_ENDPOINT_ERROR_CODE, "Operation not supported");
		}
		if (webEndpoint == null) {
			candidates.addLast(candidate);
		} else {
			internalAddIceCandidate(candidate);
		}
	}
564470
public Object displayLicenseFile(InputStream licenseFile, CommandConsole commandConsole) {
        Object e = LicenseUtility.class;
        if (licenseFile != null) {
            e = showLicenseFile(licenseFile, commandConsole);
        }
        if (e != null) {
            commandConsole.printErrorMessage(CommandUtils.getMessage("LICENSE_NOT_FOUND"));
        }
        return e;
    }