package net.catcert.psa.test.util;

import schema.core._0._1.dss.tc.names.oasis.InternationalStringType;
import schema.core._0._1.dss.tc.names.oasis.ResultDocument.Result;
import net.catcert.psa.services.PsaServices;

import com.sadiel.catcert.psa.ws.client.UtilServiceStub;
import com.sadiel.catcert.psa.ws.client.factory.PSARequestFactory;
import com.sadiel.catcert.psa.ws.util.DeleteSignatureDocument;
import com.sadiel.catcert.psa.ws.util.DeleteSignatureResponseDocument;

import dss_operation.profiles._0._1.psa.catcert.DeleteSignatureRSPNSDocument.DeleteSignatureRSPNS;

/**
 * Invokes DeleteSignedDocument at psa util service
 * @author suport tčcnic CATCert
 *
 */

public class DeleteSignedDocumentAtPSASample {


	public static void main(String[] args){

		try{

			//política de procediment
			String signedDocId = "926db832-7072-4353-b678-73bfee8b08b1";

			//localització (idioma)
			String locale = "ES";

			//petició
			DeleteSignatureDocument request = PSARequestFactory._().createDeleteSignatureDocumentRQST(locale, signedDocId);

			//servei query
			UtilServiceStub utilServiceStub = PsaServices.getInstance().getUtilServiceStub();

			//enviament de la petició
			DeleteSignatureResponseDocument deleteSignatureDoc = utilServiceStub.deleteSignature(request);
			
			DeleteSignatureRSPNS response = deleteSignatureDoc.getDeleteSignatureResponse().getDeleteSignatureRSPNS();

			//resultat de l'operació sol·licitada
			System.out.println("Result:");
			Result result = response.getResult();
			String major = result.getResultMajor();
			String minor = result.getResultMinor();
			InternationalStringType message = result.getResultMessage();
			System.out.println("Major: "+major);
			System.out.println("Minor: "+minor);
			if(message!=null)
				System.out.println("Message: "+message.getStringValue());

		} catch (Throwable e) {
			e.printStackTrace();
		}
	}	

}
