Subversion Repositories SmartDukaan

Rev

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

Rev 25429 Rev 25430
Line 173... Line 173...
173
		}
173
		}
174
		// Remove header
174
		// Remove header
175
		records.remove(0);
175
		records.remove(0);
176
		List<ContentPojo> returnList = new ArrayList<ContentPojo>();
176
		List<ContentPojo> returnList = new ArrayList<ContentPojo>();
177
		for (CSVRecord record : records) {
177
		for (CSVRecord record : records) {
-
 
178
			ContentPojo cp = null;
-
 
179
			Long entityId = Long.parseLong(record.get(Entity_Id));
178
			try {
180
			try {
-
 
181
				cp = mongoClient.getEntityById(entityId);
-
 
182
			} catch (Exception e) {
-
 
183
			}
-
 
184
			try {
-
 
185
				if (cp == null) {
179
				ContentPojo cp = new ContentPojo(Long.parseLong(record.get(Entity_Id)));
186
					cp = new ContentPojo(entityId);
-
 
187
				}
180
				cp.setWarranty(record.get(Warranty));
188
				cp.setWarranty(record.get(Warranty));
181
				cp.setKeySpecs(Arrays
189
				cp.setKeySpecs(Arrays
182
						.asList(record.get(KeySpec1), record.get(KeySpec2), record.get(KeySpec3), record.get(KeySpec4))
190
						.asList(record.get(KeySpec1), record.get(KeySpec2), record.get(KeySpec3), record.get(KeySpec4))
183
						.stream().filter(x -> x != null && !x.equals("")).collect(Collectors.toList()));
191
						.stream().filter(x -> x != null && !x.equals("")).collect(Collectors.toList()));
184
				cp.setPackageContents(Arrays.asList(record.get(Package_Contents).split(",")));
192
				cp.setPackageContents(Arrays.asList(record.get(Package_Contents).split(",")));
Line 331... Line 339...
331
			// convert base64 string to binary data
339
			// convert base64 string to binary data
332
			byte[] data = DatatypeConverter.parseBase64Binary(strings[1]);
340
			byte[] data = DatatypeConverter.parseBase64Binary(strings[1]);
333
			String fileName = getFileName(entityMediaPojo.getEntityId(), mediaPojo.getTitle(), extension);
341
			String fileName = getFileName(entityMediaPojo.getEntityId(), mediaPojo.getTitle(), extension);
334
			LOGGER.info("After switch statement Filename = {}", fileName);
342
			LOGGER.info("After switch statement Filename = {}", fileName);
335
			mediaPojo.setImageData(null);
343
			mediaPojo.setImageData(null);
336
			String staticServerUrl = String.format(STATIC_SERVER_URL, entityMediaPojo.getEntityId()%3);
344
			String staticServerUrl = String.format(STATIC_SERVER_URL, entityMediaPojo.getEntityId() % 3);
337
			mediaPojo.setUrl(staticServerUrl + entityMediaPojo.getEntityId() + "/" + fileName);
345
			mediaPojo.setUrl(staticServerUrl + entityMediaPojo.getEntityId() + "/" + fileName);
338
			map.put(fileName, new ByteArrayInputStream(data));
346
			map.put(fileName, new ByteArrayInputStream(data));
339
			if (i == entityMediaPojo.getDefaultImageIndex()) {
347
			if (i == entityMediaPojo.getDefaultImageIndex()) {
340
				String defaultFileName = getFileName(entityMediaPojo.getEntityId(), DEFAULT, extension);
348
				String defaultFileName = getFileName(entityMediaPojo.getEntityId(), DEFAULT, extension);
341
				map.put(defaultFileName, new ByteArrayInputStream(data));
349
				map.put(defaultFileName, new ByteArrayInputStream(data));