bundles/ca.uqam.tool.vivo-proxy/src_custom/main/java/ca/uqam/tool/vivoproxy/pattern/command/receiver/VivoReceiver.java
public CommandResult addImageToIndividual(Image image) throws IOException{
		/* 
		 * Goto individual page
		 */
		Response response = VivoReceiverHelper.gotoIndividualPage(getHostName()+"/"+getVivoSiteName(), getHttpClient(), image.getIndividualIRI());
		/*
		 * get editKey
		 */
		System.out.println("getEditKey");
		HttpUrl url = HttpUrl.parse(getHostName()+"/"+getVivoSiteName() +"/uploadImages").newBuilder()
				.addQueryParameter("entityUri", image.getIndividualIRI())
				.addQueryParameter("action", "add")
				.build();
		Request request = new Request.Builder()
				.url(url)
				.method("GET", null)
				.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0")
				.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
				.addHeader("Accept-Language", "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3")
				.addHeader("Connection", "keep-alive")
				.addHeader("Referer", image.getIndividualIRI())
				.addHeader("Upgrade-Insecure-Requests", "1")
				.build();
		response =  getHttpClient()
				.newCall(request).execute();

		editKey = VivoReceiverHelper.getKeyValue(response.body().string());

		/*
		 * UploadImage
		 */

		File file = new File(image.getImageURL());
		String contentType = file.toURL().openConnection().getContentType();
		RequestBody fileBody = RequestBody.create(MediaType.parse(contentType), file);

		RequestBody requestBody = new MultipartBuilder()
				.type(MultipartBuilder.FORM)
				.addFormDataPart("Content-Disposition","form-data; name=\"datafile\"; filename=\""+file.getName()+"\"")
				.addFormDataPart("Content-Type",contentType)
				.addFormDataPart("datafile",file.getName(),fileBody)
				.build();
		HttpUrl upLoadUrl = HttpUrl.parse(getHostName()+"/"+getVivoSiteName() +"/uploadImages").newBuilder()
				.addQueryParameter("entityUri", image.getIndividualIRI())
				.addQueryParameter("action", "upload")
				.addQueryParameter("imageUrl", image.getImageURL())
				.build();

		Request upLoadRequest = new Request.Builder()
				.url(upLoadUrl)
				.method("POST", requestBody)
				.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
				.addHeader("Accept-Language", "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3")
				.addHeader("Content-Type", "image/jpeg")
				.addHeader("Origin", getHostName())
				.addHeader("Connection", "keep-alive")
				.addHeader("Referer", url.toString())
				.addHeader("Upgrade-Insecure-Requests", "1")
				.addHeader("Sec-Fetch-Dest", "document")
				.addHeader("Sec-Fetch-Mode", "navigate")
				.addHeader("Sec-Fetch-Site", "same-origin")
				.addHeader("Sec-Fetch-User", "?1")
				.build();
		Response upLoadResponse =  getHttpClient().newCall(upLoadRequest).execute();
		/*
		 * Save image
		 */

		MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
		RequestBody saveBody = RequestBody.create(mediaType, "x="+image.getOrigX()+"&y="+image.getOrigY()+"&w="+image.getWidth()+"&h="+image.getHeight());

		HttpUrl saveUrl = HttpUrl.parse(getHostName()+"/"+getVivoSiteName() +"/uploadImages").newBuilder()
				.addQueryParameter("entityUri", image.getIndividualIRI())
				.addQueryParameter("action", "save")
				.build();

		Request saveRequest = new Request.Builder()
				.url(saveUrl)
				.method("POST", saveBody)
				.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
				.addHeader("Accept-Language", "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3")
				.addHeader("Content-Type", "application/x-www-form-urlencoded")
				.addHeader("Origin", getHostName())
				.addHeader("Connection", "keep-alive")
				.addHeader("Referer", upLoadUrl.toString())
				.addHeader("Upgrade-Insecure-Requests", "1")
				.addHeader("Sec-Fetch-Dest", "document")
				.addHeader("Sec-Fetch-Mode", "navigate")
				.addHeader("Sec-Fetch-Site", "same-origin")
				.addHeader("Sec-Fetch-User", "?1")
				.build();
		Response saveResponse =  getHttpClient().newCall(saveRequest).execute();
		return CommandResult.asCommandResult(saveResponse);       

	}
/**
	 * Upload image associated to an individual
	 * @param image
	 * @return
	 * @throws IOException
	 */
Upload image associated to an individual
@param image
@return
@throws IOException
Upload image associated to an individual @param image @return @throws IOException
public CommandResult addImageToIndividual(Image image) throws IOException{
		/* 
		 * Goto individual page
		 */
		Response response = VivoReceiverHelper.gotoIndividualPage(getHostName()+"/"+getVivoSiteName(), getHttpClient(), image.getIndividualIRI());
		/*
		 * get editKey
		 */
		System.out.println("getEditKey");
		HttpUrl url = HttpUrl.parse(getHostName()+"/"+getVivoSiteName() +"/uploadImages").newBuilder()
				.addQueryParameter("entityUri", image.getIndividualIRI())
				.addQueryParameter("action", "add")
				.build();
		Request request = new Request.Builder()
				.url(url)
				.method("GET", null)
				.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0")
				.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
				.addHeader("Accept-Language", "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3")
				.addHeader("Connection", "keep-alive")
				.addHeader("Referer", image.getIndividualIRI())
				.addHeader("Upgrade-Insecure-Requests", "1")
				.build();
		response =  getHttpClient()
				.newCall(request).execute();
		editKey = VivoReceiverHelper.getKeyValue(response.body().string());
		/*
		 * UploadImage
		 */
		File file = new File(image.getImageURL());
		String contentType = file.toURL().openConnection().getContentType();
		RequestBody fileBody = RequestBody.create(MediaType.parse(contentType), file);
		RequestBody requestBody = new MultipartBuilder()
				.type(MultipartBuilder.FORM)
				.addFormDataPart("Content-Disposition","form-data; name=\"datafile\"; filename=\""+file.getName()+"\"")
				.addFormDataPart("Content-Type",contentType)
				.addFormDataPart("datafile",file.getName(),fileBody)
				.build();
		HttpUrl upLoadUrl = HttpUrl.parse(getHostName()+"/"+getVivoSiteName() +"/uploadImages").newBuilder()
				.addQueryParameter("entityUri", image.getIndividualIRI())
				.addQueryParameter("action", "upload")
				.addQueryParameter("imageUrl", image.getImageURL())
				.build();
		Request upLoadRequest = new Request.Builder()
				.url(upLoadUrl)
				.method("POST", requestBody)
				.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
				.addHeader("Accept-Language", "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3")
				.addHeader("Content-Type", "image/jpeg")
				.addHeader("Origin", getHostName())
				.addHeader("Connection", "keep-alive")
				.addHeader("Referer", url.toString())
				.addHeader("Upgrade-Insecure-Requests", "1")
				.addHeader("Sec-Fetch-Dest", "document")
				.addHeader("Sec-Fetch-Mode", "navigate")
				.addHeader("Sec-Fetch-Site", "same-origin")
				.addHeader("Sec-Fetch-User", "?1")
				.build();
		Response upLoadResponse =  getHttpClient().newCall(upLoadRequest).execute();
		/*
		 * Save image
		 */
		MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
		RequestBody saveBody = RequestBody.create(mediaType, "x="+image.getOrigX()+"&y="+image.getOrigY()+"&w="+image.getWidth()+"&h="+image.getHeight());
		HttpUrl saveUrl = HttpUrl.parse(getHostName()+"/"+getVivoSiteName() +"/uploadImages").newBuilder()
				.addQueryParameter("entityUri", image.getIndividualIRI())
				.addQueryParameter("action", "save")
				.build();
		Request saveRequest = new Request.Builder()
				.url(saveUrl)
				.method("POST", saveBody)
				.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
				.addHeader("Accept-Language", "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3")
				.addHeader("Content-Type", "application/x-www-form-urlencoded")
				.addHeader("Origin", getHostName())
				.addHeader("Connection", "keep-alive")
				.addHeader("Referer", upLoadUrl.toString())
				.addHeader("Upgrade-Insecure-Requests", "1")
				.addHeader("Sec-Fetch-Dest", "document")
				.addHeader("Sec-Fetch-Mode", "navigate")
				.addHeader("Sec-Fetch-Site", "same-origin")
				.addHeader("Sec-Fetch-User", "?1")
				.build();
		Response saveResponse =  getHttpClient().newCall(saveRequest).execute();
		return CommandResult.asCommandResult(saveResponse);       
	}
public CommandResult addImageToIndividual ( Image image ) throws IOException { /* 
		 * Goto individual page
		 */ Response response = VivoReceiverHelper . gotoIndividualPage ( getHostName ( ) + "/" + getVivoSiteName ( ) , getHttpClient ( ) , image . getIndividualIRI ( ) ) ; /*
		 * get editKey
		 */ System . out . println ( "getEditKey" ) ; HttpUrl url = HttpUrl . parse ( getHostName ( ) + "/" + getVivoSiteName ( ) + "/uploadImages" ) . newBuilder ( ) . addQueryParameter ( "entityUri" , image . getIndividualIRI ( ) ) . addQueryParameter ( "action" , "add" ) . build ( ) ; Request request = new Request . Builder ( ) . url ( url ) . method ( "GET" , null ) . addHeader ( "User-Agent" , "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0" ) . addHeader ( "Accept" , "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" ) . addHeader ( "Accept-Language" , "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3" ) . addHeader ( "Connection" , "keep-alive" ) . addHeader ( "Referer" , image . getIndividualIRI ( ) ) . addHeader ( "Upgrade-Insecure-Requests" , "1" ) . build ( ) ; response = getHttpClient ( ) . newCall ( request ) . execute ( ) ; editKey = VivoReceiverHelper . getKeyValue ( response . body ( ) . string ( ) ) ; /*
		 * UploadImage
		 */ File file = new File ( image . getImageURL ( ) ) ; String contentType = file . toURL ( ) . openConnection ( ) . getContentType ( ) ; RequestBody fileBody = RequestBody . create ( MediaType . parse ( contentType ) , file ) ; RequestBody requestBody = new MultipartBuilder ( ) . type ( MultipartBuilder . FORM ) . addFormDataPart ( "Content-Disposition" , "form-data; name=\"datafile\"; filename=\"" + file . getName ( ) + "\"" ) . addFormDataPart ( "Content-Type" , contentType ) . addFormDataPart ( "datafile" , file . getName ( ) , fileBody ) . build ( ) ; HttpUrl upLoadUrl = HttpUrl . parse ( getHostName ( ) + "/" + getVivoSiteName ( ) + "/uploadImages" ) . newBuilder ( ) . addQueryParameter ( "entityUri" , image . getIndividualIRI ( ) ) . addQueryParameter ( "action" , "upload" ) . addQueryParameter ( "imageUrl" , image . getImageURL ( ) ) . build ( ) ; Request upLoadRequest = new Request . Builder ( ) . url ( upLoadUrl ) . method ( "POST" , requestBody ) . addHeader ( "Accept" , "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" ) . addHeader ( "Accept-Language" , "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3" ) . addHeader ( "Content-Type" , "image/jpeg" ) . addHeader ( "Origin" , getHostName ( ) ) . addHeader ( "Connection" , "keep-alive" ) . addHeader ( "Referer" , url . toString ( ) ) . addHeader ( "Upgrade-Insecure-Requests" , "1" ) . addHeader ( "Sec-Fetch-Dest" , "document" ) . addHeader ( "Sec-Fetch-Mode" , "navigate" ) . addHeader ( "Sec-Fetch-Site" , "same-origin" ) . addHeader ( "Sec-Fetch-User" , "?1" ) . build ( ) ; Response upLoadResponse = getHttpClient ( ) . newCall ( upLoadRequest ) . execute ( ) ; /*
		 * Save image
		 */ MediaType mediaType = MediaType . parse ( "application/x-www-form-urlencoded" ) ; RequestBody saveBody = RequestBody . create ( mediaType , "x=" + image . getOrigX ( ) + "&y=" + image . getOrigY ( ) + "&w=" + image . getWidth ( ) + "&h=" + image . getHeight ( ) ) ; HttpUrl saveUrl = HttpUrl . parse ( getHostName ( ) + "/" + getVivoSiteName ( ) + "/uploadImages" ) . newBuilder ( ) . addQueryParameter ( "entityUri" , image . getIndividualIRI ( ) ) . addQueryParameter ( "action" , "save" ) . build ( ) ; Request saveRequest = new Request . Builder ( ) . url ( saveUrl ) . method ( "POST" , saveBody ) . addHeader ( "Accept" , "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" ) . addHeader ( "Accept-Language" , "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3" ) . addHeader ( "Content-Type" , "application/x-www-form-urlencoded" ) . addHeader ( "Origin" , getHostName ( ) ) . addHeader ( "Connection" , "keep-alive" ) . addHeader ( "Referer" , upLoadUrl . toString ( ) ) . addHeader ( "Upgrade-Insecure-Requests" , "1" ) . addHeader ( "Sec-Fetch-Dest" , "document" ) . addHeader ( "Sec-Fetch-Mode" , "navigate" ) . addHeader ( "Sec-Fetch-Site" , "same-origin" ) . addHeader ( "Sec-Fetch-User" , "?1" ) . build ( ) ; Response saveResponse = getHttpClient ( ) . newCall ( saveRequest ) . execute ( ) ; return CommandResult . asCommandResult ( saveResponse ) ; }
Upload image associated to an individual
 @param image
 @return
 @throws IOException
Upload image associated to an individual @param image @return @throws IOException