Index: MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/CompRegistryProxyAction.java
===================================================================
--- MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/CompRegistryProxyAction.java	(revision 1531)
+++ MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/CompRegistryProxyAction.java	(revision 1532)
@@ -112,86 +112,90 @@
 	@SuppressWarnings("deprecation")	
 	@Override
-	public void prepare() throws Exception {		
-		
-		//Admin.notifyUser("CRPA.prepare");
-		if (!getActionkey().equals("elements"))	{
-			super.prepare();
-		} else	{
-//			Admin.notifyUser("CRPA.prepareSourceStream - elements");
-			String xcid;
-			InputStream _sourceStream;
-			InputStream __sourceStream;
-			InputStream _resultStream;
-			
-			_sourceStream = Cache.getCache().getFromCache(getRequestKey());
-			if (_sourceStream == null) {
-	//				Admin.notifyUser("CRPA.prepareSourceStream- profiles");
-					//setActionkey("profiles");
-					//setFormat("xmlresolved");
-					__sourceStream = Cache.getCache().getFromCache(getRequestKey());
-					if (__sourceStream == null) {
-						__sourceStream = getSourceStream();
-						xcid = Cache.getCache().putInCache(getRequestKey(),__sourceStream);			
-						//Admin.notifyUser("CRPA-putting in cache: " + getRequestKey());	
+	public void prepare()  {		
+		
+		try {
+		
+			//Admin.notifyUser("CRPA.prepare");
+			if (!getActionkey().equals("elements"))	{
+				super.prepare();
+			} else	{
+//				Admin.notifyUser("CRPA.prepareSourceStream - elements");
+				String xcid;
+				InputStream _sourceStream;
+				InputStream __sourceStream;
+				InputStream _resultStream;
+				
+				_sourceStream = Cache.getCache().getFromCache(getRequestKey());
+				if (_sourceStream == null) {
+		//				Admin.notifyUser("CRPA.prepareSourceStream- profiles");
+						//setActionkey("profiles");
+						//setFormat("xmlresolved");
 						__sourceStream = Cache.getCache().getFromCache(getRequestKey());
-					} else{
-						//Admin.notifyUser("CRPA-reading from cache: " + getRequestKey());	
-					}
-			//		Admin.notifyUser("CCCRPA." + getTargetRequest());
-				//	Admin.notifyUser("CCCRPA." + getFullFormat());
+						if (__sourceStream == null) {
+							__sourceStream = getSourceStream();
+							xcid = Cache.getCache().putInCache(getRequestKey(),__sourceStream);			
+							//Admin.notifyUser("CRPA-putting in cache: " + getRequestKey());	
+							__sourceStream = Cache.getCache().getFromCache(getRequestKey());
+						} else{
+							//Admin.notifyUser("CRPA-reading from cache: " + getRequestKey());	
+						}
+				//		Admin.notifyUser("CCCRPA." + getTargetRequest());
+					//	Admin.notifyUser("CCCRPA." + getFullFormat());
+						MDTransformer transformer = new MDTransformer();
+						transformer.setSrcFile(getTargetRequest());
+						//transformer.setParams(createTransformerParams());
+						_sourceStream = transformer.transformXML(__sourceStream);//, getFullFormat(),null,null,null,null,null,null);
+					//	Admin.notifyUser("CRPA.- elements");
+						//setActionkey("elements");
+						//setFormat("htmllist");
+						xcid = Cache.getCache().putInCache(getRequestKey(),_sourceStream);			
+				//		Admin.notifyUser("CRPA-putting in cache: " + getRequestKey());
+						_sourceStream = Cache.getCache().getFromCache(getRequestKey());
+				} /*else {
+						Admin.notifyUser("CRPA-reading from cache: " + getRequestKey());
+				}*/
+					/*
+				File file=new File(Cache.getCache().formPath(getRequestKey()));
+				Admin.notifyUser("File-absolutePath " + file.getAbsolutePath());
+				URL url = null;
+				   try{
+					   url = file.toURL();
+					   Admin.notifyUser("URL-tostring " + url.toString());
+					   }  catch (MalformedURLException me){
+				  }
+				 */
+				
+				if (getFormat().equals("xml")) {			
+					_resultStream = _sourceStream;	
+				}else {
+					// set URL as srcFile (for MDTransformer to pass to xsl-scripts) 
 					MDTransformer transformer = new MDTransformer();
 					transformer.setSrcFile(getTargetRequest());
-					//transformer.setParams(createTransformerParams());
-					_sourceStream = transformer.transformXML(__sourceStream);//, getFullFormat(),null,null,null,null,null,null);
-				//	Admin.notifyUser("CRPA.- elements");
-					//setActionkey("elements");
-					//setFormat("htmllist");
-					xcid = Cache.getCache().putInCache(getRequestKey(),_sourceStream);			
-			//		Admin.notifyUser("CRPA-putting in cache: " + getRequestKey());
-					_sourceStream = Cache.getCache().getFromCache(getRequestKey());
-			} /*else {
-					Admin.notifyUser("CRPA-reading from cache: " + getRequestKey());
-			}*/
+					//transformer.setParams(MDTransformer.createParamsMap(getFullFormat()));
+					_resultStream = transformer.transformXML(_sourceStream);//, getFullFormat());
+						
+				}
+		
+				Admin.notifyUser(getProxyKey() + " success:" + (_resultStream!=null));
+				
+				setSourceStream(_sourceStream);
+				setResultStream(_resultStream);
+
 				/*
-			File file=new File(Cache.getCache().formPath(getRequestKey()));
-			Admin.notifyUser("File-absolutePath " + file.getAbsolutePath());
-			URL url = null;
-			   try{
-				   url = file.toURL();
-				   Admin.notifyUser("URL-tostring " + url.toString());
-				   }  catch (MalformedURLException me){
-			  }
-			 */
+				if (getFormat().equals("txt")) {
+					File f=new File(Cache.getCache().formPath("terms_autocomplete.txt"));
+				    OutputStream out=new FileOutputStream(f);
+				    byte buf[]=new byte[1024];
+				    int len;
+				    while((len=getResultStream().read(buf))>0)
+				    	out.write(buf,0,len);
+				    out.close();
+	Admin.notifyUser("terms_autocomplete.txt");
+				}
+				*/
+			}
+		} catch(Exception e){
 			
-			if (getFormat().equals("xml")) {			
-				_resultStream = _sourceStream;	
-			}else {
-				// set URL as srcFile (for MDTransformer to pass to xsl-scripts) 
-				MDTransformer transformer = new MDTransformer();
-				transformer.setSrcFile(getTargetRequest());
-				//transformer.setParams(MDTransformer.createParamsMap(getFullFormat()));
-				_resultStream = transformer.transformXML(_sourceStream);//, getFullFormat());
-					
-			}
-	
-			Admin.notifyUser(getProxyKey() + " success:" + (_resultStream!=null));
-			
-			setSourceStream(_sourceStream);
-			setResultStream(_resultStream);
-
-			/*
-			if (getFormat().equals("txt")) {
-				File f=new File(Cache.getCache().formPath("terms_autocomplete.txt"));
-			    OutputStream out=new FileOutputStream(f);
-			    byte buf[]=new byte[1024];
-			    int len;
-			    while((len=getResultStream().read(buf))>0)
-			    	out.write(buf,0,len);
-			    out.close();
-Admin.notifyUser("terms_autocomplete.txt");
-			}
-			*/
-			
-		}
+		}			
 
 	}
Index: MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericAction.java
===================================================================
--- MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericAction.java	(revision 1531)
+++ MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericAction.java	(revision 1532)
@@ -499,81 +499,87 @@
 	 */
 	
-	public void prepare() throws Exception {
+	public void prepare()  {
 			
-		loadParams();
-		setTargetProxy();
-		getTargetProxy().checkParams();
-		
-		String req_key = getRequestKey();
-		log.debug("request_key: " +  req_key); 
-		log.debug("params.size: " +  params.size());
-		log.debug(getActionkey() + ".targetURL: " + getTargetProxy().getTargetRequest() + " .format:" + getFullFormat());
-		
-		// Caching
-		String xcid;
-	
-		if (getCache().equals(Cache.SKIP)) {
+		try{
+			loadParams();
+			setTargetProxy();
+			getTargetProxy().checkParams();
 			
-			sourceStream = getSourceStream();
+			String req_key = getRequestKey();
+			log.debug("request_key: " +  req_key); 
+			log.debug("params.size: " +  params.size());
+			log.debug(getActionkey() + ".targetURL: " + getTargetProxy().getTargetRequest() + " .format:" + getFullFormat());
 			
-		} else { 
-			if (getCache().equals(Cache.USE)) {
+			// Caching
+			String xcid;
+		
+			if (getCache().equals(Cache.SKIP)) {
+				
+				sourceStream = getSourceStream();
+				
+			} else { 
+				if (getCache().equals(Cache.USE)) {
+						sourceStream = Cache.getCache().getFromCache(req_key);
+				}
+				if (sourceStream == null) { // either not in cache or cache_flag=refresh
+					//sourceStream = getTargetRequest().openStream();
+					long startMillis = System.currentTimeMillis();
+					sourceStream = getSourceStream();
+					duration = System.currentTimeMillis() - startMillis;
+					req_key = addDurationKey();
+					
+					long now = System.currentTimeMillis();
+					xcid = Cache.getCache().putInCache(req_key,sourceStream);			
+					//Admin.notifyUser("putting in cache: " + req_key);			
 					sourceStream = Cache.getCache().getFromCache(req_key);
-			}
-			if (sourceStream == null) { // either not in cache or cache_flag=refresh
-				//sourceStream = getTargetRequest().openStream();
-				long startMillis = System.currentTimeMillis();
-				sourceStream = getSourceStream();
-				duration = System.currentTimeMillis() - startMillis;
-				req_key = addDurationKey();
+				} /* else {
+					Admin.notifyUser("reading from cache: " + req_key);
+				} */
+			}
+			
+			// add diagnostics non fatal
+			if (getDiagnostics().Exists()){
+				Document doc ;
+				Node r_element;
+				// fatal error 
+				//TODO getDiagnostics().Exists("fatal");
+				if (sourceStream == null){
+					//TODO rootelemname ???
+					doc = Helpers.createDocument("rootelemname");
+					r_element = doc.getFirstChild();
+				} else {
+					doc = Helpers.getDocument(sourceStream);
+					//TODO tagname by class
+					r_element=  doc.getElementsByTagName("searchRetrieveResponse").item(0);
+				}
 				
-				long now = System.currentTimeMillis();
-				xcid = Cache.getCache().putInCache(req_key,sourceStream);			
-				//Admin.notifyUser("putting in cache: " + req_key);			
-				sourceStream = Cache.getCache().getFromCache(req_key);
-			} /* else {
-				Admin.notifyUser("reading from cache: " + req_key);
-			} */
-		}
-		
-		// add diagnostics
-		if (getDiagnostics().Exists()){
-			Document doc ;
-			Node r_element;
-			// fatal error 
-			//TODO getDiagnostics().Exists("fatal");
-			if (sourceStream == null){
-				//TODO rootelemname ???
-				doc = Helpers.createDocument("rootelemname");
-				r_element = doc.getFirstChild();
-			} else {
-				doc = Helpers.getDocument(sourceStream);
-				//TODO tagname by class
-				r_element=  doc.getElementsByTagName("searchRetrieveResponse").item(0);
+				Document ddoc = getDiagnostics().buildXMLDocument();
+				Node d_element=  ddoc.getElementsByTagName("diagnostics").item(0);
+				doc.adoptNode(d_element);
+				r_element.appendChild(d_element);
+				DOMSource source = new DOMSource(doc);   
+				StringWriter xmlAsWriter = new StringWriter();   
+				StreamResult result = new StreamResult(xmlAsWriter);    
+				TransformerFactory.newInstance().newTransformer().transform(source, result);
+				this.setSourceStream(new ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")));
 			}
 			
-			Document ddoc = getDiagnostics().buildXMLDocument();
-			Node d_element=  ddoc.getElementsByTagName("diagnostics").item(0);
-			doc.adoptNode(d_element);
-			r_element.appendChild(d_element);
-			DOMSource source = new DOMSource(doc);   
-			StringWriter xmlAsWriter = new StringWriter();   
-			StreamResult result = new StreamResult(xmlAsWriter);    
-			TransformerFactory.newInstance().newTransformer().transform(source, result);
-			this.setSourceStream(new ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")));
-		}
-		
-		log.debug("format: " + getFormat() );
-		if (getFormat().equals("xml")) {			
-			resultStream = sourceStream;	
-		}else {
-			MDTransformer transformer = new MDTransformer();
-			// set URL as srcFile (for MDTransformer to pass to xsl-scripts)
-			// TODO: WHY??
-			transformer.setSrcFile(getTargetProxy().getTargetRequest());
-			//transformer.setParams(createTransformerParams());
-			transformer.setParams(getParams());
-			// here the transformation is invoked
-			resultStream = transformer.transformXML(sourceStream);
+			log.debug("format: " + getFormat() );
+			if (getFormat().equals("xml")) {			
+				resultStream = sourceStream;	
+			}else {
+				MDTransformer transformer = new MDTransformer();
+				// set URL as srcFile (for MDTransformer to pass to xsl-scripts)
+				// TODO: WHY??
+				transformer.setSrcFile(getTargetProxy().getTargetRequest());
+				//transformer.setParams(createTransformerParams());
+				transformer.setParams(getParams());
+				// here the transformation is invoked
+				resultStream = transformer.transformXML(sourceStream);
+			}
+
+		}catch (Exception e){
+			//TODO add exception to diagnostic ?
+			return;
 		}
 		
@@ -597,4 +603,23 @@
 
 		if (resultStream == null) {
+			if (getDiagnostics().Exists()){
+				Document doc ;
+				Node r_element;
+				// fatal error 
+				//TODO getDiagnostics().Exists("fatal");
+				doc = Helpers.createDocument("Error");
+				r_element = doc.getFirstChild();
+				
+				Document ddoc = getDiagnostics().buildXMLDocument();
+				Node d_element=  ddoc.getElementsByTagName("diagnostics").item(0);
+				doc.adoptNode(d_element);
+				r_element.appendChild(d_element);
+				DOMSource source = new DOMSource(doc);   
+				StringWriter xmlAsWriter = new StringWriter();   
+				StreamResult result = new StreamResult(xmlAsWriter);    
+				TransformerFactory.newInstance().newTransformer().transform(source, result);
+				this.setResultStream(new ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")));
+
+			}
 			return ERROR;	
 		} else {
Index: MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java
===================================================================
--- MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java	(revision 1531)
+++ MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java	(revision 1532)
@@ -449,52 +449,57 @@
 	 */
 	
-	public void prepare() throws Exception {		
-		
-		String req_key = getRequestKey();
-		Admin.notifyUser("request_key: " +  req_key); 
-		Admin.notifyUser(getProxyKey() + ".targetURL: " + getTargetRequest() + " .format:" + getFullFormat());
-		
-		// Caching
-		String xcid;
-	
-		// Admin.notifyUser("GPA.prepareSourceStream");
-		
-		if (getCache().equals(Cache.SKIP)) {
+	public void prepare() {		
+		
+		try{
+			String req_key = getRequestKey();
+			Admin.notifyUser("request_key: " +  req_key); 
+			Admin.notifyUser(getProxyKey() + ".targetURL: " + getTargetRequest() + " .format:" + getFullFormat());
 			
-			sourceStream = getSourceStream();
+			// Caching
+			String xcid;
+		
+			// Admin.notifyUser("GPA.prepareSourceStream");
 			
-		} else { 
-			if (getCache().equals(Cache.USE)) {
+			if (getCache().equals(Cache.SKIP)) {
+				
+				sourceStream = getSourceStream();
+				
+			} else { 
+				if (getCache().equals(Cache.USE)) {
+						sourceStream = Cache.getCache().getFromCache(req_key);
+				}
+				if (sourceStream == null) { // either not in cache or cache_flag=refresh
+					//sourceStream = getTargetRequest().openStream();
+					long startMillis = System.currentTimeMillis();
+					sourceStream = getSourceStream();
+					duration = System.currentTimeMillis() - startMillis;
+					req_key = addDurationKey();
+					
+					long now = System.currentTimeMillis();
+					xcid = Cache.getCache().putInCache(req_key,sourceStream);			
+					//Admin.notifyUser("putting in cache: " + req_key);			
 					sourceStream = Cache.getCache().getFromCache(req_key);
-			}
-			if (sourceStream == null) { // either not in cache or cache_flag=refresh
-				//sourceStream = getTargetRequest().openStream();
-				long startMillis = System.currentTimeMillis();
-				sourceStream = getSourceStream();
-				duration = System.currentTimeMillis() - startMillis;
-				req_key = addDurationKey();
+				} /* else {
+					Admin.notifyUser("reading from cache: " + req_key);
+				} */
+			}
 				
-				long now = System.currentTimeMillis();
-				xcid = Cache.getCache().putInCache(req_key,sourceStream);			
-				//Admin.notifyUser("putting in cache: " + req_key);			
-				sourceStream = Cache.getCache().getFromCache(req_key);
-			} /* else {
-				Admin.notifyUser("reading from cache: " + req_key);
-			} */
-		}
+			if (format.equals("xml")) {			
+				resultStream = sourceStream;	
+			}else {
+				MDTransformer transformer = new MDTransformer();
+				// set URL as srcFile (for MDTransformer to pass to xsl-scripts)
+				// TODO: WHY??
+				transformer.setSrcFile(getTargetRequest());
+				//transformer.setParams(createTransformerParams());
+				// here the transformation is invoked
+				resultStream = transformer.transformXML(sourceStream);
+			}
+				
+			log.debug(getProxyKey() + " success:" + (resultStream!=null));
+	
+		} catch (Exception e){
 			
-		if (format.equals("xml")) {			
-			resultStream = sourceStream;	
-		}else {
-			MDTransformer transformer = new MDTransformer();
-			// set URL as srcFile (for MDTransformer to pass to xsl-scripts)
-			// TODO: WHY??
-			transformer.setSrcFile(getTargetRequest());
-			//transformer.setParams(createTransformerParams());
-			// here the transformation is invoked
-			resultStream = transformer.transformXML(sourceStream);
-		}
-			
-		log.debug(getProxyKey() + " success:" + (resultStream!=null));
+		}
 	}
 
Index: MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/RepoAction.java
===================================================================
--- MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/RepoAction.java	(revision 1531)
+++ MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/RepoAction.java	(revision 1532)
@@ -91,6 +91,13 @@
 		public void setTargetProxy(){
 						
-			//if (getRepository()==null) setRepository("clarin.at-mirror");
+			if (getRepository()==null) {
+				getDiagnostics().Add(Diagnostic.MANDATORY_NOTSUPPLIED, "repository", "");
+				return;
+			}
 			
+			if (!WorkspaceProfile.repositoryExists(getRepository())){
+				getDiagnostics().Add(Diagnostic.UNSUPPORTED_PARAMETERVALUE, "repository", "repository=" + getRepository() );
+				return;
+			}
 			switch (WorkspaceProfile.RepositoryType.toRepositoryType(WorkspaceProfile.getRepositoryType(getRepository())))
 			{		
@@ -105,5 +112,6 @@
 			    	return;
 			    default:
-			    	getDiagnostics().Add(Diagnostic.MANDATORY_NOTSUPPLIED, "repository", "repository=" + getRepository() );
+			    	//TODO error  = bad workspaceProfile configuration
+			    	getDiagnostics().Add(Diagnostic.SYSTEM_ERROR, "error in workspaceprofile configuration", "repository=" + getRepository() );
 			}
 			
Index: MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/WorkspaceAction.java
===================================================================
--- MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/WorkspaceAction.java	(revision 1531)
+++ MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/WorkspaceAction.java	(revision 1532)
@@ -956,8 +956,9 @@
 	
 	@Override
-	public void prepare() throws Exception {		
-		
-		loadParams();
-		
+	public void prepare()  {		
+		
+		try{
+			loadParams();
+			
 	        NodeList list = (NodeList) getWorkspaceData();//result;
 	        if (list.getLength() < 1) {
@@ -985,4 +986,8 @@
 			
 		log.debug(getProxyKey() + " success:" + (getResultStream()!=null));
+
+		} catch (Exception e){
+			
+		}
 	}
 
Index: MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/model/WorkspaceProfile.java
===================================================================
--- MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/model/WorkspaceProfile.java	(revision 1531)
+++ MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/model/WorkspaceProfile.java	(revision 1532)
@@ -178,4 +178,18 @@
 	}
 	
+	public static Boolean repositoryExists(String repository_name){
+			
+			// static repositories
+			net.sf.json.JSONArray json = WorkspaceProfile.getRepositories(); 
+			for(int i=0;i<json.size();i++){
+				if (json.getJSONObject(i).getString("name").equals(repository_name)){
+					return true;
+				}
+			}
+			
+			return false;
+
+		}
+	
 	public static String getRepositoryPath(String repository_name){
 		String repository_path = null;
Index: MDService2/branches/MDService_simple3/src/struts.xml
===================================================================
--- MDService2/branches/MDService_simple3/src/struts.xml	(revision 1531)
+++ MDService2/branches/MDService_simple3/src/struts.xml	(revision 1532)
@@ -21,5 +21,8 @@
 			      <param name="location">/Error.jsp</param>			    
 			    </result> -->
-			    <result name="error">/Error.jsp</result>
+			    <result name="error" type="stream">
+			    	<param name="contentType">text/xml</param>
+			        <param name="inputName">resultStream</param>
+			    </result>
 			    <!-- <result name="error" type="redirectAction"></result>
 			     --> 
