![JAR search and dependency download from the Maven repository](/logo.png)
org.semanticwb.portal.resources.Banner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SWBPortal Show documentation
Show all versions of SWBPortal Show documentation
SemanticWebBuilder Portal API components and utilities
The newest version!
/*
* SemanticWebBuilder es una plataforma para el desarrollo de portales y aplicaciones de integración,
* colaboración y conocimiento, que gracias al uso de tecnología semántica puede generar contextos de
* información alrededor de algún tema de interés o bien integrar información y aplicaciones de diferentes
* fuentes, donde a la información se le asigna un significado, de forma que pueda ser interpretada y
* procesada por personas y/o sistemas, es una creación original del Fondo de Información y Documentación
* para la Industria INFOTEC, cuyo registro se encuentra actualmente en trámite.
*
* INFOTEC pone a su disposición la herramienta SemanticWebBuilder a través de su licenciamiento abierto al público (‘open source’),
* en virtud del cual, usted podrá usarlo en las mismas condiciones con que INFOTEC lo ha diseñado y puesto a su disposición;
* aprender de él; distribuirlo a terceros; acceder a su código fuente y modificarlo, y combinarlo o enlazarlo con otro software,
* todo ello de conformidad con los términos y condiciones de la LICENCIA ABIERTA AL PÚBLICO que otorga INFOTEC para la utilización
* del SemanticWebBuilder 4.0.
*
* INFOTEC no otorga garantía sobre SemanticWebBuilder, de ninguna especie y naturaleza, ni implícita ni explícita,
* siendo usted completamente responsable de la utilización que le dé y asumiendo la totalidad de los riesgos que puedan derivar
* de la misma.
*
* Si usted tiene cualquier duda o comentario sobre SemanticWebBuilder, INFOTEC pone a su disposición la siguiente
* dirección electrónica:
* http://www.semanticwebbuilder.org
*/
package org.semanticwb.portal.resources;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.semanticwb.Logger;
import org.semanticwb.SWBPlatform;
import org.semanticwb.SWBPortal;
import org.semanticwb.SWBUtils;
import org.semanticwb.model.Resource;
import org.semanticwb.model.User;
import org.semanticwb.model.WebPage;
import org.semanticwb.portal.api.SWBParamRequest;
import org.semanticwb.portal.api.GenericAdmResource;
import org.semanticwb.portal.api.SWBActionResponse;
import org.semanticwb.portal.api.SWBResourceException;
// TODO: Auto-generated Javadoc
/**
* Banner se encarga de desplegar y administrar un banner bajo ciertos
* criterios(configuración de recurso).
*
* Banner is in charge to unfold and to administer a banner under certain
* criteria (resource configuration).
*
* @author : Jorge Alberto Jiménez
* @version 1.0
*/
public class Banner extends GenericAdmResource {
/** The log. */
private static Logger log = SWBUtils.getLogger(Banner.class);
/* (non-Javadoc)
* @see org.semanticwb.portal.api.GenericAdmResource#doView(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.semanticwb.portal.api.SWBParamRequest)
*/
@Override
public void doView(HttpServletRequest request, HttpServletResponse response, SWBParamRequest paramRequest) throws SWBResourceException, IOException {
Resource base = getResourceBase();
PrintWriter out = response.getWriter();
String lang=paramRequest.getUser().getLanguage();
try {
// String local = base.getAttribute("local", "0");
String code =base.getAttribute("code");
// if( local.equals("0")||code==null ) {
if(code==null) {
String img = base.getAttribute("img","");
String longdesc = base.getAttribute("longdesc");
String url = base.getAttribute("url");
String width = paramRequest.getArgument("width", base.getAttribute("width"));
try {
Integer.parseInt( width.replaceAll("\\D", "") );
}catch(Exception e) {
width = null;
}
String height = paramRequest.getArgument("height", base.getAttribute("height"));
try {
Integer.parseInt( height.replaceAll("\\D", "") );
}catch(Exception e) {
height = null;
}
//Para envío de parametros que traiga la página actual(07/09/2011)
String QueryStream="";
if(request.getQueryString()!=null) QueryStream="?"+SWBUtils.TEXT.encodeURLChars4CSS(request.getQueryString());
String wburl = null;
if( url!=null && url.toLowerCase().startsWith("mailto:") )
wburl = url.replaceAll("\"", """);
else if(url!=null)
wburl = paramRequest.getActionUrl().toString();
if( img.endsWith(".swf") ) {
out.print("");
}else {
if( url!=null ) {
out.print("");
out.println(" title=\""+base.getDisplayTitle(paramRequest.getUser().getLanguage())+"\">");
}
out.print("
");
if( url!=null )
out.print("");
}
if( longdesc!=null )
out.println(""+paramRequest.getLocaleString("longDesc")+"");
}else {
String img = base.getAttribute("img","");
//publicidad externa
code=SWBUtils.TEXT.replaceAll(code, "{title}", getResourceBase().getDisplayTitle(lang));
code=SWBUtils.TEXT.replaceAll(code, "{description}", getResourceBase().getDisplayDescription(lang));
code=SWBUtils.TEXT.replaceAll(code, "{image}", SWBPortal.getWebWorkPath()+base.getWorkPath()+"/"+img);
out.println(code);
}
}catch (Exception e) {
log.error("Error in resource Banner while bringing HTML", e);
}
out.flush();
out.close();
}
/* (non-Javadoc)
* @see org.semanticwb.portal.api.GenericResource#doHelp(HttpServletRequest, HttpServletResponse, SWBParamRequest)
*/
@Override
public void doHelp(HttpServletRequest request, HttpServletResponse response, SWBParamRequest paramRequest) throws SWBResourceException, IOException {
Resource base = getResourceBase();
PrintWriter out = response.getWriter();
out.println(" ");
out.flush();
out.close();
}
/**
* Replace tags.
*
* @param str the str
* @param request the request
* @param user the user
* @param webpage the webpage
* @return the string
*/
public String replaceTags(String str, HttpServletRequest request, User user,WebPage webpage) {
if(str==null || str.trim().length()==0)
return null;
str=str.trim();
Iterator it=SWBUtils.TEXT.findInterStr(str, "{request.getParameter(\"", "\")}");
while(it.hasNext())
{
String s=(String)it.next();
str=SWBUtils.TEXT.replaceAll(str, "{request.getParameter(\""+s+"\")}", request.getParameter(replaceTags(s,request,user,webpage)));
}
it=SWBUtils.TEXT.findInterStr(str, "{session.getAttribute(\"", "\")}");
while(it.hasNext())
{
String s=(String)it.next();
str=SWBUtils.TEXT.replaceAll(str, "{session.getAttribute(\""+s+"\")}", (String)request.getSession().getAttribute(replaceTags(s,request,user,webpage)));
}
/*it=SWBUtils.TEXT.findInterStr(str, "{template.getArgument(\"", "\")}");
while(it.hasNext())
{
String s=(String)it.next();
str=SWBUtils.TEXT.replaceAll(str, "{template.getArgument(\""+s+"\")}", (String)response.getArgument(replaceTags(s,request,user,webpage)));
}*/
it=SWBUtils.TEXT.findInterStr(str, "{getEnv(\"", "\")}");
while(it.hasNext())
{
String s=(String)it.next();
str=SWBUtils.TEXT.replaceAll(str, "{getEnv(\""+s+"\")}", SWBPlatform.getEnv(replaceTags(s,request,user,webpage)));
}
str=SWBUtils.TEXT.replaceAll(str, "{user.login}", user.getLogin());
str=SWBUtils.TEXT.replaceAll(str, "{user.email}", user.getEmail());
str=SWBUtils.TEXT.replaceAll(str, "{user.language}", user.getLanguage());
str=SWBUtils.TEXT.replaceAll(str, "{webpath}", SWBPortal.getContextPath());
str=SWBUtils.TEXT.replaceAll(str, "{distpath}", SWBPortal.getDistributorPath());
str=SWBUtils.TEXT.replaceAll(str, "{webworkpath}", SWBPortal.getWebWorkPath());
str=SWBUtils.TEXT.replaceAll(str, "{workpath}", SWBPortal.getWorkPath());
str=SWBUtils.TEXT.replaceAll(str, "{websiteid}", webpage.getWebSiteId());
return str;
}
/**
* Metodo para hacer operaciones.
*
* @param request the request
* @param response the response
* @throws SWBResourceException the sWB resource exception
* @throws IOException Signals that an I/O exception has occurred.
*/
@Override
public void processAction(javax.servlet.http.HttpServletRequest request, SWBActionResponse response) throws SWBResourceException, IOException {
Resource base=getResourceBase();
base.addHit(request, response.getUser(), response.getWebPage());
String url = base.getAttribute("url");
if( url!=null ) {
url = replaceTags(url, request, response.getUser(), response.getWebPage());
response.sendRedirect(url);
}else
{
//Para paso de parametros
String params="";
int cont=0;
Enumeration enParams=request.getParameterNames();
while(enParams.hasMoreElements()){
String param=enParams.nextElement();
cont++;
if(cont==1) params+="?"; else params+="&";
params+=param+"="+request.getParameter(param);
}
response.sendRedirect(response.getWebPage().getUrl()+params);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy