This repository has been archived by the owner on May 9, 2020. It is now read-only.
/
BirtViewerAttributeBean.java
170 lines (142 loc) · 6.15 KB
/
BirtViewerAttributeBean.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
package org.ofbiz.birt.report.context;
import java.net.URL;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.birt.report.IBirtConstants;
import org.eclipse.birt.report.context.ViewerAttributeBean;
import org.eclipse.birt.report.exception.ViewerException;
import org.eclipse.birt.report.resource.BirtResources;
import org.eclipse.birt.report.resource.ResourceConstants;
import org.eclipse.birt.report.utility.BirtUtility;
import org.eclipse.birt.report.utility.DataUtil;
import org.eclipse.birt.report.utility.ParameterAccessor;
import org.ofbiz.base.location.FlexibleLocation;
public class BirtViewerAttributeBean extends ViewerAttributeBean {
public final static String module = BirtViewerAttributeBean.class.getName();
/**
* Module Options
*/
private Map moduleOptions = null;
/**
* Request Type
*/
private String requestType;
private Boolean reportRtl;
public BirtViewerAttributeBean(HttpServletRequest arg0) {
super(arg0);
// TODO Auto-generated constructor stub
}
/**
* Init the bean.
*
* @param request
* @throws Exception
*/
protected void __init( HttpServletRequest request ) throws Exception
{
// If GetImage operate, return directly.
if ( ParameterAccessor.isGetImageOperator( request )
&& ( IBirtConstants.SERVLET_PATH_FRAMESET
.equalsIgnoreCase( request.getServletPath( ) )
|| IBirtConstants.SERVLET_PATH_OUTPUT
.equalsIgnoreCase( request.getServletPath( ) )
|| IBirtConstants.SERVLET_PATH_RUN
.equalsIgnoreCase( request.getServletPath( ) ) || IBirtConstants.SERVLET_PATH_PREVIEW
.equalsIgnoreCase( request.getServletPath( ) ) ) )
{
return;
}
this.category = "BIRT"; //$NON-NLS-1$
this.masterPageContent = ParameterAccessor
.isMasterPageContent( request );
this.isDesigner = ParameterAccessor.isDesigner( );
if ( !ParameterAccessor.isBookmarkReportlet( request ) )
{
this.bookmark = ParameterAccessor.getBookmark( request );
}
else
{
this.bookmark = null;
}
this.isToc = ParameterAccessor.isToc( request );
this.reportPage = ParameterAccessor.getPage( request );
this.reportPageRange = ParameterAccessor.getPageRange( request );
this.action = ParameterAccessor.getAction( request );
// If use frameset/output/download/extract servlet pattern, generate
// document
// from design file
if ( IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase( request
.getServletPath( ) )
|| IBirtConstants.SERVLET_PATH_OUTPUT.equalsIgnoreCase( request
.getServletPath( ) )
|| IBirtConstants.SERVLET_PATH_DOWNLOAD
.equalsIgnoreCase( request.getServletPath( ) )
|| IBirtConstants.SERVLET_PATH_EXTRACT
.equalsIgnoreCase( request.getServletPath( ) ) )
{
this.reportDocumentName = ParameterAccessor.getReportDocument(
request, null, true );
}
else
{
this.reportDocumentName = ParameterAccessor.getReportDocument(
request, null, false );
}
String reportParam = DataUtil.trimString( ParameterAccessor.getParameter( request, ParameterAccessor.PARAM_REPORT ));
if (reportParam.startsWith("component://")) {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
loader = BirtViewerAttributeBean.class.getClassLoader();
}
URL reportFileUrl = null;
reportFileUrl = FlexibleLocation.resolveLocation(reportParam, loader);
if (reportFileUrl == null) {
throw new IllegalArgumentException("Could not resolve location to URL: " + reportParam);
}
this.reportDesignName = reportFileUrl.getPath();
} else {
this.reportDesignName = ParameterAccessor.getReport( request, null );
}
this.emitterId = ParameterAccessor.getEmitterId( request );
// If print action, force to use postscript format
this.format = ParameterAccessor.getFormat( request );
if ( IBirtConstants.ACTION_PRINT.equalsIgnoreCase( action ) )
{
// Check whether turn on this funtion
if ( ParameterAccessor.isSupportedPrintOnServer )
{
this.format = IBirtConstants.POSTSCRIPT_RENDER_FORMAT;
this.emitterId = null;
}
else
{
this.action = null;
}
}
// Set locale information
BirtResources.setLocale( ParameterAccessor.getLocale( request ) );
// Set the request type
this.requestType = request
.getHeader( ParameterAccessor.HEADER_REQUEST_TYPE );
// Determine the report design and doc 's timestamp
processReport( request );
// Report title.
this.reportTitle = ParameterAccessor.getTitle( request );
// Set whether show the report title
this.isShowTitle = ParameterAccessor.isShowTitle( request );
// Set whether show the toolbar
this.isShowToolbar = ParameterAccessor.isShowToolbar( request );
// Set whether show the navigation bar
this.isShowNavigationbar = ParameterAccessor
.isShowNavigationbar( request );
// get some module options
this.moduleOptions = BirtUtility.getModuleOptions( request );
this.reportDesignHandle = getDesignHandle( request );
if ( this.reportDesignHandle == null )
throw new ViewerException(
ResourceConstants.GENERAL_EXCEPTION_NO_REPORT_DESIGN );
this.reportRtl = null;
// Initialize report parameters.
__initParameters( request );
}
}