Subversion Repositories SmartDukaan

Rev

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

Rev 2489 Rev 2498
Line 622... Line 622...
622
        // else move forward with update.
622
        // else move forward with update.
623
        if(errMsg != null) {
623
        if(errMsg != null) {
624
            return errMsg;
624
            return errMsg;
625
        }
625
        }
626
        try{
626
        try{
627
            /*CatalogServiceClient catalogServiceClient_Prod = new CatalogServiceClient(CatalogServiceClient.class.getSimpleName(), 
627
            CatalogServiceClient catalogServiceClient_Prod = new CatalogServiceClient(CatalogServiceClient.class.getSimpleName(), 
628
                    ConfigClientKeys.catalog_service_server_host_prod.toString(),
628
                    ConfigClientKeys.catalog_service_server_host_prod.toString(),
629
                    ConfigClientKeys.catalog_service_server_port.toString());*/
629
                    ConfigClientKeys.catalog_service_server_port.toString());
630
            
630
            
631
            //for testing, put catalog_service_server_port_test in shop2020.cfg
631
            //for testing, put catalog_service_server_port_test in shop2020.cfg
632
            CatalogServiceClient catalogServiceClient_Prod = new CatalogServiceClient(CatalogServiceClient.class.getSimpleName(), 
632
            /*CatalogServiceClient catalogServiceClient_Prod = new CatalogServiceClient(CatalogServiceClient.class.getSimpleName(), 
633
                    ConfigClientKeys.catalog_service_server_host.toString(), "catalog_service_server_port_test");
633
                    ConfigClientKeys.catalog_service_server_host.toString(), "catalog_service_server_port_test");*/
634
            
634
            
635
            InventoryService.Client catalogClient_Prod = catalogServiceClient_Prod.getClient();
635
            InventoryService.Client catalogClient_Prod = catalogServiceClient_Prod.getClient();
636
 
636
 
637
            in.shop2020.model.v1.catalog.Item tItem = catalogClient_Prod.getItem(item.getId());
637
            in.shop2020.model.v1.catalog.Item tItem = catalogClient_Prod.getItem(item.getId());
638
            
638
            
Line 720... Line 720...
720
     *   <br>otherwise error message to be passed to the client side for showing to the user
720
     *   <br>otherwise error message to be passed to the client side for showing to the user
721
     */
721
     */
722
    private String checkPushToProdCount() {
722
    private String checkPushToProdCount() {
723
        int count = 0, maxCount;
723
        int count = 0, maxCount;
724
        try {
724
        try {
725
            //logfile = ConfigClient.getClient().get(ConfigClientKeys.push_prices_to_prod_log_file.toString());
725
            String logfile = ConfigClient.getClient().get(ConfigClientKeys.push_prices_to_prod_log_file.toString());
726
            maxCount = Integer.parseInt(ConfigClient.getClient().get(ConfigClientKeys.push_prices_to_prod_max_count.toString()));
726
            maxCount = Integer.parseInt(ConfigClient.getClient().get(ConfigClientKeys.push_prices_to_prod_max_count.toString()));
727
            count = getPushToProdCount();
727
            count = getPushToProdCount(logfile);
728
            if(count >= maxCount) {
728
            if(count >= maxCount) {
729
                return "Maximum push to production count reached for today";
729
                return "Maximum push to production count reached for today";
730
            }
730
            }
731
        } catch (ConfigException e1) {
731
        } catch (ConfigException e1) {
732
            e1.printStackTrace();
732
            e1.printStackTrace();
Line 747... Line 747...
747
    /**
747
    /**
748
     * If this is the first attempt to push to production for current date, returns 0
748
     * If this is the first attempt to push to production for current date, returns 0
749
     * else reads number of lines from daily rolling log file to get the count.
749
     * else reads number of lines from daily rolling log file to get the count.
750
     * @return push to production count for current date
750
     * @return push to production count for current date
751
     */
751
     */
752
    private int getPushToProdCount() {
752
    private int getPushToProdCount(String logfile) {
-
 
753
        // logfile is "/var/log/services/pushToProductionCount/pushToProd.log"
-
 
754
        // this should also be set in log4j.properties
753
        int lineCount = 0;
755
        int lineCount = 0;
754
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
756
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
755
        Date currentDate = Calendar.getInstance().getTime();
757
        Date currentDate = Calendar.getInstance().getTime();
756
        if(pushToProdDate == null ||  !dateFormat.format(pushToProdDate).equals(dateFormat.format(currentDate))) {
758
        if(pushToProdDate == null ||  !dateFormat.format(pushToProdDate).equals(dateFormat.format(currentDate))) {
757
            pushToProdDate = currentDate;
759
            pushToProdDate = currentDate;
758
            return lineCount;
760
            return lineCount;
759
        }
761
        }
760
        try {
762
        try {
761
            BufferedReader br = new BufferedReader(new FileReader("/home/ankur/logs/pushToProd.log"));
763
            BufferedReader br = new BufferedReader(new FileReader(logfile));
762
            while (br.readLine() != null) {
764
            while (br.readLine() != null) {
763
                lineCount++;
765
                lineCount++;
764
            }
766
            }
765
        } catch (IOException e) {
767
        } catch (IOException e) {
766
            e.printStackTrace();
768
            e.printStackTrace();