src/index.jsp
author RM packaging bot <staff.rm@openbravo.com>
Thu, 13 Mar 2014 10:13:41 +0000
changeset 22702 83952b65ffe7
parent 22281 b2f7d8ccc2c3
child 23075 43e598987eb7
permissions -rw-r--r--
CI: merge back from main
antonio@19365
     1
ivan@10243
     2
<%@ page import="java.util.Properties" %>
ivan@10243
     3
<%@ page import="org.openbravo.base.HttpBaseServlet" %>
martin@13190
     4
<%@ page import="org.openbravo.dal.core.OBContext"%>
ivan@10243
     5
<%@ page import="org.openbravo.base.util.OBClassLoader" %>
ivan@10243
     6
<%@ page import="org.openbravo.authentication.AuthenticationManager" %>
david@16048
     7
<%@ page import="org.openbravo.client.kernel.KernelUtils" %>
ivan@16865
     8
<%@ page import="org.openbravo.client.kernel.KernelConstants" %>
david@16048
     9
<%@ page import="org.openbravo.dal.core.OBContext" %>
david@16048
    10
<%@ page import="org.openbravo.model.ad.module.Module" %>
stefan@12524
    11
<%@ page import="org.apache.log4j.Logger" %>
antonio@19365
    12
<%@ page import="org.openbravo.model.ad.access.Role" %>
antonio@19368
    13
<%@ page import="org.openbravo.model.ad.access.User" %>
antonio@19365
    14
<%@ page import="org.openbravo.dal.service.OBDal" %>
antonio@19365
    15
<%@ page import="org.openbravo.base.secureApp.VariablesSecureApp" %>
ivan@10243
    16
<%@ page contentType="text/html; charset=UTF-8" %>
ivan@10243
    17
<%
ivan@13719
    18
  /*
ivan@10243
    19
 *************************************************************************
ivan@10243
    20
 * The contents of this file are subject to the Openbravo  Public  License
ivan@10243
    21
 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
ivan@10243
    22
 * Version 1.1  with a permitted attribution clause; you may not  use this
ivan@10243
    23
 * file except in compliance with the License. You  may  obtain  a copy of
ivan@10243
    24
 * the License at http://www.openbravo.com/legal/license.html 
ivan@10243
    25
 * Software distributed under the License  is  distributed  on  an "AS IS"
ivan@10243
    26
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
ivan@10243
    27
 * License for the specific  language  governing  rights  and  limitations
ivan@10243
    28
 * under the License. 
ivan@10243
    29
 * The Original Code is Openbravo ERP. 
ivan@10243
    30
 * The Initial Developer of the Original Code is Openbravo SLU 
david@21897
    31
 * All portions are Copyright (C) 2011-2014 Openbravo SLU
ivan@10243
    32
 * All Rights Reserved. 
martin@15614
    33
 * Contributor(s):  ______________________________________.
ivan@10243
    34
 ************************************************************************
ivan@10243
    35
 */
stefan@12524
    36
stefan@12524
    37
Logger log = Logger.getLogger(org.openbravo.authentication.AuthenticationManager.class); 
ivan@10243
    38
ivan@16797
    39
AuthenticationManager authManager = AuthenticationManager.getAuthenticationManager(this);
ivan@10243
    40
ivan@10243
    41
String userId = authManager.authenticate(request, response);
ivan@16797
    42
ivan@10243
    43
if(userId == null){
ivan@10243
    44
  return;
ivan@10243
    45
}
david@11337
    46
david@16048
    47
boolean uncompSC = false;
david@16052
    48
String scDevModulePackage = "org.openbravo.userinterface.smartclient.dev";
david@16048
    49
OBContext.setAdminMode();
david@16048
    50
try {
david@16048
    51
  if (KernelUtils.getInstance().isModulePresent(scDevModulePackage)) {
david@16048
    52
    uncompSC = KernelUtils.getInstance().getModule(scDevModulePackage).isInDevelopment();
david@16048
    53
  }
david@16048
    54
} catch (Exception e) {
david@16052
    55
  log.error("Error trying to acquire module \"" + scDevModulePackage + "\": " + e.getMessage(), e);
david@16048
    56
} finally {
david@16048
    57
  OBContext.restorePreviousMode();
david@16048
    58
}
david@16048
    59
david@11337
    60
String ua = request.getHeader( "User-Agent" );
david@11337
    61
boolean isMSIE = ( ua != null && ua.indexOf( "MSIE" ) != -1 );
david@11337
    62
int verMSIE = 0;
david@11337
    63
String verMSIEtmp = "";
david@11337
    64
if (isMSIE) {
david@11337
    65
  verMSIEtmp = ua.substring(ua.indexOf("MSIE") + 5);
david@11337
    66
  verMSIEtmp = verMSIEtmp.substring(0, verMSIEtmp.indexOf("."));
david@11337
    67
  if (ua.indexOf("MSIE 7.0") != -1 && ua.indexOf("Trident/4") != -1) {
david@11337
    68
    //In case IE8 runs in "IE8 Compatibility mode, look for Trident/4.0 to know that is IE8 although MSIE string is MSIE 7.0
david@11337
    69
    verMSIEtmp = "8";
david@11337
    70
  } else if (ua.indexOf("MSIE 7.0") != -1 && ua.indexOf("Trident/5") != -1) {
david@11337
    71
    // In case IE9 runs in "IE8 Compatibility mode, look for Trident/5.0 to know that is IE9 although MSIE string is MSIE 7.0
david@11337
    72
    verMSIEtmp = "9";
david@11337
    73
  } else if (ua.indexOf("MSIE 7.0") != -1 && ua.indexOf("Trident/") != -1) {
david@11337
    74
    // For hypothetic future IE versions in case IEX runs in "IEX Compatibility mode, look for Trident/ to know that is IEX although MSIE string is MSIE 7.0
david@11337
    75
    verMSIEtmp = "10"; //If this 'if' statement is not updated, could be 10 or 11 or anything... but set 10 just to ensure it is not in IE7
david@11337
    76
  }
david@11337
    77
  verMSIE = Integer.parseInt(verMSIEtmp);
david@11337
    78
}
martin@15540
    79
response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
martin@15540
    80
response.addHeader("Pragma", "no-cache");
martin@15540
    81
response.addHeader("Expires", "0");
ivan@10243
    82
%>
david@16334
    83
<!DOCTYPE html>
ivan@10243
    84
david@16384
    85
<html dir="<%=(OBContext.isRightToLeft() ? "RTL" : "LTR")%>">
david@10938
    86
<head>
ivan@10243
    87
<meta http-equiv="Expires" content="Tue, 24 Apr 1979 00:00:01 GMT"/>
ivan@10243
    88
<meta http-equiv="Content-type" content="text/html;charset=utf-8"/>
martin@15539
    89
<meta http-equiv="Cache-Control" content="no-cache no-store must-revalidate" >
ivan@10243
    90
<meta http-equiv="Pragma" content="no-cache" >
ivan@10243
    91
<meta name="author" content="Openbravo S.L.U.">
ivan@10243
    92
<meta name="keywords" content="openbravo">
ivan@10243
    93
<meta name="description" content="Openbravo S.L.U.">
ivan@10257
    94
<link rel="shortcut icon" href="./web/images/favicon.ico" />
ivan@16865
    95
<link rel="stylesheet" type="text/css" href="./org.openbravo.client.kernel/OBCLKER_Kernel/StyleSheetResources?_appName=OB3&_skinVersion=Default&_cssDataUri=<%=(!isMSIE || (isMSIE && verMSIE >=8))%>"/>
david@11337
    96
ivan@10243
    97
<title>Openbravo</title>
ivan@16479
    98
<script src="./web/org.openbravo.client.kernel/js/scopeleaks.min.js"></script>
ivan@16479
    99
<script src="./web/org.openbravo.client.kernel/js/LAB.min.js"></script>
ivan@16479
   100
<script src="./web/org.openbravo.client.kernel/js/BigDecimal-all-1.0.1.min.js"></script>
david@11337
   101
ivan@10243
   102
<!-- styles used during loading -->
ivan@16479
   103
<style>
ivan@10243
   104
  html, body {
ivan@10243
   105
      height: 100%;
ivan@10243
   106
      width: 100%;
ivan@10243
   107
  }
ivan@10243
   108
ivan@10243
   109
  .OBCenteredBox {
ivan@10243
   110
      position: fixed;
ivan@10243
   111
      z-index: 1000000;
ivan@10243
   112
      top: 50%;
ivan@10243
   113
      left: 50%;
ivan@10243
   114
      margin: -25px 0 0 -150px;
ivan@10243
   115
      width: 300px;
ivan@10243
   116
      height: 50px;
ivan@10243
   117
  }
ivan@10243
   118
ivan@10243
   119
  .OBLoadingPromptLabel {
ivan@10243
   120
      font-family: 'Arial';
ivan@10243
   121
      font-size: 12px;
ivan@10243
   122
      color: #ccd0d4;
ivan@10243
   123
  }
ivan@10243
   124
ivan@10243
   125
  .OBLoadingPromptModalMask {
ivan@10243
   126
      left: 0;
ivan@10243
   127
      top: 0;
ivan@10243
   128
      width: 100%;
ivan@10243
   129
      height: 100%;
ivan@10243
   130
      background-color: #7f7f7f;
ivan@10243
   131
  }
ivan@10243
   132
</style>
ivan@10243
   133
ivan@10243
   134
</head>
david@16384
   135
<body>
ivan@10243
   136
ivan@10243
   137
<!-- shows the loading div -->
ivan@10243
   138
<div class="OBLoadingPromptModalMask" id="OBLoadingDiv">
ivan@10243
   139
    <div class="OBCenteredBox">
ivan@10243
   140
        <table>
ivan@10243
   141
            <tr>
ivan@10243
   142
                <td>
ivan@10243
   143
                    <span class="OBLoadingPromptLabel">LOADING...</span>
ivan@10243
   144
                </td>
ivan@10243
   145
                <td>
martin@12927
   146
                    <img width="220" height="16" src="./web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/system/windowLoading.gif"/>
ivan@10243
   147
                </td>
ivan@10243
   148
            </tr>
ivan@10243
   149
        </table>
ivan@10243
   150
    </div>
ivan@10243
   151
</div>
ivan@10243
   152
<!-- load the rest -->
ivan@16479
   153
<script>
ivan@16865
   154
// Bootstrap error handling: Shows an alert to the user when an error occurs loading static resources
ivan@16865
   155
// This error handler gets removed at the end of static resources
ivan@16865
   156
window.onerror = function <%=KernelConstants.BOOTSTRAP_ERROR_HANDLER_NAME%> (errorMsg, url, lineNumber) {
ivan@16865
   157
  var msg = errorMsg + ' - ' + url + ':' + lineNumber;
ivan@16865
   158
  document.body.removeChild(document.getElementById('OBLoadingDiv'));
ivan@16865
   159
  alert(msg);
ivan@16865
   160
};
ivan@16865
   161
martin@15593
   162
$LAB.setGlobalDefaults({AppendTo: 'body'});
martin@15593
   163
ivan@10243
   164
var isomorphicDir='./web/org.openbravo.userinterface.smartclient/isomorphic/';
david@21907
   165
var isc = window.isc ? window.isc : {};
ivan@10243
   166
ivan@10243
   167
// starts the application is called as the last statement in the StaticResources part
ivan@15690
   168
function OBStartApplication() {
antonio@19365
   169
<%
antonio@19365
   170
//If the role has its access to the backend restricted, an error message will be shown
antonio@19365
   171
final VariablesSecureApp vars1 = new VariablesSecureApp(request, false);
antonio@19368
   172
OBContext.setAdminMode();
antonio@19368
   173
try{
antonio@19368
   174
  String roleId=vars1.getRole();
antonio@19368
   175
  Role role;
antonio@19368
   176
  if(roleId==null || roleId.equals("")){
antonio@19368
   177
    role=OBDal.getInstance().get(User.class, userId).getDefaultRole();
antonio@19368
   178
  }else{
antonio@19368
   179
    role = OBDal.getInstance().get(Role.class, vars1.getRole());
antonio@19368
   180
  }
antonio@20499
   181
if(role !=null && role.isRestrictbackend()){
antonio@19365
   182
%>
antonio@19365
   183
  document.body.removeChild(document.getElementById('OBLoadingDiv'));
antonio@19365
   184
  isc.Dialog.create({message: OB.I18N.getLabel('OBUIAPP_RestrictedUser'), title: OB.I18N.getLabel('OBUIAPP_RestrictedUserTitle'), showCloseButton: false}).show();
antonio@19365
   185
  return;
antonio@19365
   186
<%
antonio@19365
   187
}
antonio@19368
   188
 }finally{
antonio@19368
   189
  OBContext.restorePreviousMode();
antonio@19368
   190
}
antonio@19365
   191
%>
martin@12948
   192
  OB.Layout.initialize();
ivan@10243
   193
  OB.Layout.draw();
ivan@10243
   194
  OB.Layout.ViewManager.createAddStartTab();
ivan@10243
   195
  // get rid of the loading stuff
ivan@10243
   196
  document.body.removeChild(document.getElementById('OBLoadingDiv'));
ivan@10243
   197
  OB.GlobalHiddenForm = document.forms.OBGlobalHiddenForm;
ivan@13342
   198
<%
ivan@13342
   199
  if (session.getAttribute("STARTUP-MESSAGE") != null) {
ivan@13342
   200
    String text = (String) session.getAttribute("STARTUP-MESSAGE");
ivan@13342
   201
    String title = (String) session.getAttribute("STARTUP-MESSAGE-TITLE");
ivan@13342
   202
    session.removeAttribute("STARTUP-MESSAGE");
ivan@13342
   203
    session.removeAttribute("STARTUP-MESSAGE-TITLE");
ivan@13342
   204
%>
ivan@13342
   205
  isc.say('<%=text%>', null, {title: '<%=title%>'});
ivan@13342
   206
<%
ivan@13342
   207
  }
ivan@13342
   208
%>
ivan@10243
   209
}
ivan@10243
   210
</script>
ivan@16479
   211
<script src="./web/org.openbravo.userinterface.smartclient/isomorphic/ISC_Combined<%=(uncompSC ? ".uncompressed" : "")%>.js"></script>
ivan@16479
   212
<script src="./web/org.openbravo.userinterface.smartclient/isomorphic/ISC_History<%=(uncompSC ? ".uncompressed" : "")%>.js"></script>
ivan@16865
   213
<script src="./org.openbravo.client.kernel/OBCLKER_Kernel/StaticResources?_appName=OB3&_skinVersion=Default"></script>
ivan@11956
   214
<iframe name="background_target" id="background_target" height="0" width="0" style="display:none;"></iframe>
antonio@11954
   215
<form name="OBGlobalHiddenForm" method="post" action="blank.html" target="background_target">
antonio@11344
   216
</form>
ivan@10243
   217
</body>
ivan@14579
   218
</html>