src/index.jsp
author Asier Lostalé <asier.lostale@openbravo.com>
Wed, 18 Mar 2015 10:50:25 +0100
changeset 26205 e7c1d9e51ba8
parent 23075 43e598987eb7
child 26257 6a6c882af4c9
permissions -rw-r--r--
fixed bug 29329: can't download attachments for 2 rows with same name & no ext

When trying to download at once attachemnts for different records that have the
same name and it does not have extension, it fails.

The problem is in case of duplicated names to be included within the zipped file,
a number is appended to the file name before the extension. Extesion is present
is assumed, failing if not.

Fix: don't assume file name has extension.
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
david@23075
   102
<script>
david@23075
   103
  (function () {
david@23075
   104
    var b = document.documentElement;
david@23075
   105
    b.setAttribute('data-useragent',  navigator.userAgent);
david@23075
   106
    b.setAttribute('data-platform', navigator.platform );
david@23075
   107
    b.className += ((!!('ontouchstart' in window) || !!('onmsgesturechange' in window))?' touch':'');
david@23075
   108
  }());
david@23075
   109
</script>
david@23075
   110
ivan@10243
   111
<!-- styles used during loading -->
ivan@16479
   112
<style>
ivan@10243
   113
  html, body {
ivan@10243
   114
      height: 100%;
ivan@10243
   115
      width: 100%;
ivan@10243
   116
  }
ivan@10243
   117
ivan@10243
   118
  .OBCenteredBox {
ivan@10243
   119
      position: fixed;
ivan@10243
   120
      z-index: 1000000;
ivan@10243
   121
      top: 50%;
ivan@10243
   122
      left: 50%;
ivan@10243
   123
      margin: -25px 0 0 -150px;
ivan@10243
   124
      width: 300px;
ivan@10243
   125
      height: 50px;
ivan@10243
   126
  }
ivan@10243
   127
ivan@10243
   128
  .OBLoadingPromptLabel {
ivan@10243
   129
      font-family: 'Arial';
ivan@10243
   130
      font-size: 12px;
ivan@10243
   131
      color: #ccd0d4;
ivan@10243
   132
  }
ivan@10243
   133
ivan@10243
   134
  .OBLoadingPromptModalMask {
ivan@10243
   135
      left: 0;
ivan@10243
   136
      top: 0;
ivan@10243
   137
      width: 100%;
ivan@10243
   138
      height: 100%;
ivan@10243
   139
      background-color: #7f7f7f;
ivan@10243
   140
  }
ivan@10243
   141
</style>
ivan@10243
   142
ivan@10243
   143
</head>
david@16384
   144
<body>
ivan@10243
   145
ivan@10243
   146
<!-- shows the loading div -->
ivan@10243
   147
<div class="OBLoadingPromptModalMask" id="OBLoadingDiv">
ivan@10243
   148
    <div class="OBCenteredBox">
ivan@10243
   149
        <table>
ivan@10243
   150
            <tr>
ivan@10243
   151
                <td>
ivan@10243
   152
                    <span class="OBLoadingPromptLabel">LOADING...</span>
ivan@10243
   153
                </td>
ivan@10243
   154
                <td>
martin@12927
   155
                    <img width="220" height="16" src="./web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/system/windowLoading.gif"/>
ivan@10243
   156
                </td>
ivan@10243
   157
            </tr>
ivan@10243
   158
        </table>
ivan@10243
   159
    </div>
ivan@10243
   160
</div>
ivan@10243
   161
<!-- load the rest -->
ivan@16479
   162
<script>
ivan@16865
   163
// Bootstrap error handling: Shows an alert to the user when an error occurs loading static resources
ivan@16865
   164
// This error handler gets removed at the end of static resources
ivan@16865
   165
window.onerror = function <%=KernelConstants.BOOTSTRAP_ERROR_HANDLER_NAME%> (errorMsg, url, lineNumber) {
ivan@16865
   166
  var msg = errorMsg + ' - ' + url + ':' + lineNumber;
ivan@16865
   167
  document.body.removeChild(document.getElementById('OBLoadingDiv'));
ivan@16865
   168
  alert(msg);
ivan@16865
   169
};
ivan@16865
   170
martin@15593
   171
$LAB.setGlobalDefaults({AppendTo: 'body'});
martin@15593
   172
ivan@10243
   173
var isomorphicDir='./web/org.openbravo.userinterface.smartclient/isomorphic/';
david@21907
   174
var isc = window.isc ? window.isc : {};
ivan@10243
   175
ivan@10243
   176
// starts the application is called as the last statement in the StaticResources part
ivan@15690
   177
function OBStartApplication() {
antonio@19365
   178
<%
antonio@19365
   179
//If the role has its access to the backend restricted, an error message will be shown
antonio@19365
   180
final VariablesSecureApp vars1 = new VariablesSecureApp(request, false);
antonio@19368
   181
OBContext.setAdminMode();
antonio@19368
   182
try{
antonio@19368
   183
  String roleId=vars1.getRole();
antonio@19368
   184
  Role role;
antonio@19368
   185
  if(roleId==null || roleId.equals("")){
antonio@19368
   186
    role=OBDal.getInstance().get(User.class, userId).getDefaultRole();
antonio@19368
   187
  }else{
antonio@19368
   188
    role = OBDal.getInstance().get(Role.class, vars1.getRole());
antonio@19368
   189
  }
antonio@20499
   190
if(role !=null && role.isRestrictbackend()){
antonio@19365
   191
%>
antonio@19365
   192
  document.body.removeChild(document.getElementById('OBLoadingDiv'));
antonio@19365
   193
  isc.Dialog.create({message: OB.I18N.getLabel('OBUIAPP_RestrictedUser'), title: OB.I18N.getLabel('OBUIAPP_RestrictedUserTitle'), showCloseButton: false}).show();
antonio@19365
   194
  return;
antonio@19365
   195
<%
antonio@19365
   196
}
antonio@19368
   197
 }finally{
antonio@19368
   198
  OBContext.restorePreviousMode();
antonio@19368
   199
}
antonio@19365
   200
%>
martin@12948
   201
  OB.Layout.initialize();
ivan@10243
   202
  OB.Layout.draw();
ivan@10243
   203
  OB.Layout.ViewManager.createAddStartTab();
ivan@10243
   204
  // get rid of the loading stuff
ivan@10243
   205
  document.body.removeChild(document.getElementById('OBLoadingDiv'));
ivan@10243
   206
  OB.GlobalHiddenForm = document.forms.OBGlobalHiddenForm;
ivan@13342
   207
<%
ivan@13342
   208
  if (session.getAttribute("STARTUP-MESSAGE") != null) {
ivan@13342
   209
    String text = (String) session.getAttribute("STARTUP-MESSAGE");
ivan@13342
   210
    String title = (String) session.getAttribute("STARTUP-MESSAGE-TITLE");
ivan@13342
   211
    session.removeAttribute("STARTUP-MESSAGE");
ivan@13342
   212
    session.removeAttribute("STARTUP-MESSAGE-TITLE");
ivan@13342
   213
%>
ivan@13342
   214
  isc.say('<%=text%>', null, {title: '<%=title%>'});
ivan@13342
   215
<%
ivan@13342
   216
  }
ivan@13342
   217
%>
ivan@10243
   218
}
ivan@10243
   219
</script>
ivan@16479
   220
<script src="./web/org.openbravo.userinterface.smartclient/isomorphic/ISC_Combined<%=(uncompSC ? ".uncompressed" : "")%>.js"></script>
ivan@16479
   221
<script src="./web/org.openbravo.userinterface.smartclient/isomorphic/ISC_History<%=(uncompSC ? ".uncompressed" : "")%>.js"></script>
ivan@16865
   222
<script src="./org.openbravo.client.kernel/OBCLKER_Kernel/StaticResources?_appName=OB3&_skinVersion=Default"></script>
ivan@11956
   223
<iframe name="background_target" id="background_target" height="0" width="0" style="display:none;"></iframe>
antonio@11954
   224
<form name="OBGlobalHiddenForm" method="post" action="blank.html" target="background_target">
antonio@11344
   225
</form>
ivan@10243
   226
</body>
ivan@14579
   227
</html>