com.frameworkset.platform.portal.PortalIssueManagerImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pdp-system Show documentation
Show all versions of pdp-system Show documentation
bboss public development platform base on bboss.
package com.frameworkset.platform.portal;
import java.io.File;
import javax.servlet.http.HttpServletRequest;
import com.frameworkset.util.FileUtil;
/**
* 类说明:
* Copyright: Copyright (c) 2009
* Company: bbossgroups
* @author gao.tang
* @version V1.0 创建时间:Oct 19, 2009 4:42:55 PM
*/
public class PortalIssueManagerImpl implements PortalIssueManager {
public boolean appIssueIframePlugin(int portletCount,
HttpServletRequest request) throws PortalIssueException {
return issueIframePlugin(portletCount,request,true);
}
public boolean definedIssueIframePlugin(int portletCount,
HttpServletRequest request) throws PortalIssueException {
// TODO Auto-generated method stub
return issueIframePlugin(portletCount,request,false);
}
/**
* 检查文件是否存在
* @param portletName
* @return
*/
private boolean checkPortletName(String portletName){
File t_file = new File(PortalProperties.PORTAL_ISSUEPATH_WAR+"/"+portletName+".war");
if (t_file.exists()){
return true;
}
return false;
}
/**
* 将配置好的iframe portlet发布成portal模板插件war包
* @param portletCount 发布的portlet数
* @param request
* @param state 是否是应用模块发布:
* true为应用模块配置发布,false为自定义配置发布
* @return
*/
private boolean issueIframePlugin(int moduleCount,
HttpServletRequest request, boolean state) throws PortalIssueException {
String portletIframeName = request.getParameter("portletIframeName");
if(portletIframeName == null || "".equals(portletIframeName)){
throw new PortalIssueException("portlet war包名称 不能为空!");
}
if(checkPortletName(portletIframeName)){
throw new PortalIssueException("已经存在名为["+portletIframeName+"] war包名称!");
}
// WEB-INF/liferay-display.xml文件配置
StringBuffer liferay_display = new StringBuffer()
.append("\n")
.append("\n")
.append("\n")
.append("\t\n");
// WEB-INF/liferay-portlet.xml文件配置
StringBuffer liferay_portlet = new StringBuffer()
.append("\n")
.append("\n")
.append("\n");
// WEB-INF/portlet.xml文件配置
StringBuffer portlet = new StringBuffer()
.append("\n")
.append("\n");
String portalId = null;
String portalName = null;
String subsystemid = null;
String appModuleSrc = null;
String httpcontext = null;
String issueArea = null;
//add by jianfeng 20100118
String MAXsrc = null;
//add end
for(int i = 0; i < moduleCount; i++){
portalId = request.getParameter("portalId"+i);
portalName = request.getParameter("portalName"+i);
portalName = PortalUtil.getBytes(portalName);
subsystemid = request.getParameter("subsystemid"+i);
appModuleSrc = request.getParameter("appModuleSrc"+i);
httpcontext = request.getParameter("httpcontext"+i);
issueArea = request.getParameter("issueArea"+i);
//add by jianfeng 20100118
MAXsrc = request.getParameter("MAXsrc"+i);;
//add end
liferay_display.append("\t\t \n");
liferay_portlet.append("\t\n")
.append("\t\t").append(portalId).append(" \n")
.append("\t\t/icon.png \n")
.append("\t\tcom.liferay.plugin.action.ConfigurationActionImpl \n")
.append("\t\t")
.append("1".equals(request.getParameter("instanceable"+i))?"true":"false")
.append(" \n")
.append("\t\t1 \n")
.append("\t\tfalse \n")
.append("\t\tcreator-iframe-portlet \n")
.append("\t \n");
portlet.append("\t\n")
.append("\t\t").append(portalId).append(" \n")
.append("\t\tcreator iframe \n")
.append("\t\tcom.liferay.plugin.portlet.IframeAppPortlet \n")
.append("\t\t\n")
.append("\t\t\tview-jsp \n")
.append("\t\t\t/view.jsp \n")
.append("\t\t \n")
.append("\t\t0 \n")
.append("\t\t\n")
.append("\t\t\ttext/html \n")
.append("\t\t \n")
.append("\t\t\n")
.append("\t\t\t").append(portalName).append(" \n")
.append("\t\t\t").append(portalName).append(" \n")
.append("\t\t\t").append(portalName).append(" \n")
.append("\t\t \n")
.append("\t\t\n")
.append("\t\t\t\n")
.append("\t\t\t\tform-method \n")
.append("\t\t\t\tpost \n")
.append("\t\t\t\ttrue \n")
.append("\t\t\t \n")
.append("\t\t\t\n")
.append("\t\t\t\tsrc \n")
.append("\t\t\t\t \n")
.append("\t\t\t\t")
.append("1".equals(request.getParameter("appModuleSrcstate"+i))?"true":"false")
.append(" \n")
.append("\t\t\t \n")
.append("\t\t\t\n")
.append("\t\t\t\tMAXsrc \n")
.append("\t\t\t\t \n")
.append("\t\t\t\t")
.append("1".equals(request.getParameter("MAXsrcstate"+i))?"true":"false")
.append(" \n")
.append("\t\t\t \n")
.append("\t\t\t\n")
.append("\t\t\t\thttpcontext \n")
.append("\t\t\t\t \n")
.append("\t\t\t\t")
.append("1".equals(request.getParameter("httpcontextstate"+i))?"true":"false")
.append(" \n")
.append("\t\t\t \n")
.append("\t\t\t\n")
.append("\t\t\t\tAPP_ID \n")
.append("\t\t\t\t \n")
.append("\t\t\t\t")
.append("1".equals(request.getParameter("appModuleSrcstate"+i))?"true":"false")
.append(" \n")
.append("\t\t\t \n")
.append("\t\t \n");
String[] roles = request.getParameterValues("role"+i);
for(int j = 0; j < roles.length; j++){
portlet.append("\t\t\n")
.append("\t\t\t").append(roles[j]).append(" \n")
.append("\t\t \n");
}
portlet.append("\t \n");
}
liferay_display.append("\t \n")
.append(" ");
liferay_portlet.append("\t\n")
.append("\t\tadministrator \n")
.append("\t\tAdministrator \n")
.append("\t \n")
.append("\t\n")
.append("\t\tguest \n")
.append("\t\tGuest \n")
.append("\t \n")
.append("\t\n")
.append("\t\tpower-user \n")
.append("\t\tPower User \n")
.append("\t \n")
.append("\t\n")
.append("\t\tuser \n")
.append("\t\tUser \n")
.append("\t \n")
.append("");
portlet.append("");
String msg = null;
try{
//temp目录
String tmepPath = PortalProperties.APPROOT + "/portal/temp";
//iframe模板文件所在目录
String templateZip = PortalProperties.APPROOT + "/portal/template/web_iframe_plugin.zip";
//删除temp目录下的文件和文件夹
FileUtil.deleteSubfiles(tmepPath);
//将iframe模板文件解压到temp目录
FileUtil.unzip(templateZip,tmepPath);
FileUtil.writeFile(PortalProperties.APPROOT + "/portal/temp/WEB-INF/liferay-display.xml",
liferay_display.toString(),false);
FileUtil.writeFile(PortalProperties.APPROOT + "/portal/temp/WEB-INF/liferay-portlet.xml",
liferay_portlet.toString(),false);
FileUtil.writeFile(PortalProperties.APPROOT + "/portal/temp/WEB-INF/portlet.xml",
portlet.toString(),false);
//将临时目录生成的文件打包成war包
//System.out.println(System.currentTimeMillis());
PortalUtil.jar(tmepPath,
PortalProperties.PORTAL_ISSUEPATH_WAR+"/"+request.getParameter("portletIframeName")+".war");
}catch(Exception e){
throw new PortalIssueException(e);
}
return true;
}
}