All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nosi.core.webapp.IgrpLog Maven / Gradle / Ivy

Go to download

IGRP Framework is a powerful and highly customizable platform developed by the Operational Nucleus for the Information Society (NOSi) to create web applications, it provides out of box, several modules to make easy to create stand-alone, production-grade web applications: authentication and access-control, business processes automation, reporting, page builder with automatic code generation and incorporation of the Once-Only-Principle, written in Java. IGRP Framework WAR - Contains some keys resources that give UI to IGRP Framework and others supports files.

There is a newer version: 2.0.0.241121-RCM
Show newest version
package nosi.core.webapp;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import jakarta.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;

/**
 * Iekiny Marcel
 * Jan 11, 2018
 */
public final class IgrpLog implements Component { // Not inherited 
	
	private List msgLog; 
	
	public IgrpLog() {}
	
	public IgrpLog addMessage(String msg) {
		this.msgLog.add(msg);
		return this;
	}
	
	public List getMsgLog(){
		return this.msgLog;
	}

	public void run() {
		Set paramNames = Igrp.getInstance().getRequest().getParameterMap().keySet();
		Iterator i = paramNames.iterator();
		
		String qs = Igrp.getInstance().getRequest().getQueryString();
		
		while(i.hasNext()) {
			String key = i.next();
			String values = "";
			
			if(StringUtils.countMatches(qs, key+"=")==1) {
				values = Igrp.getInstance().getRequest().getParameter(key);
			}else {
				String []result = Igrp.getInstance().getRequest().getParameterValues(key); 
				if(result != null && result.length > 1) {
					values += "[";
					for(int j = 0; j < result.length; j++) {
						values += result[j];
						if(j < result.length - 1)
							values += ", ";
					}		
					values += "]";
				}else 
					values = Igrp.getInstance().getRequest().getParameter(key);
			}	
				this.msgLog.add(key + " = " + values + " ");
		}
	}

	@Override
	public void destroy() {}

	@Override
	public void init(HttpServletRequest request) {
		this.msgLog = new ArrayList<>();
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy