Subversion Repositories SmartDukaan

Rev

Rev 3062 | Rev 3125 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3062 Rev 3105
Line 66... Line 66...
66
			in.shop2020.utils.HelperService.Client client = helperServiceClient.getClient();
66
			in.shop2020.utils.HelperService.Client client = helperServiceClient.getClient();
67
			LogisticsUser user = client.authenticateLogisticsUser(username, password);
67
			LogisticsUser user = client.authenticateLogisticsUser(username, password);
68
			session.setAttribute("username", user.getUsername());
68
			session.setAttribute("username", user.getUsername());
69
			session.setAttribute("providerId", Long.valueOf(user.getProviderId()));
69
			session.setAttribute("providerId", Long.valueOf(user.getProviderId()));
70
		}catch(Exception e){
70
		}catch(Exception e){
71
			e.printStackTrace();
71
			logger.error("Error authenticating the user " + username, e);
72
			return "authfail";
72
			return "authfail";
73
		}
73
		}
74
		return "authsuccess";
74
		return "authsuccess";
75
	}
75
	}
76
	
76
	
Line 83... Line 83...
83
			try {
83
			try {
84
	            isCod = Boolean.parseBoolean(request.getParameter("isCod"));
84
	            isCod = Boolean.parseBoolean(request.getParameter("isCod"));
85
	        } catch (Exception e) {
85
	        } catch (Exception e) {
86
	            isCod = false;
86
	            isCod = false;
87
	        }
87
	        }
88
			System.out.println("Warehouse Id is:  " + warehouseId);
88
			logger.info("Download request for " + (isCod ? "COD" : "Prepaid") + " Courier Details report of warehouse Id: " + warehouseId + " and provider Id:" + providerId);
89
			System.out.println("Provider Id is: " + providerId);
-
 
90
			
89
			
91
			String deliveryType = "prepaid";
90
			String deliveryType = "prepaid";
92
			if(isCod)
91
			if(isCod)
93
			    deliveryType = "cod";
92
			    deliveryType = "cod";
94
			
93
			
Line 116... Line 115...
116
		}catch(NumberFormatException nfe){
115
		}catch(NumberFormatException nfe){
117
			logger.error("Unable to parse the warehouse id", nfe);
116
			logger.error("Unable to parse the warehouse id", nfe);
118
		}
117
		}
119
		return "authfail";
118
		return "authfail";
120
	}
119
	}
121
	
120
 
-
 
121
    /**
-
 
122
     * Sets the daysToSubtract to -2 and then invokes the standard show() handler.
-
 
123
     * Should be used to view day before yesterday's courier details report.
-
 
124
     * 
-
 
125
     * @return the same string tokens as show
-
 
126
     */
122
	public String dayBefore(){
127
	public String dayBefore(){
123
		daysToSubtract = -2;
128
		daysToSubtract = -2;
124
		return show();
129
		return show();
125
	}
130
	}
126
	
131
 
-
 
132
    /**
-
 
133
     * Sets the daysToSubtract to -1 and then invokes the standard show()
-
 
134
     * handler. Should be used to view yesterday's courier details report.
-
 
135
     * 
-
 
136
     * @return the same string tokens as show
-
 
137
     */
127
	public String yesterday(){
138
	public String yesterday(){
128
		daysToSubtract = -1;
139
		daysToSubtract = -1;
129
		return show();
140
		return show();
130
	}
141
	}
131
	
142
 
-
 
143
    /**
-
 
144
     * Sets the daysToSubtract to 0 and then invokes the standard show()
-
 
145
     * handler. Should be used to view today's courier details report.
-
 
146
     * 
-
 
147
     * @return the same string tokens as show
-
 
148
     */
132
	public String today(){
149
	public String today(){
133
		daysToSubtract = 0;
150
		daysToSubtract = 0;
134
		return show();
151
		return show();
135
	}
152
	}
136
	
153
	
-
 
154
    /**
-
 
155
     * Reads a file and converts its contents to a byte array.
-
 
156
     * 
-
 
157
     * @param file
-
 
158
     *            Name of the file to process
137
	// Returns the contents of the file in a byte array.
159
     * @return the contents of the file in a byte array.
-
 
160
     * @throws IOException
-
 
161
     *             if the file could not be found or read or is too big to
-
 
162
     *             convert to a byte array.
-
 
163
     */
138
	public static byte[] getBytesFromFile(File file) throws IOException {
164
	private static byte[] getBytesFromFile(File file) throws IOException {
139
	    FileInputStream is = new FileInputStream(file);
165
	    FileInputStream is = new FileInputStream(file);
140
	    
166
	    
141
	    // Get the size of the file
167
	    // Get the size of the file
142
	    long length = file.length();
168
	    long length = file.length();
143
 
169
 
Line 145... Line 171...
145
	    // It needs to be an int type.
171
	    // It needs to be an int type.
146
	    // Before converting to an int type, check
172
	    // Before converting to an int type, check
147
	    // to ensure that file is not larger than Integer.MAX_VALUE.
173
	    // to ensure that file is not larger than Integer.MAX_VALUE.
148
	    if (length > Integer.MAX_VALUE) {
174
	    if (length > Integer.MAX_VALUE) {
149
	        // File is too large
175
	        // File is too large
-
 
176
	        throw new IOException(file.getName() + " is too large to stream");
150
	    }
177
	    }
151
 
178
 
152
	    // Create the byte array to hold the data
179
	    // Create the byte array to hold the data
153
	    byte[] bytes = new byte[(int)length];
180
	    byte[] bytes = new byte[(int)length];
154
 
181
 
Line 195... Line 222...
195
	}
222
	}
196
	
223
	
197
	public String getSessionUserName(){
224
	public String getSessionUserName(){
198
		return (String) session.getAttribute("username");
225
		return (String) session.getAttribute("username");
199
	}
226
	}
200
	
227
 
-
 
228
    /**
-
 
229
     * Gets the list of all warehouses and maps the warehouse ids to their
-
 
230
     * display name.
-
 
231
     * 
-
 
232
     * @return the mapping of warehouse if to its display namee
-
 
233
     */
201
	public Map<Long, String> getWarehouses(){
234
	public Map<Long, String> getWarehouses(){
202
		Map<Long, String> warehouseMap = new HashMap<Long, String>();
235
		Map<Long, String> warehouseMap = new HashMap<Long, String>();
203
		try{
236
		try{
204
			CatalogServiceClient csc = new CatalogServiceClient();
237
			CatalogServiceClient csc = new CatalogServiceClient();
205
			in.shop2020.model.v1.catalog.InventoryService.Client catalogClient= csc.getClient();
238
			in.shop2020.model.v1.catalog.InventoryService.Client catalogClient= csc.getClient();
206
			List<Warehouse> warehouses = catalogClient.getAllWarehouses(true);
239
			List<Warehouse> warehouses = catalogClient.getAllWarehouses(true);
207
			for(Warehouse warehouse : warehouses){
240
			for(Warehouse warehouse : warehouses){
208
				warehouseMap.put(warehouse.getId(), warehouse.getDisplayName());
241
				warehouseMap.put(warehouse.getId(), warehouse.getDisplayName());
209
			}
242
			}
210
		}catch(Exception e){
243
		}catch(Exception e){
211
			e.printStackTrace();
244
			logger.error("Error getting the list of warehouses", e);
212
		}
245
		}
213
		return warehouseMap;
246
		return warehouseMap;
214
	}
247
	}
215
 
248
 
216
	public String getServletContextPath(){
249
	public String getServletContextPath(){