/*
 * Decompiled with CFR 0_114.
 * 
 * Could not load the following classes:
 *  com.stimulsoft.base.StiAttribute
 *  com.stimulsoft.base.enums.StiPaperKind
 *  com.stimulsoft.base.exception.StiException
 *  com.stimulsoft.base.json.JSONException
 *  com.stimulsoft.base.json.JSONObject
 *  com.stimulsoft.base.json.StiJSONHelper
 *  com.stimulsoft.base.localization.StiLocalization
 *  com.stimulsoft.base.serializing.StiDeserializationException
 *  com.stimulsoft.base.system.StiGuid
 *  com.stimulsoft.base.utils.StiLoggingUtil
 *  com.stimulsoft.lib.io.StiIOUtil
 *  com.stimulsoft.lib.utils.StiValidationUtil
 *  com.stimulsoft.lib.utils.StiXmlUtil
 *  com.stimulsoft.report.StiExportManager
 *  com.stimulsoft.report.StiReport
 *  com.stimulsoft.report.StiSerializeManager
 *  com.stimulsoft.report.components.StiPage
 *  com.stimulsoft.report.components.StiPagesCollection
 *  com.stimulsoft.report.design.StiDesignerInfo
 *  com.stimulsoft.report.dictionary.data.DataSet
 *  com.stimulsoft.report.enums.StiReportUnitType
 *  com.stimulsoft.report.export.service.StiHtmlExportService
 *  com.stimulsoft.report.export.settings.StiHtmlExportSettings
 *  com.stimulsoft.report.units.StiUnit
 *  com.stimulsoft.web.enums.StiInterfaceType
 *  com.stimulsoft.web.helper.StiFileResult
 *  com.stimulsoft.web.helper.StiWebResourceHelper
 *  com.stimulsoft.web.html.StiHtmlElement
 *  com.stimulsoft.web.utils.StiServletUtil
 *  javax.servlet.ServletContext
 *  javax.servlet.ServletOutputStream
 *  javax.servlet.http.HttpServletRequest
 *  javax.servlet.http.HttpServletResponse
 *  javax.servlet.http.HttpSession
 */
package com.stimulsoft.webdesigner;

import com.stimulsoft.base.StiAttribute;
import com.stimulsoft.base.enums.StiPaperKind;
import com.stimulsoft.base.exception.StiException;
import com.stimulsoft.base.json.JSONException;
import com.stimulsoft.base.json.JSONObject;
import com.stimulsoft.base.json.StiJSONHelper;
import com.stimulsoft.base.localization.StiLocalization;
import com.stimulsoft.base.serializing.StiDeserializationException;
import com.stimulsoft.base.system.StiGuid;
import com.stimulsoft.base.utils.StiLoggingUtil;
import com.stimulsoft.lib.io.StiIOUtil;
import com.stimulsoft.lib.utils.StiValidationUtil;
import com.stimulsoft.lib.utils.StiXmlUtil;
import com.stimulsoft.report.StiExportManager;
import com.stimulsoft.report.StiReport;
import com.stimulsoft.report.StiSerializeManager;
import com.stimulsoft.report.components.StiPage;
import com.stimulsoft.report.components.StiPagesCollection;
import com.stimulsoft.report.design.StiDesignerInfo;
import com.stimulsoft.report.dictionary.data.DataSet;
import com.stimulsoft.report.enums.StiReportUnitType;
import com.stimulsoft.report.export.service.StiHtmlExportService;
import com.stimulsoft.report.export.settings.StiHtmlExportSettings;
import com.stimulsoft.report.units.StiUnit;
import com.stimulsoft.web.enums.StiInterfaceType;
import com.stimulsoft.web.helper.StiFileResult;
import com.stimulsoft.web.helper.StiWebResourceHelper;
import com.stimulsoft.web.html.StiHtmlElement;
import com.stimulsoft.web.utils.StiServletUtil;
import com.stimulsoft.webdesigner.StiWebDesigerHandler;
import com.stimulsoft.webdesigner.StiWebDesignerHelper;
import com.stimulsoft.webdesigner.StiWebDesignerOptions;
import com.stimulsoft.webdesigner.enums.StiDesignerPermissions;
import com.stimulsoft.webdesigner.enums.StiWebDesignerTheme;
import com.stimulsoft.webdesigner.helper.StiAggrigateFunctions;
import com.stimulsoft.webdesigner.helper.StiChartHelper;
import com.stimulsoft.webdesigner.helper.StiDefaultConditions;
import com.stimulsoft.webdesigner.helper.StiDictionaryHelper;
import com.stimulsoft.webdesigner.helper.StiEncodingHelper;
import com.stimulsoft.webdesigner.helper.StiFontNames;
import com.stimulsoft.webdesigner.helper.StiHatchStyles;
import com.stimulsoft.webdesigner.helper.StiIconSetArrays;
import com.stimulsoft.webdesigner.helper.StiPaperSizes;
import com.stimulsoft.webdesigner.helper.StiReportEdit;
import com.stimulsoft.webdesigner.helper.StiStylesHelper;
import com.stimulsoft.webdesigner.helper.StiSummaryTypes;
import com.stimulsoft.webdesigner.helper.StiWizardHelper;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.URL;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletContext;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.ProcessingInstruction;
import org.xml.sax.SAXException;

/*
 * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
 */
public class StiWebDesigner {
    protected static final Logger LOG = Logger.getLogger(StiWebDesigner.class.getName());
    public static final String ACTION_GET_REPORT_TEMPLATE = "ReportTemplate";
    public static final String ACTION_OPEN_REPORT_TEMPLATE = "OpenReportTemplate";
    public static final String ACTION_SAVE_REPORT_TEMPLATE = "SaveReportTemplate";
    public static final String ACTION_GET_NEW_REPORT_DATA = "GetNewReportData";
    public static final String ACTION_DESIGNER_EVENT = "DesignerEvent";
    public static final String ACTION_REFRESH_SESSION = "RefreshSession";
    public static final String ACTION_EXIST_DESIGNER = "ExitDesigner";
    public static final String ACTION_GET_REPORT_SNAPSHOTE = "ReportSnapshot";
    public static final String ACTION_EXPORT_REPORT = "ExportReport";
    private static final String SESSION_ATTRIBUTE_CACHED_REPORT = "webdesigner_cached_report";
    private static final String SESSION_ATTRIBUTE_PARAMETERS = "webdesigner_params";
    private static final String SESSION_ATTRIBUTE_HANDLER = "webdesigner_handler";
    private static final String SESSION_OPTIONS_ID = "sessionOptions";
    private StiWebDesignerOptions options;
    private String id;

    public StiWebDesigner(StiWebDesignerOptions stiWebDesignerOptions, URL uRL, HttpServletRequest httpServletRequest) {
        this.options = stiWebDesignerOptions;
        this.id = stiWebDesignerOptions.getDesignerID();
        httpServletRequest.getSession().setAttribute("sessionOptions", (Object)stiWebDesignerOptions);
        String string = stiWebDesignerOptions.getLocalization();
        if (StiValidationUtil.isNotNullOrEmpty((String)string)) {
            File file = new File(string);
            if (file.exists()) {
                try {
                    StiLocalization stiLocalization = StiLocalization.load((InputStream)new FileInputStream(file));
                    StiLocalization.setLocalization((StiLocalization)stiLocalization);
                }
                catch (FileNotFoundException var6_7) {
                    LOG.log(Level.SEVERE, "", var6_7);
                }
                catch (StiException var6_8) {
                    LOG.log(Level.SEVERE, "", (Throwable)var6_8);
                }
            } else {
                LOG.log(Level.SEVERE, "Unable to load localization file: " + file.getAbsolutePath());
            }
        }
    }

    private static void setupDesign(StiReport stiReport) {
        if (stiReport != null) {
            stiReport.getInfo().setForceDesigningMode(true);
            stiReport.setIsSerializing(false);
            stiReport.setIsRendered(false);
        }
    }

    public String getDesigner(URL uRL, StiWebDesigerHandler stiWebDesigerHandler, HttpServletRequest httpServletRequest, ServletContext servletContext) throws ParserConfigurationException, IOException {
        StiReport stiReport = stiWebDesigerHandler.getEditedReport(httpServletRequest);
        StiWebDesigner.setupDesign(stiReport);
        DocumentBuilderFactory documentBuilderFactory = StiXmlUtil.getBuilderFactory();
        DocumentBuilder documentBuilder = null;
        documentBuilder = documentBuilderFactory.newDocumentBuilder();
        Document document = documentBuilder.newDocument();
        ProcessingInstruction processingInstruction = document.createProcessingInstruction("javax.xml.transform.disable-output-escaping", "");
        document.appendChild(processingInstruction);
        Element element = StiHtmlElement.createPanelHtmlElement((Document)document);
        document.appendChild(element);
        return this.createChildControls(element, document, uRL, stiReport, httpServletRequest, stiWebDesigerHandler, servletContext);
    }

    protected String createChildControls(Element element, Document document, URL uRL, StiReport stiReport, HttpServletRequest httpServletRequest, StiWebDesigerHandler stiWebDesigerHandler, ServletContext servletContext) throws IOException {
        this.options.setJsObject("js" + this.id + ".");
        Hashtable<String, Object> hashtable = new Hashtable<String, Object>();
        String string = StiWebDesigner.getNewGuid();
        String string2 = StiWebDesigner.getNewGuid();
        hashtable.put("isJava", System.getProperty("java.runtime.version"));
        hashtable.put("mobileDesignerId", this.id);
        hashtable.put("requestUrl", uRL.toString() + "/" + "stimulsoft_webdesigner_action" + "?a={action}");
        hashtable.put("actionGetReportSnapshot", "ReportSnapshot");
        hashtable.put("actionGetReportTemplate", "ReportTemplate");
        hashtable.put("actionOpenReportTemplate", "OpenReportTemplate");
        hashtable.put("actionSaveReportTemplate", "SaveReportTemplate");
        hashtable.put("actionGetNewReportData", "GetNewReportData");
        hashtable.put("actionExitDesigner", "ExitDesigner");
        hashtable.put("actionDesignerEvent", "DesignerEvent");
        hashtable.put("serverCacheMode", "Page");
        hashtable.put("serverTimeout", "00:00:10");
        hashtable.put("serverCacheItemPriority", "Default");
        hashtable.put("demoVersion", true);
        hashtable.put("theme", this.options.getTheme().name());
        hashtable.put("showAnimation", this.options.isShowAnimation());
        hashtable.put("defaultUnit", (Object)this.options.getDefaultUnit());
        hashtable.put("helpLanguage", this.getCurrentHelpLanguage());
        hashtable.put("productVersion", StiAttribute.getVersion((boolean)true) + "<br>Server: " + servletContext.getServerInfo() + ", " + StiServletUtil.getSystemVersion());
        hashtable.put("defaultUnit", (Object)this.options.getDefaultUnit());
        hashtable.put("clipboardId", string2);
        hashtable.put("undoArrayId", StiWebDesigner.getNewGuid());
        hashtable.put("chartCloneId", StiWebDesigner.getNewGuid());
        hashtable.put("showSaveDialog", this.options.isShowSaveDialog());
        hashtable.put("fullScreenMode", StiValidationUtil.isNullOrEmpty((String)this.options.getWidth()) && StiValidationUtil.isNullOrEmpty((String)this.options.getHeight()));
        hashtable.put("showTooltips", this.options.isShowTooltips());
        hashtable.put("showTooltipsHelp", this.options.isShowTooltipsHelp());
        hashtable.put("interfaceType", this.options.getInterfaceType().name());
        hashtable.put("cloudMode", false);
        hashtable.put("loc", new JSONObject(StiLocalization.getLocalization().languageProp).toString());
        hashtable.put("paperSizes", StiPaperSizes.getItems());
        hashtable.put("hatchStyles", StiHatchStyles.getItems());
        hashtable.put("summaryTypes", StiSummaryTypes.getItems());
        hashtable.put("aggrigateFunctions", StiAggrigateFunctions.getItems());
        hashtable.put("fontNames", StiFontNames.getItems());
        hashtable.put("conditions", StiDefaultConditions.getItems());
        hashtable.put("iconSetArrays", StiIconSetArrays.getItems());
        hashtable.put("images", StiWebResourceHelper.getImages((Class)StiWebDesigner.class, (String)"webdesigner", (String)"webdesigner/Images/Office2013/", (URL)uRL, (String)this.options.getTheme().name(), (boolean)this.options.isImagesInHTML()));
        hashtable.put("styles", StiWebDesignerHelper.getDesignerStyles(uRL, this.options.getTheme()));
        hashtable.put("routes", "{}");
        hashtable.put("showInsertButton", this.options.isShowInsertButton());
        hashtable.put("showPageButton", this.options.isShowPageButton());
        hashtable.put("showPreviewButton", this.options.isShowPreviewButton());
        hashtable.put("showFileMenu", this.options.isShowFileMenu());
        hashtable.put("showSaveButton", this.options.isShowSaveButton());
        hashtable.put("showAboutButton", this.options.isShowAboutButton());
        hashtable.put("reportGuid", string);
        hashtable.put("showFileMenuNew", this.options.isShowFileMenuNew());
        hashtable.put("showFileMenuOpen", this.options.isShowFileMenuOpen());
        hashtable.put("showFileMenuSave", this.options.isShowFileMenuSave());
        hashtable.put("showFileMenuClose", this.options.isShowFileMenuClose());
        hashtable.put("showFileMenuExit", this.options.isShowFileMenuExit());
        hashtable.put("showFileMenuReportSetup", this.options.isShowFileMenuReportSetup());
        Hashtable<String, Boolean> hashtable2 = new Hashtable<String, Boolean>();
        hashtable.put("visibilityBands", hashtable2);
        hashtable2.put("StiReportTitleBand", this.options.isShowReportTitleBand());
        hashtable2.put("StiReportSummaryBand", this.options.isShowReportSummaryBand());
        hashtable2.put("StiPageHeaderBand", this.options.isShowPageHeaderBand());
        hashtable2.put("StiPageFooterBand", this.options.isShowPageFooterBand());
        hashtable2.put("StiGroupHeaderBand", this.options.isShowGroupHeaderBand());
        hashtable2.put("StiGroupFooterBand", this.options.isShowGroupFooterBand());
        hashtable2.put("StiHeaderBand", this.options.isShowHeaderBand());
        hashtable2.put("StiFooterBand", this.options.isShowFooterBand());
        hashtable2.put("StiColumnHeaderBand", this.options.isShowColumnHeaderBand());
        hashtable2.put("StiColumnFooterBand", this.options.isShowColumnFooterBand());
        hashtable2.put("StiDataBand", this.options.isShowDataBand());
        hashtable2.put("StiHierarchicalBand", this.options.isShowHierarchicalBand());
        hashtable2.put("StiChildBand", this.options.isShowChildBand());
        hashtable2.put("StiEmptyBand", this.options.isShowEmptyBand());
        hashtable2.put("StiOverlayBand", this.options.isShowOverlayBand());
        hashtable2.put("StiTable", this.options.isShowTable());
        Hashtable<String, Boolean> hashtable3 = new Hashtable<String, Boolean>();
        hashtable.put("visibilityCrossBands", hashtable3);
        hashtable3.put("StiCrossTab", this.options.isShowCrossTab());
        hashtable3.put("StiCrossGroupHeaderBand", this.options.isShowCrossGroupHeaderBand());
        hashtable3.put("StiCrossGroupFooterBand", this.options.isShowCrossGroupFooterBand());
        hashtable3.put("StiCrossHeaderBand", this.options.isShowCrossHeaderBand());
        hashtable3.put("StiCrossFooterBand", this.options.isShowCrossFooterBand());
        hashtable3.put("StiCrossDataBand", this.options.isShowCrossDataBand());
        Hashtable<String, Boolean> hashtable4 = new Hashtable<String, Boolean>();
        hashtable.put("visibilityComponents", hashtable4);
        hashtable4.put("StiText", this.options.isShowText());
        hashtable4.put("StiTextInCells", this.options.isShowTextInCells());
        hashtable4.put("StiRichText", this.options.isShowRichText());
        hashtable4.put("StiImage", this.options.isShowImage());
        hashtable4.put("StiBarCode", this.options.isShowBarCode());
        hashtable4.put("StiShape", this.options.isShowShape());
        hashtable4.put("StiPanel", this.options.isShowPanel());
        hashtable4.put("StiClone", this.options.isShowClone());
        hashtable4.put("StiCheckBox", this.options.isShowCheckBox());
        hashtable4.put("StiSubReport", this.options.isShowSubReport());
        hashtable4.put("StiZipCode", this.options.isShowZipCode());
        hashtable4.put("StiChart", this.options.isShowChart());
        hashtable.put("showPropertiesGrid", this.options.isShowPropertiesGrid());
        hashtable.put("propertiesGridWidth", this.options.getPropertiesGridWidth());
        hashtable.put("propertiesGridLabelWidth", this.options.getPropertiesGridLabelWidth());
        hashtable.put("showDictionary", this.options.isShowDictionary());
        hashtable.put("permissionDataSources", this.options.getPermissionDataSources().toString());
        hashtable.put("permissionDataColumns", this.options.getPermissionDataColumns().toString());
        hashtable.put("permissionDataRelations", this.options.getPermissionDataRelations().toString());
        hashtable.put("permissionDataConnections", this.options.getPermissionDataConnections().toString());
        hashtable.put("permissionBusinessObjects", this.options.getPermissionBusinessObjects().toString());
        hashtable.put("permissionVariables", this.options.getPermissionVariables().toString());
        hashtable.put("urlCursorStyleSet", StiWebResourceHelper.getWebResourceUrl((URL)uRL, (String)"webdesigner", (String)"/Images/Office2013/Cursors/StyleSet.cur"));
        hashtable.put("urlCursorPen", StiWebResourceHelper.getWebResourceUrl((URL)uRL, (String)"webdesigner", (String)"/Images/Office2013/Cursors/Pen.cur"));
        String string3 = new JSONObject(hashtable).toString();
        Element element2 = StiHtmlElement.createPanelHtmlElement((Document)document);
        StiHtmlElement.setID((Element)element2, (String)(this.id + "_MainPanel"));
        StiHtmlElement.setCssClass((Element)element2, (String)"stiDesignerMainPanel");
        element.appendChild(element2);
        if (StiValidationUtil.isNullOrEmpty((String)this.options.getWidth()) && StiValidationUtil.isNullOrEmpty((String)this.options.getHeight())) {
            StiHtmlElement.addStyle((Element)element, (String)"position", (String)"absolute");
            StiHtmlElement.addStyle((Element)element, (String)"top", (String)"0px");
            StiHtmlElement.addStyle((Element)element, (String)"left", (String)"0px");
            StiHtmlElement.addStyle((Element)element, (String)"right", (String)"0px");
            StiHtmlElement.addStyle((Element)element, (String)"bottom", (String)"0px");
        } else {
            StiHtmlElement.addStyle((Element)element2, (String)"width", (String)this.options.getWidth());
            StiHtmlElement.addStyle((Element)element2, (String)"height", (String)this.options.getHeight());
        }
        Element element3 = StiHtmlElement.createJavascriptHtmlElement((Document)document);
        element3.setTextContent("var js" + this.id + " = new StiMobileDesigner(" + string3 + ")");
        element.appendChild(element3);
        if (this.options.getRefreshTimeout() > 0) {
            Element element4 = StiHtmlElement.createJavascriptHtmlElement((Document)document);
            element4.setTextContent(String.format("function refreshSession(){ js%s.PostAjax('RefreshSession=' + Math.random(),'', function(){} ); setTimeout('refreshSession()',%s);}refreshSession();", this.id, this.options.getRefreshTimeout() * 60000));
            element.appendChild(element4);
        }
        StiHtmlElement.setID((Element)element, (String)this.id);
        StiWebDesigner.saveReportObject(httpServletRequest, stiReport, string);
        httpServletRequest.getSession().setAttribute(string2 + "webdesigner_handler", (Object)stiWebDesigerHandler);
        return StiWebDesigner.serialize(document, true);
    }

    public void storeReport(HttpServletRequest httpServletRequest, StiReport stiReport, String string) throws IOException, StiException {
        String string2 = string + "webdesigner_cached_report";
        httpServletRequest.getSession().removeAttribute(string + "webdesigner_params");
        if (stiReport != null) {
            httpServletRequest.getSession().setAttribute(string2, (Object)stiReport);
        }
    }

    public static String serialize(Document document, boolean bl) throws IOException {
        try {
            TransformerFactory transformerFactory = TransformerFactory.newInstance();
            Transformer transformer = transformerFactory.newTransformer();
            transformer.setOutputProperty("method", "html");
            transformer.setOutputProperty("omit-xml-declaration", "yes");
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            transformer.transform(new DOMSource(document), new StreamResult(new OutputStreamWriter((OutputStream)byteArrayOutputStream, "UTF-8")));
            byteArrayOutputStream.close();
            return new String(byteArrayOutputStream.toByteArray(), "UTF8");
        }
        catch (Exception var2_3) {
            LOG.log(Level.SEVERE, "", var2_3);
            return "";
        }
    }

    public static String getActionCommandName(HttpServletRequest httpServletRequest) throws JSONException {
        JSONObject jSONObject = new JSONObject(httpServletRequest.getParameter("MvcMobileDesignerParameters"));
        return (String)jSONObject.get("command");
    }

    public static List<Object> getArrayFromCache(HttpServletRequest httpServletRequest, String string) {
        ArrayList<Object> arrayList = (ArrayList<Object>)httpServletRequest.getSession().getAttribute(string);
        if (arrayList == null || arrayList.size() == 0) {
            arrayList = new ArrayList<Object>();
            arrayList.add(1);
            arrayList.add(JSONObject.NULL);
        }
        return arrayList;
    }

    public static List<Object> saveArrayToCache(HttpServletRequest httpServletRequest, String string, List<Object> list) {
        httpServletRequest.getSession().setAttribute(string, list);
        return list;
    }

    public static StiReport getReportObject(HttpServletRequest httpServletRequest) throws JSONException {
        JSONObject jSONObject = new JSONObject(httpServletRequest.getParameter("MvcMobileDesignerParameters"));
        return StiWebDesigner.getReportObject(httpServletRequest, jSONObject);
    }

    public static StiReport getReportObject_new(HttpServletRequest httpServletRequest, JSONObject jSONObject) {
        return null;
    }

    public static StiReport getReportObject(HttpServletRequest httpServletRequest, JSONObject jSONObject) throws JSONException {
        String string = jSONObject.getString("reportGuid");
        StiReport stiReport = (StiReport)httpServletRequest.getSession().getAttribute(string);
        if (stiReport != null) {
            stiReport.getInfo().setForceDesigningMode(true);
            if (jSONObject.has("reportName")) {
                stiReport.setReportName(jSONObject.getString("reportName"));
            }
        }
        return stiReport;
    }

    public static StiReport saveReportObject(HttpServletRequest httpServletRequest, StiReport stiReport, String string) {
        if (stiReport != null) {
            httpServletRequest.getSession().setAttribute(string, (Object)stiReport);
        }
        return stiReport;
    }

    public static String designerEventResult(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        JSONObject jSONObject = new JSONObject(httpServletRequest.getParameter("MvcMobileDesignerParameters"));
        Hashtable hashtable = StiJSONHelper.jsonToHash((JSONObject)jSONObject);
        Hashtable<String, Object> hashtable2 = new Hashtable<String, Object>();
        String string = (String)hashtable.get("command");
        hashtable2.put("command", string);
        try {
            Object object;
            StiReport stiReport = StiWebDesigner.getReportObject(httpServletRequest, jSONObject);
            StiWebDesignerOptions stiWebDesignerOptions = (StiWebDesignerOptions)httpServletRequest.getSession().getAttribute("sessionOptions");
            if (!(stiReport != null || "CloseReport".equals(string) || "CreateReport".equals(string) || "OpenReport".equals(string) || "GetDataSourcesForWizard".equals(string) || "WizardResult".equals(string))) {
                hashtable2.put("command", "SessionCompleted");
                return new JSONObject(hashtable2).toString();
            }
            if ("Synchronization".equals(string)) {
                if (stiReport == null) {
                    hashtable2.put("command", "SessionCompleted");
                } else {
                    hashtable2.put("reportObject", StiReportEdit.writeReportInObject(stiReport));
                }
            }
            if ("UpdateCache".equals(string)) {
                hashtable2.put("command", "UpdateCache");
            }
            if ("CloseReport".equals(string)) {
                stiReport = null;
            }
            if ("MoveComponent".equals(string) || "ResizeComponent".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiReportEdit.changeRectComponent(stiReport, hashtable, hashtable2);
            }
            if ("CreateComponent".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiReportEdit.createComponent(stiReport, hashtable, hashtable2);
            }
            if ("RemoveComponent".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiReportEdit.removeComponent(stiReport, hashtable, hashtable2);
            }
            if ("AddPage".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiReportEdit.addPage(stiReport, hashtable, hashtable2);
            }
            if ("RemovePage".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiReportEdit.removePage(stiReport, hashtable, hashtable2);
            }
            if ("SendProperties".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiReportEdit.readAllPropertiesFromString(stiReport, hashtable, hashtable2);
            }
            if ("ChangeUnit".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiReportEdit.changeUnit(stiReport, (String)hashtable.get("reportUnit"));
                object = StiReportEdit.getAllComponentsPositions(stiReport);
                hashtable2.put("reportUnit", hashtable.get("reportUnit"));
                hashtable2.put("pagePositions", object.get("pagePositions"));
                hashtable2.put("compPositions", object.get("compPositions"));
                hashtable2.put("gridSize", String.valueOf(stiReport.getInfo().getGridSize()));
            }
            if ("RebuildPage".equals(string)) {
                hashtable2.put("pageName", hashtable.get("pageName"));
                hashtable2.put("rebuildProps", StiReportEdit.getPropsRebuildPage(stiReport, StiReportEdit.getPageByName(stiReport, (String)hashtable.get("pageName"))));
            }
            if ("UpdateAllSvgContents".equals(string)) {
                StiReportEdit.getAllSvgContents(stiReport, hashtable, hashtable2);
            }
            if ("RenameComponent".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiReportEdit.renameComponent(stiReport, hashtable, hashtable2);
            }
            if ("Undo".equals(string)) {
                StiReportEdit.getUndoStep(httpServletRequest, stiReport, hashtable, hashtable2);
            }
            if ("Redo".equals(string)) {
                StiReportEdit.getRedoStep(httpServletRequest, stiReport, hashtable, hashtable2);
            }
            if ("SetToClipboard".equals(string)) {
                StiReportEdit.setToClipboard(httpServletRequest, stiReport, hashtable, hashtable2);
            }
            if ("GetFromClipboard".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiReportEdit.getFromClipboard(httpServletRequest, stiReport, hashtable, hashtable2);
            }
            if ("PreviewAs".equals(string)) {
                return StiWebDesigner.previewAs(stiReport, jSONObject, httpServletResponse);
            }
            if ("GetConnectionTypes".equals(string)) {
                StiDictionaryHelper.getConnectionTypes(stiReport, hashtable, hashtable2, stiWebDesignerOptions);
            }
            if ("GetDataAdapterTypes".equals(string)) {
                StiDictionaryHelper.getDataAdapterTypes(stiReport, hashtable, hashtable2, stiWebDesignerOptions);
            }
            if ("CreateOrEditConnection".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.createOrEditConnection(stiReport, hashtable, hashtable2, stiWebDesignerOptions);
            }
            if ("DeleteConnection".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.deleteConnection(stiReport, hashtable, hashtable2);
            }
            if ("CreateOrEditRelation".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.createOrEditRelation(stiReport, hashtable, hashtable2);
            }
            if ("DeleteRelation".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.deleteRelation(stiReport, hashtable, hashtable2);
            }
            if ("CreateOrEditColumn".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.createOrEditColumn(stiReport, hashtable, hashtable2);
            }
            if ("DeleteColumn".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.deleteColumn(stiReport, hashtable, hashtable2);
            }
            if ("CreateOrEditDataSource".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.createOrEditDataSource(stiReport, hashtable, hashtable2, stiWebDesignerOptions);
            }
            if ("DeleteDataSource".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.deleteDataSource(stiReport, hashtable, hashtable2);
            }
            if ("CreateOrEditBusinessObject".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.createOrEditBusinessObject(stiReport, hashtable, hashtable2);
            }
            if ("DeleteBusinessObject".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.deleteBusinessObject(stiReport, hashtable, hashtable2);
            }
            if ("DeleteBusinessObjectCategory".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.deleteBusinessObjectCategory(stiReport, hashtable, hashtable2);
            }
            if ("EditBusinessObjectCategory".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.editBusinessObjectCategory(stiReport, hashtable, hashtable2);
            }
            if ("CreateOrEditVariable".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.createOrEditVariable(stiReport, hashtable, hashtable2);
            }
            if ("DeleteVariable".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.deleteVariable(stiReport, hashtable, hashtable2);
            }
            if ("DeleteVariablesCategory".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.deleteVariablesCategory(stiReport, hashtable, hashtable2);
            }
            if ("EditVariablesCategory".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.editVariablesCategory(stiReport, hashtable, hashtable2);
            }
            if ("CreateVariablesCategory".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiDictionaryHelper.createVariablesCategory(stiReport, hashtable, hashtable2);
            }
            if ("SynchronizeDictionary".equals(string)) {
                StiDictionaryHelper.synchronizeDictionary(stiReport, hashtable, hashtable2);
            }
            if ("GetAllConnections".equals(string)) {
                StiDictionaryHelper.getAllConnections(stiReport, hashtable, hashtable2, stiWebDesignerOptions);
            }
            if ("RetrieveColumns".equals(string)) {
                StiDictionaryHelper.retrieveColumns(stiReport, hashtable, hashtable2);
            }
            if ("WizardResult".equals(string)) {
                object = StiWebDesigner.getNewGuid();
                JSONObject jSONObject2 = (JSONObject)hashtable.get("wizardResult");
                stiReport = StiWizardHelper.getReportFromWizardOptions(stiReport, (JSONObject)jSONObject2.get("reportOptions"), (JSONObject)jSONObject2.get("dataSources"));
                StiWebDesigner.saveReportObject(httpServletRequest, stiReport, (String)object);
                StiWebDesigner.saveArrayToCache(httpServletRequest, (String)hashtable.get("undoArrayId"), new ArrayList<Object>());
                hashtable2.put("reportGuid", object);
                hashtable2.put("reportObject", StiReportEdit.writeReportInObject(stiReport));
            }
            if ("UpdateStyles".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiStylesHelper.updateStyles(stiReport, hashtable, hashtable2);
            }
            if ("AddStyle".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiStylesHelper.addStyle(stiReport, hashtable, hashtable2);
            }
            if ("RemoveStyle".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiStylesHelper.removeStyle(stiReport, hashtable, hashtable2);
            }
            if ("CreateStyleCollection".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiStylesHelper.createStyleCollection(stiReport, hashtable, hashtable2);
            }
            if ("StartEditChartComponent".equals(string)) {
                try {
                    StiReportEdit.saveChartClone(httpServletRequest, stiReport, hashtable, hashtable2);
                }
                catch (Exception var8_10) {
                    // empty catch block
                }
            }
            if ("CanceledEditChart".equals(string)) {
                try {
                    StiReportEdit.canceledEditChart(httpServletRequest, stiReport, hashtable, hashtable2);
                }
                catch (Exception var8_11) {
                    // empty catch block
                }
            }
            if ("AddSeries".equals(string)) {
                StiChartHelper.addSeries(stiReport, hashtable, hashtable2);
            }
            if ("RemoveSeries".equals(string)) {
                StiChartHelper.removeSeries(stiReport, hashtable, hashtable2);
            }
            if ("SeriesMove".equals(string)) {
                StiChartHelper.seriesMove(stiReport, hashtable, hashtable2);
            }
            if ("AddConstantLineOrStrip".equals(string)) {
                StiChartHelper.addConstantLineOrStrip(stiReport, hashtable, hashtable2);
            }
            if ("RemoveConstantLineOrStrip".equals(string)) {
                StiChartHelper.removeConstantLineOrStrip(stiReport, hashtable, hashtable2);
            }
            if ("ConstantLineOrStripMove".equals(string)) {
                StiChartHelper.constantLineOrStripMove(stiReport, hashtable, hashtable2);
            }
            if ("GetLabelsContent".equals(string)) {
                StiChartHelper.getLabelsContent(stiReport, hashtable, hashtable2);
            }
            if ("GetStylesContent".equals(string)) {
                StiChartHelper.getStylesContent(stiReport, hashtable, hashtable2);
            }
            if ("SetLabelsType".equals(string)) {
                StiChartHelper.setLabelsType(stiReport, hashtable, hashtable2);
            }
            if ("SetChartStyle".equals(string)) {
                StiChartHelper.setChartStyle(stiReport, hashtable, hashtable2);
            }
            if ("SetChartPropertyValue".equals(string)) {
                StiChartHelper.setChartPropertyValue(stiReport, hashtable, hashtable2);
            }
            if ("SendContainerValue".equals(string)) {
                StiChartHelper.setContainerValue(stiReport, hashtable, hashtable2);
            }
            if ("GetDatabaseData".equals(string)) {
                StiDictionaryHelper.getDatabaseData(stiReport, hashtable, hashtable2);
            }
            if ("ApplySelectedData".equals(string)) {
                StiDictionaryHelper.applySelectedData(stiReport, hashtable, hashtable2);
            }
            if ("CreateTextComponent".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiReportEdit.createTextComponentFromDictionary(stiReport, hashtable, hashtable2);
            }
            if ("CreateDataComponent".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiReportEdit.createDataComponentFromDictionary(stiReport, hashtable, hashtable2);
            }
            if ("SetReportProperties".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiReportEdit.setReportProperties(stiReport, hashtable, hashtable2);
            }
            if ("PageMove".equals(string)) {
                StiReportEdit.addReportToUndoArray(httpServletRequest, stiReport, hashtable);
                StiReportEdit.pageMove(stiReport, hashtable, hashtable2);
            }
            if ("TestConnection".equals(string)) {
                StiDictionaryHelper.testConnection(stiReport, hashtable, hashtable2, stiWebDesignerOptions);
            }
            if (hashtable.contains("reportGuid")) {
                object = (String)hashtable.get("reportGuid");
                StiWebDesigner.saveReportObject(httpServletRequest, stiReport, (String)object);
            }
        }
        catch (Exception var6_7) {
            var6_7.printStackTrace();
            hashtable2.put("error", StiLoggingUtil.getHtmlError((String)(var6_7.getClass() + " " + var6_7.getMessage()), (Exception)var6_7));
        }
        return new JSONObject(hashtable2).toString();
    }

    public static String getReportTemplateResult(HttpServletRequest httpServletRequest) throws JSONException {
        return StiWebDesigner.getReportTemplateResult(httpServletRequest, null);
    }

    public static String getReportTemplateResult(HttpServletRequest httpServletRequest, StiReport stiReport) throws JSONException {
        JSONObject jSONObject = new JSONObject(httpServletRequest.getParameter("MvcMobileDesignerParameters"));
        if (stiReport == null) {
            stiReport = StiWebDesigner.getNewReport(jSONObject);
        }
        String string = jSONObject.get("reportGuid") == JSONObject.NULL ? StiWebDesigner.getNewGuid() : jSONObject.getString("reportGuid");
        stiReport.getInfo().setZoom(1.0);
        StiWebDesigner.saveReportObject(httpServletRequest, stiReport, string);
        Hashtable<String, String> hashtable = new Hashtable<String, String>();
        hashtable.put("reportGuid", string);
        hashtable.put("reportObject", StiReportEdit.writeReportInObject(stiReport));
        hashtable.put("command", "LoadReport");
        return new JSONObject(hashtable).toString();
    }

    public static String getReportSnapshotResult(HttpServletRequest httpServletRequest) throws JSONException, StiException, IOException, SAXException, StiDeserializationException {
        return StiWebDesigner.getReportSnapshotResult(httpServletRequest, null);
    }

    public static String getReportSnapshotResult(HttpServletRequest httpServletRequest, StiReport stiReport) throws JSONException, StiException, IOException, SAXException, StiDeserializationException {
        Hashtable<String, Object> hashtable = new Hashtable<String, Object>();
        JSONObject jSONObject = new JSONObject(httpServletRequest.getParameter("MvcMobileDesignerParameters"));
        hashtable.put("command", jSONObject.get("command"));
        StiReport stiReport2 = stiReport;
        if (stiReport2 == null) {
            stiReport2 = StiWebDesigner.getReportObject(httpServletRequest);
        }
        hashtable = StiWebDesigner.getReportSnapshotCallbackResult(hashtable, httpServletRequest, stiReport2, jSONObject);
        return new JSONObject(hashtable).toString();
    }

    public static String getNewReportDataResult(HttpServletRequest httpServletRequest) throws JSONException {
        return StiWebDesigner.getNewReportDataResultHelper(httpServletRequest, null, null);
    }

    public static String getNewReportDataResult(HttpServletRequest httpServletRequest, DataSet dataSet) throws JSONException {
        return StiWebDesigner.getNewReportDataResultHelper(httpServletRequest, null, dataSet);
    }

    public static String getNewReportDataResult(HttpServletRequest httpServletRequest, StiReport stiReport) throws JSONException {
        return StiWebDesigner.getNewReportDataResultHelper(httpServletRequest, stiReport, null);
    }

    public static String getNewReportDataResultHelper(HttpServletRequest httpServletRequest, StiReport stiReport, DataSet dataSet) throws JSONException {
        Hashtable<String, Object> hashtable = new Hashtable<String, Object>();
        JSONObject jSONObject = new JSONObject(httpServletRequest.getParameter("MvcMobileDesignerParameters"));
        hashtable.put("command", jSONObject.get("command"));
        StiReport stiReport2 = stiReport;
        if (stiReport2 == null) {
            stiReport2 = StiWebDesigner.getNewReport(jSONObject);
        }
        StiWebDesigerHandler stiWebDesigerHandler = StiWebDesigner.getHandler(httpServletRequest, jSONObject);
        stiWebDesigerHandler.onNewReportTemplate(stiReport2, httpServletRequest);
        hashtable = StiWebDesigner.getNewReportCallbackResult(hashtable, httpServletRequest, stiReport2, jSONObject);
        return new JSONObject(hashtable).toString();
    }

    public static String openReportTemplateResult(HttpServletRequest httpServletRequest) throws JSONException {
        JSONObject jSONObject = new JSONObject(httpServletRequest.getParameter("MvcMobileDesignerParameters"));
        String string = jSONObject.getString("content");
        String string2 = StiEncodingHelper.decodeString(string);
        Hashtable<String, Object> hashtable = new Hashtable<String, Object>();
        hashtable.put("command", "OpenReport");
        try {
            StiReport stiReport = StiSerializeManager.deserializeReport((InputStream)new ByteArrayInputStream(string2.getBytes("UTF-8")));
            StiWebDesigner.setupDesign(stiReport);
            StiWebDesigerHandler stiWebDesigerHandler = StiWebDesigner.getHandler(httpServletRequest, jSONObject);
            stiWebDesigerHandler.onOpenReportTemplate(stiReport, httpServletRequest);
            stiReport.getInfo().setZoom(1.0);
            String string3 = StiWebDesigner.getNewGuid();
            StiWebDesigner.saveReportObject(httpServletRequest, stiReport, string3);
            hashtable.put("reportGuid", string3);
            hashtable.put("reportObject", StiReportEdit.writeReportInObject(stiReport));
        }
        catch (Exception var5_6) {
            hashtable.put("reportGuid", JSONObject.NULL);
            hashtable.put("reportObject", JSONObject.NULL);
            var5_6.printStackTrace();
        }
        StiWebDesigner.saveArrayToCache(httpServletRequest, jSONObject.getString("undoArrayId"), new ArrayList<Object>());
        return new JSONObject(hashtable).toString();
    }

    public static String saveReportTemplateResult(HttpServletRequest httpServletRequest) throws JSONException {
        JSONObject jSONObject = new JSONObject(httpServletRequest.getParameter("MvcMobileDesignerParameters"));
        StiReport stiReport = StiWebDesigner.getReportObject(httpServletRequest, jSONObject);
        String string = jSONObject.getString("reportName");
        StiWebDesigerHandler stiWebDesigerHandler = StiWebDesigner.getHandler(httpServletRequest, jSONObject);
        stiWebDesigerHandler.onSaveReportTemplate(stiReport, string, httpServletRequest);
        Hashtable<String, String> hashtable = new Hashtable<String, String>();
        hashtable.put("command", "SaveReport");
        if (jSONObject.has("closeAction")) {
            hashtable.put("closeAction", jSONObject.getString("closeAction"));
        }
        return new JSONObject(hashtable).toString();
    }

    private static StiWebDesigerHandler getHandler(HttpServletRequest httpServletRequest, JSONObject jSONObject) throws JSONException {
        String string = jSONObject.getString("clipboardId");
        return (StiWebDesigerHandler)httpServletRequest.getSession().getAttribute(string + "webdesigner_handler");
    }

    public static Hashtable<String, Object> getReportSnapshotCallbackResult(Hashtable<String, Object> hashtable, HttpServletRequest httpServletRequest, StiReport stiReport, JSONObject jSONObject) throws StiException, IOException, SAXException, StiDeserializationException, JSONException {
        StiReportEdit.getPreviewPages(stiReport, jSONObject, hashtable);
        return hashtable;
    }

    public static Hashtable<String, Object> getNewReportCallbackResult(Hashtable<String, Object> hashtable, HttpServletRequest httpServletRequest, StiReport stiReport, JSONObject jSONObject) throws JSONException {
        String string = StiWebDesigner.getNewGuid();
        StiWebDesigner.saveReportObject(httpServletRequest, stiReport, string);
        StiWebDesigner.saveArrayToCache(httpServletRequest, jSONObject.getString("undoArrayId"), new ArrayList<Object>());
        hashtable.put("reportGuid", string);
        String string2 = jSONObject.getString("command");
        if ("CreateReport".equals(string2)) {
            hashtable.put("reportObject", StiReportEdit.writeReportInObject(stiReport));
        } else if ("GetDataSourcesForWizard".equals(string2)) {
            hashtable.put("dictionary", StiDictionaryHelper.getDictionaryTree(stiReport));
        }
        return hashtable;
    }

    private static String previewAs(StiReport stiReport, JSONObject jSONObject, HttpServletResponse httpServletResponse) throws JSONException, StiException, IOException, SAXException, StiDeserializationException {
        String string;
        block4 : {
            StiReport stiReport2 = StiReportEdit.cloneReport(stiReport);
            stiReport2.Render(false);
            stiReport2 = stiReport2.getCompiledReport() != null ? stiReport2.getCompiledReport() : stiReport2;
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            string = null;
            try {
                if ("pdf".equals(jSONObject.getString("format"))) {
                    StiExportManager.exportPdf((StiReport)stiReport2, (OutputStream)byteArrayOutputStream);
                    new StiFileResult(byteArrayOutputStream, "Report.pdf", "application/pdf", false).writeFile(httpServletResponse);
                    break block4;
                }
                StiHtmlExportSettings stiHtmlExportSettings = new StiHtmlExportSettings();
                StiHtmlExportService stiHtmlExportService = new StiHtmlExportService();
                stiHtmlExportService.exportHtml(stiReport2, (OutputStream)byteArrayOutputStream, stiHtmlExportSettings);
                string = new String(byteArrayOutputStream.toByteArray(), "UTF-8");
            }
            finally {
                byteArrayOutputStream.close();
            }
        }
        return string;
    }

    public static void previewReport(StiReport stiReport, String string, HttpServletResponse httpServletResponse) throws IOException, SAXException, StiDeserializationException, StiException {
        block4 : {
            StiReport stiReport2 = StiReportEdit.cloneReport(stiReport);
            stiReport2.Render(false);
            stiReport2 = stiReport2.getCompiledReport() != null ? stiReport2.getCompiledReport() : stiReport2;
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            try {
                if ("pdf".equals(string)) {
                    StiExportManager.exportPdf((StiReport)stiReport2, (OutputStream)byteArrayOutputStream);
                    new StiFileResult(byteArrayOutputStream, "Report.pdf", "application/pdf", true).writeFile(httpServletResponse);
                    break block4;
                }
                StiHtmlExportSettings stiHtmlExportSettings = new StiHtmlExportSettings();
                StiHtmlExportService stiHtmlExportService = new StiHtmlExportService();
                stiHtmlExportService.exportHtml(stiReport2, (OutputStream)byteArrayOutputStream, stiHtmlExportSettings);
                StiIOUtil.writeString((OutputStream)httpServletResponse.getOutputStream(), (String)new String(byteArrayOutputStream.toByteArray(), "UTF-8"));
            }
            finally {
                byteArrayOutputStream.close();
            }
        }
    }

    private static String getNewGuid() {
        return StiGuid.newGuidString().substring(0, 16);
    }

    private String getCurrentHelpLanguage() {
        return "ru".equals(StiLocalization.getLocalizationCultureName()) ? "ru" : "en";
    }

    public static StiReport getNewReport(JSONObject jSONObject) throws JSONException {
        StiReport stiReport = StiReport.newInstance();
        stiReport.setReportGuid(StiWebDesigner.getNewGuid());
        stiReport.getInfo().setForceDesigningMode(true);
        if (jSONObject != null && jSONObject.has("defaultUnit")) {
            stiReport.setReportUnit(StiReportUnitType.valueOf((String)jSONObject.getString("defaultUnit")));
        }
        ((StiPage)stiReport.getPages().get(0)).setPaperSize(StiPaperKind.Custom);
        ((StiPage)stiReport.getPages().get(0)).setPageWidth(stiReport.getUnit().ConvertFromHInches(827.0));
        ((StiPage)stiReport.getPages().get(0)).setPageHeight(stiReport.getUnit().ConvertFromHInches(1169.0));
        stiReport.getInfo().setZoom(1.0);
        return stiReport;
    }
}

