Subversion Repositories SmartDukaan

Rev

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

Rev 35894 Rev 35923
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
-
 
3
import com.google.gson.Gson;
3
import com.jcraft.jsch.*;
4
import com.jcraft.jsch.*;
4
import com.spice.profitmandi.common.enumuration.MessageType;
5
import com.spice.profitmandi.common.enumuration.MessageType;
5
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
6
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
6
import com.spice.profitmandi.common.model.CustomRetailer;
7
import com.spice.profitmandi.common.model.CustomRetailer;
7
import com.spice.profitmandi.common.model.ProfitMandiConstants;
8
import com.spice.profitmandi.common.model.ProfitMandiConstants;
Line 14... Line 15...
14
import com.spice.profitmandi.dao.enumuration.catalog.ItemCriteriaType;
15
import com.spice.profitmandi.dao.enumuration.catalog.ItemCriteriaType;
15
import com.spice.profitmandi.dao.enumuration.catalog.OfferSchemeType;
16
import com.spice.profitmandi.dao.enumuration.catalog.OfferSchemeType;
16
import com.spice.profitmandi.dao.model.CreateOfferRequest;
17
import com.spice.profitmandi.dao.model.CreateOfferRequest;
17
import com.spice.profitmandi.dao.model.ItemCriteriaPayout;
18
import com.spice.profitmandi.dao.model.ItemCriteriaPayout;
18
import com.spice.profitmandi.dao.model.TodayOfferModel;
19
import com.spice.profitmandi.dao.model.TodayOfferModel;
-
 
20
import com.spice.profitmandi.dao.repository.catalog.CatalogRepository;
19
import com.spice.profitmandi.dao.repository.catalog.*;
21
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
-
 
22
import com.spice.profitmandi.dao.repository.catalog.OfferMarginRepository;
-
 
23
import com.spice.profitmandi.dao.repository.catalog.OfferRepository;
20
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
24
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
21
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
25
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
22
import com.spice.profitmandi.service.NotificationService;
26
import com.spice.profitmandi.service.NotificationService;
23
import com.spice.profitmandi.service.authentication.RoleManager;
27
import com.spice.profitmandi.service.authentication.RoleManager;
24
import com.spice.profitmandi.service.catalog.BrandsService;
28
import com.spice.profitmandi.service.catalog.BrandsService;
25
import com.spice.profitmandi.service.offers.ItemCriteria;
29
import com.spice.profitmandi.service.offers.ItemCriteria;
26
import com.spice.profitmandi.service.offers.OfferService;
30
import com.spice.profitmandi.service.offers.OfferService;
-
 
31
import com.spice.profitmandi.service.offers.PartnerCriteria;
27
import com.spice.profitmandi.service.offers.TodayOfferService;
32
import com.spice.profitmandi.service.offers.TodayOfferService;
28
import com.spice.profitmandi.service.user.RetailerService;
33
import com.spice.profitmandi.service.user.RetailerService;
29
import com.spice.profitmandi.web.model.LoginDetails;
34
import com.spice.profitmandi.web.model.LoginDetails;
30
import com.spice.profitmandi.web.util.CookiesProcessor;
35
import com.spice.profitmandi.web.util.CookiesProcessor;
31
import com.spice.profitmandi.web.util.MVCResponseSender;
36
import com.spice.profitmandi.web.util.MVCResponseSender;
32
import org.apache.commons.io.FileUtils;
37
import org.apache.commons.io.FileUtils;
33
import org.apache.commons.io.output.ByteArrayOutputStream;
38
import org.apache.commons.io.output.ByteArrayOutputStream;
34
import org.apache.logging.log4j.LogManager;
39
import org.apache.logging.log4j.LogManager;
35
import org.apache.logging.log4j.Logger;
40
import org.apache.logging.log4j.Logger;
36
import com.google.gson.Gson;
-
 
37
import com.spice.profitmandi.service.offers.PartnerCriteria;
-
 
38
import org.springframework.beans.factory.annotation.Autowired;
41
import org.springframework.beans.factory.annotation.Autowired;
39
import org.springframework.cache.interceptor.SimpleKey;
-
 
40
import org.springframework.beans.factory.annotation.Value;
42
import org.springframework.beans.factory.annotation.Value;
41
import org.springframework.cache.CacheManager;
43
import org.springframework.cache.CacheManager;
-
 
44
import org.springframework.cache.interceptor.SimpleKey;
42
import org.springframework.core.io.InputStreamResource;
45
import org.springframework.core.io.InputStreamResource;
43
import org.springframework.http.HttpHeaders;
46
import org.springframework.http.HttpHeaders;
44
import org.springframework.http.HttpStatus;
47
import org.springframework.http.HttpStatus;
45
import org.springframework.http.ResponseEntity;
48
import org.springframework.http.ResponseEntity;
46
import org.springframework.mock.web.MockHttpServletRequest;
49
import org.springframework.mock.web.MockHttpServletRequest;
Line 64... Line 67...
64
import java.io.InputStream;
67
import java.io.InputStream;
65
import java.time.Instant;
68
import java.time.Instant;
66
import java.time.LocalDate;
69
import java.time.LocalDate;
67
import java.time.LocalDateTime;
70
import java.time.LocalDateTime;
68
import java.time.YearMonth;
71
import java.time.YearMonth;
69
import java.util.List;
-
 
70
import java.util.*;
72
import java.util.*;
-
 
73
import java.util.List;
71
import java.util.stream.Collectors;
74
import java.util.stream.Collectors;
72
 
75
 
73
@Controller
76
@Controller
74
@Transactional(rollbackFor = Throwable.class)
77
@Transactional(rollbackFor = Throwable.class)
75
public class OfferController {
78
public class OfferController {
Line 377... Line 380...
377
        this.fileUpload(channelSftp, fileStreamsMap, IMAGE_REMOTE_DIR + "");
380
        this.fileUpload(channelSftp, fileStreamsMap, IMAGE_REMOTE_DIR + "");
378
        channelSftp.exit();
381
        channelSftp.exit();
379
    }
382
    }
380
 
383
 
381
    private InputStream getImageBuffer(String html) throws Exception {
384
    private InputStream getImageBuffer(String html) throws Exception {
-
 
385
        // Sanitize HTML to valid XHTML for Flying Saucer (Java2DRenderer requires well-formed XML)
-
 
386
        org.jsoup.nodes.Document doc = org.jsoup.Jsoup.parse(html);
-
 
387
        doc.outputSettings().syntax(org.jsoup.nodes.Document.OutputSettings.Syntax.xml);
-
 
388
        doc.outputSettings().escapeMode(org.jsoup.nodes.Entities.EscapeMode.xhtml);
-
 
389
        doc.outputSettings().charset("UTF-8");
-
 
390
        html = doc.html();
382
 
391
 
383
        String fileName = "/tmp/" + Instant.now().toEpochMilli();
392
        String fileName = "/tmp/" + Instant.now().toEpochMilli();
384
        FileUtils.writeStringToFile(new File(fileName), html, "UTF-8");
393
        FileUtils.writeStringToFile(new File(fileName), html, "UTF-8");
385
        String address = "file:" + fileName;
394
        String address = "file:" + fileName;
386
        Java2DRenderer renderer = new Java2DRenderer(address, 400);
395
        Java2DRenderer renderer = new Java2DRenderer(address, 400);