@ -7,7 +7,6 @@ import static de.srsoftware.document.mustang.Constants.KEY_PDF;
				@@ -7,7 +7,6 @@ import static de.srsoftware.document.mustang.Constants.KEY_PDF;
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import static  de.srsoftware.document.mustang.Constants.KEY_PRODUCER ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import static  de.srsoftware.document.mustang.Constants.KEY_TEMPLATE ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import static  de.srsoftware.document.zugferd.data.UnitCode.* ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import static  de.srsoftware.tools.MimeType.MIME_FORM_URL ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import static  de.srsoftware.tools.MimeType.MIME_PDF ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import static  de.srsoftware.tools.Optionals.isSet ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import static  de.srsoftware.tools.Strings.escapeHtmlEntities ;  
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -26,7 +25,6 @@ import static de.srsoftware.umbrella.core.ModuleRegistry.*;
				@@ -26,7 +25,6 @@ import static de.srsoftware.umbrella.core.ModuleRegistry.*;
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import static  de.srsoftware.umbrella.core.Paths.* ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import static  de.srsoftware.umbrella.core.ResponseCode.HTTP_UNPROCESSABLE ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import static  de.srsoftware.umbrella.core.Util.mapValues ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import static  de.srsoftware.umbrella.core.Util.request ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import static  de.srsoftware.umbrella.core.exceptions.UmbrellaException.* ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import static  de.srsoftware.umbrella.core.model.Document.State.NEW ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import static  de.srsoftware.umbrella.core.model.Document.State.SENT ;  
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -67,7 +65,6 @@ import java.util.*;
				@@ -67,7 +65,6 @@ import java.util.*;
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import  java.util.function.Function ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import  java.util.function.Predicate ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import  java.util.stream.Stream ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import  org.json.JSONArray ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import  org.json.JSONObject ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					public  class  DocumentApi  extends  BaseHandler  implements  DocumentService  {  
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -141,7 +138,6 @@ public class DocumentApi extends BaseHandler implements DocumentService {
				@@ -141,7 +138,6 @@ public class DocumentApi extends BaseHandler implements DocumentService {
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
								if  ( user . isEmpty ( ) )  return  unauthorized ( ex ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
								var  head  =  path . pop ( ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
								return  switch  ( head ) {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
									case  CONTACTS   - >  getContacts ( ex , user . get ( ) , token . orElse ( null ) ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
									case  PATH_TYPES  - >  getDocTypes ( ex ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
									case  STATES  - >  getDocStates ( ex ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
									case  null  - >  super . doGet ( path , ex ) ;   
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -207,10 +203,6 @@ public class DocumentApi extends BaseHandler implements DocumentService {
				@@ -207,10 +203,6 @@ public class DocumentApi extends BaseHandler implements DocumentService {
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
							}   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
						}   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
						private  boolean  getContacts ( HttpExchange  ex ,  UmbrellaUser  user ,  Token  token )  throws  IOException ,  UmbrellaException  {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
							return  sendContent ( ex , getLegacyContacts ( ex , user , token ) ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
						}   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
						private  boolean  getDocStates ( HttpExchange  ex )  throws  IOException  {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
							var  map  =  Stream . of ( Document . State . values ( ) ) . collect ( toMap ( Document . State : : code ,  Document . State : : name ) ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
							return  sendContent ( ex , map ) ;   
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -376,13 +368,6 @@ public class DocumentApi extends BaseHandler implements DocumentService {
				@@ -376,13 +368,6 @@ public class DocumentApi extends BaseHandler implements DocumentService {
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
							return  sendContent ( ex , content . bytes ( ) ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
						}   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
						private  JSONArray  getLegacyContacts ( HttpExchange  ex ,  UmbrellaUser  umbrellaUser ,  Token  token )  throws  IOException ,  UmbrellaException  {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
							var  location  =  config . get ( "umbrella.modules.contact.baseUrl" ) . map ( s  - >  s + "/json" ) . orElseThrow ( ( )  - >  new  UmbrellaException ( 500 , "umbrella.modules.contact.baseUrl not configured!" ) ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
							var  resp      =  request ( location ,  token . asMap ( ) , MIME_FORM_URL , null ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
							if  ( ! ( resp  instanceof  String  s  & &  s . startsWith ( "[" ) ) )  throw  new  UmbrellaException ( 500 , "{0} did not return JSON Array!" , location ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
							return  new  JSONArray ( s ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
						}   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
						public  Map < Long ,  Document >  list ( long  companyId )  throws  UmbrellaException {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
							return  db . listDocs ( companyId ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
						}