Example usage for java.util Date toString

List of usage examples for java.util Date toString

Introduction

In this page you can find the example usage for java.util Date toString.

Prototype

public String toString() 

Source Link

Document

Converts this Date object to a String of the form:
 dow mon dd hh:mm:ss zzz yyyy
where:
  • dow is the day of the week ( Sun, Mon, Tue, Wed, Thu, Fri, Sat ).

    Usage

    From source file:FBMsgExtractor.MessageFormatting.java

    public MessageFormatting() {
        File inFile = new File(
                "J:\\Uni Work Backup\\Dropbox\\Alex Facebook Thread\\After Parsing\\TrimmedMessages.txt");
        try {// w w w .j a v  a 2  s .com
            leagueIDs = new HashMap<>();
    
            leagueIDs.put("36819082", "Ben Beowulf Reid");
            leagueIDs.put("514098273", "Reginald Amukoshi Emvula");
            leagueIDs.put("36818470", "Alex Holehouse");
            leagueIDs.put("61416976", "Gregory van der Donk");
            leagueIDs.put("503074462", "James Rees");
            leagueIDs.put("505420379", "Jonathan Cain");
            leagueIDs.put("286302858", "Nick Cool Swallow");
            leagueIDs.put("502555542", "Ben Morgan");
            leagueIDs.put("500535605", "Vernon Silson");
    
            Date date = new Date();
    
            messageDetails = new HashMap<>();
    
            int counter = 0;
    
            outPut = new PrintWriter(
                    "J:\\Uni Work Backup\\Dropbox\\Alex Facebook Thread\\After Parsing\\CleanedMessages.txt");
    
            br = new BufferedReader(new InputStreamReader(new FileInputStream(inFile)));
            String line;
    
            while (((line = br.readLine()) != null)) //&& (count < 100))
            {
    
                if (line.trim().equals(""))
                    continue;
    
                if (line.startsWith("***LEAGUETHREAD***")) {
                    messageDetails.put("*ThreadNumber", line.replace("***LEAGUETHREAD***", "").trim());
                    continue;
                }
    
                if (line.startsWith("***TITLE***")) {
                    messageDetails.put("*Title", line.replace("***TITLE***", "").trim());
                    continue;
                }
    
                if (line.startsWith("***MARKER***")) {
                    messageDetails.put("*Marker", line.replace("***MARKER***", "").trim());
                    continue;
                }
    
                if (line.startsWith("MessageID:")) {
                    messageDetails.put("*MessageID", line.replace("MessageID:", "").trim());
                    continue;
                }
    
                if (line.startsWith("Time:")) {
                    line = line.replace("Time: ", "");
                    long tempTime = Long.parseLong(line.trim());
                    date.setTime(tempTime);
                    messageDetails.put("*Time", date.toString());
                    continue;
                }
    
                if (line.startsWith("Author:")) {
                    line = line.replace("Author: ", "").trim();
                    messageDetails.put("*Author", leagueIDs.get(line));
                    continue;
                }
    
                if (line.startsWith("Message:")) {
                    line = line.replace("Message:", "");
                    String tempMessage = new String(StringEscapeUtils.unescapeHtml4(line).getBytes("ISO-8859-1"))
                            .trim();
    
                    messageDetails.put("*Message", tempMessage);
                }
    
                if (line.startsWith("Link:")) {
                    line = line.replace("Link: ", "");
                    line = line.replace("***LINK: \"", "***LINK: ");
                    line = line.replace(" ImageShack</span>", "");
                    line = line.replace("</span>", "").trim();
    
                    line = StringEscapeUtils.unescapeHtml4(line);
    
                    line = line.replace("http://lm.facebook.com/l.php?u=", "");
                    line = line.replace("https://m.facebook.com/l.php?u=", "");
    
                    String tempLink = "";
                    char[] linkArray = line.toCharArray();
    
                    for (int i = (line.indexOf("***LINK:") + 8); i < line.indexOf("||"); i++) {
                        tempLink += linkArray[i];
    
                    }
                    tempLink = tempLink.trim();
    
                    line = line.replace(tempLink, "***URL***");
    
                    tempLink = URLDecoder.decode(tempLink, "ISO-8859-1");
    
                    line = line.replace("***URL***", tempLink);
    
                    messageDetails.put("*Link", line);
                    messageDetails.put("*LinkURL", tempLink);
                    continue;
                }
    
                if (line.startsWith("Image:")) {
                    line = line.replace("Image:", "");
                    line = line.replace("***IMAGE: \"", "***IMAGE: ").trim();
    
                    line = StringEscapeUtils.unescapeHtml4(line);
    
                    String tempLink = "";
                    char[] linkArray = line.toCharArray();
    
                    for (int i = (line.indexOf("***IMAGE:") + 9); i < line.indexOf("\""); i++) {
                        tempLink += linkArray[i];
    
                    }
                    tempLink = tempLink.trim();
    
                    char[] cutLine = line.toCharArray();
                    String tempLine = "";
    
                    for (int i = 0; i < line.indexOf(tempLink); i++) {
                        tempLine += cutLine[i];
                    }
    
                    tempLink = URLDecoder.decode(tempLink, "ISO-8859-1");
                    tempLink = tempLink.replaceAll("s100x100/", "");
                    tempLink = tempLink.replaceAll("s75x225/", "");
                    tempLink = tempLink.replaceAll("p50x50/", "");
                    tempLink = tempLink.replaceAll("&preview=1&width=194&height=194", "");
    
                    tempLine += tempLink;
                    tempLine = tempLine.trim();
    
                    messageDetails.put("*Image", tempLine);
                    messageDetails.put("*ImageURL", tempLink);
                    continue;
                }
    
                if (line.startsWith("***END***")) {
                    if (line.contains(""))
                        System.out.println(messageDetails.get("*Marker"));
    
                    if (messageDetails.containsKey("*ThreadNumber")) {
                        outPut.println("League Thread " + messageDetails.get("*ThreadNumber"));
                        System.out.println(messageDetails.get("*ThreadNumber") + "-" + messageDetails.get("*Time")
                                + "-" + messageDetails.get("*Title"));
                        outPut.println();
                    }
    
                    if (messageDetails.containsKey("*Title")) {
                        outPut.println("Title: " + messageDetails.get("*Title"));
                        outPut.println();
                    }
    
                    if (messageDetails.containsKey("*Marker")) {
                        outPut.println("*************");
                        outPut.println("Marker: " + messageDetails.get("*Marker"));
                    }
    
                    if (messageDetails.containsKey("*MessageID")) {
                        outPut.println("MessageID: " + messageDetails.get("*MessageID"));
                    }
    
                    if (messageDetails.containsKey("*Author")) {
                        outPut.println("Author: " + messageDetails.get("*Author"));
                    }
    
                    if (messageDetails.containsKey("*Time")) {
                        outPut.println("Time: " + messageDetails.get("*Time"));
                        outPut.println();
                    }
    
                    //if(messageDetails.containsKey("*Image") && messageDetails.containsKey("*Link"))
                    //System.out.println(messageDetails.get("*Marker"));
    
                    if (messageDetails.containsKey("*Image")) {
                        String tempImage = messageDetails.get("*Image");
    
                        if (messageDetails.containsKey("*Message")) {
                            tempImage = tempImage.replace(messageDetails.get("*Message"), "").trim();
                        }
    
                        outPut.println("Image: " + tempImage);
                        outPut.println("ImageURL: " + messageDetails.get("*ImageURL"));
                        outPut.println();
                    }
    
                    if (messageDetails.containsKey("*Link")) {
                        String tempLink = messageDetails.get("*Link");
    
                        if (messageDetails.containsKey("*Message")) {
                            tempLink = tempLink.replace(messageDetails.get("*Message"), "").trim();
                        }
    
                        outPut.println("Link: " + tempLink);
                        outPut.println("LinkURL: " + messageDetails.get("*LinkURL"));
                        outPut.println();
                    }
    
                    if (messageDetails.containsKey("*Message")) {
                        outPut.println("Message: " + messageDetails.get("*Message"));
                        outPut.println();
                    }
    
                    messageDetails.clear();
                    outPut.println("***END***");
                    outPut.println();
                }
    
                outPut.flush();
            }
            outPut.close();
    
        } catch (Exception e) {
            System.out.println(e);
        }
    
    }
    

    From source file:com.sample.solutionprofile.portlet.JSPPortlet.java

    public void processAction(ActionRequest req, ActionResponse res) throws IOException, PortletException {
    
        String command = req.getParameter("command");
        long userId = 0;
        userId = PortalUtil.getUserId(req);/*from   w ww  .ja v  a  2 s  .co m*/
        List companyIds = null;
    
        int companyId = 0;
        String company_name = req.getParameter("company_names");
    
        if ((company_name != null) && (!company_name.isEmpty())) {
            try {
                companyId = CompanyItemDAO.getCompanyIdByName(company_name);
                System.out.println("Company for solution is" + String.valueOf(companyId));
            } catch (Exception e) {
                System.out.println("Couldn't find the company");
            }
        }
        // remove it for the moment, the user has choosed company ID
        /*try {
           companyIds = SolutionItemDAO.getCompanyIdsByUserId(userId) ;
           companyId = (Integer)companyIds.get(0); 
        } catch (Exception e) {
           System.out.println("SolutionItemDAO.getCompanyIdsByUserId throws exception for userId = " + String.valueOf(userId));
        }*/
        int id = 0;
        try {
            id = Integer.parseInt(req.getParameter("id"));
        } catch (Exception e) {
            System.out.println("Bzz");
        }
    
        //int companyId = 0;
        String partNumberStr = req.getParameter("partNumber");
        long partNumber = 0;
        /*try {
           partNumber  = Integer.parseInt(partNumberStr);
        }catch (Exception e) {
           System.out.println("Bzz2");
        }*/
    
        String solName = req.getParameter("solName");
        String solDesc = req.getParameter("solDesc");
        String partComSite = req.getParameter("partComSite");
        //int solFocus  = Integer.parseInt(req.getParameter("solFocus"));
        //int solStatusPartner = Integer.parseInt(req.getParameter("solStatusPartner"));;
        //int solStatusSAP = Integer.parseInt(req.getParameter("solStatusSAP"));
    
        String sapCertSince = req.getParameter("sapCertSince");
        String lastReviewBySAP = req.getParameter("lastReviewBySAP");
        int averTrainEndUser = 0;
        if (req.getParameter("averTrainEndUser") != null && !req.getParameter("averTrainEndUser").isEmpty())
            averTrainEndUser = Integer.parseInt(req.getParameter("averTrainEndUser"));
        int averImplTrainingDays = 0;
        if (req.getParameter("averImplTrainingDays") != null && !req.getParameter("averImplTrainingDays").isEmpty())
            averImplTrainingDays = Integer.parseInt(req.getParameter("averImplTrainingDays"));
    
        int averImplEffort = 0;
        if (req.getParameter("averImplEffort") != null && !req.getParameter("averImplEffort").isEmpty())
            averImplEffort = Integer.parseInt(req.getParameter("averImplEffort"));
        int averImplDuration = 0;
        if (req.getParameter("averImplDuration") != null && !req.getParameter("averImplDuration").isEmpty())
            averImplDuration = Integer.parseInt(req.getParameter("averImplDuration"));
    
        int averSizeImplTeam = 0;
        if (req.getParameter("averSizeImplTeam") != null && !req.getParameter("averSizeImplTeam").isEmpty())
            averSizeImplTeam = Integer.parseInt(req.getParameter("averSizeImplTeam"));
    
        int averSaleCycle = 0;
        if (req.getParameter("averSaleCycle") != null && !req.getParameter("averSaleCycle").isEmpty())
            averSaleCycle = Integer.parseInt(req.getParameter("averSaleCycle"));
    
        int noCustomers = 0;
        if (req.getParameter("noCustomers") != null && !req.getParameter("noCustomers").isEmpty())
            noCustomers = Integer.parseInt(req.getParameter("noCustomers"));
    
        int smallImpl = 0;
        if (req.getParameter("smallImpl") != null && !req.getParameter("smallImpl").isEmpty())
            smallImpl = Integer.parseInt(req.getParameter("smallImpl"));
    
        int largeImpl = 0;
        if (req.getParameter("largeImpl") != null && !req.getParameter("largeImpl").isEmpty())
            largeImpl = Integer.parseInt(req.getParameter("largeImpl"));
    
        int smallImplTime = 0;
        if (req.getParameter("smallImplTime") != null && !req.getParameter("smallImplTime").isEmpty())
            smallImplTime = Integer.parseInt(req.getParameter("smallImplTime"));
    
        int largeImplTime = 0;
        if (req.getParameter("largeImplTime") != null && !req.getParameter("largeImplTime").isEmpty())
            largeImplTime = Integer.parseInt(req.getParameter("largeImplTime"));
    
        int smallImplTeamNo = 0;
        if (req.getParameter("smallImplTeamNo") != null && !req.getParameter("smallImplTeamNo").isEmpty())
            smallImplTeamNo = Integer.parseInt(req.getParameter("smallImplTeamNo"));
        int largeImplTeamNo = 0;
        if (req.getParameter("largeImplTeamNo") != null && !req.getParameter("largeImplTeamNo").isEmpty())
            largeImplTeamNo = Integer.parseInt(req.getParameter("largeImplTeamNo"));
    
        String solSite = req.getParameter("solSite");
    
        //int countryPriceEuro = Integer.parseInt(req.getParameter("countryPriceEuro"));
    
        String refCustAvailForUse = req.getParameter("refCustAvailForUse");
        if (refCustAvailForUse == null) //?WHY
            refCustAvailForUse = "No";
    
        int totalAppBaseLinePrice = 0;
        if (req.getParameter("totalAppBaseLinePrice") != null
                && !req.getParameter("totalAppBaseLinePrice").isEmpty())
            totalAppBaseLinePrice = Integer.parseInt(req.getParameter("totalAppBaseLinePrice"));
    
        int appPriceEur = 0;//Integer.parseInt(req.getParameter("appPriceEur"));
        int hardwareCost = 0;
        if (req.getParameter("hardwareCost") != null && !req.getParameter("hardwareCost").isEmpty())
            hardwareCost = Integer.parseInt(req.getParameter("hardwareCost"));
    
        int hardwareCostEur = 0;//Integer.parseInt(req.getParameter("hardwareCostEur"));
        int averLicensePrice = 0;
        if (req.getParameter("averLicensePrice") != null && !req.getParameter("averLicensePrice").isEmpty())
            averLicensePrice = Integer.parseInt(req.getParameter("averLicensePrice"));
    
        int averLicensePriceEur = 0;//Integer.parseInt(req.getParameter("averLicensePriceEur"));
        int addServiceCost = 0;
        if (req.getParameter("addServiceCost") != null && !req.getParameter("addServiceCost").isEmpty())
            addServiceCost = Integer.parseInt(req.getParameter("addServiceCost"));
    
        int addServicePriceEur = 0;//Integer.parseInt(req.getParameter("addServicePriceEur"));
        int implCost = 0;
        if (req.getParameter("implCost") != null && !req.getParameter("implCost").isEmpty())
            implCost = Integer.parseInt(req.getParameter("implCost"));
    
        int implCostEur = 0;//Integer.parseInt(req.getParameter("implCostEur"));   
    
        String sapDiscount = req.getParameter("sapDiscount");
        String dbUsed = req.getParameter("dbUsed");
        String SAPBusUsed = req.getParameter("SAPBusUsed");
        String SAPGUIUsed = req.getParameter("SAPGUIUsed");
        String compA1B1Used = req.getParameter("compA1B1Used");
        String thirdPartyUsed = req.getParameter("thirdPartyUsed");
        String thirdPartyName = req.getParameter("thirdPartyName");
        String otherIT = req.getParameter("otherIT");
        String addRemarks = req.getParameter("addRemarks");
        String solSAPMicroSite = req.getParameter("solSAPMicroSite");
    
        String lastPartRevieDate = req.getParameter("solSAPMicroSite");
        String reviewedBy = req.getParameter("reviewedBy");
        if (reviewedBy == null) // WHY?
            reviewedBy = "";
        String profileAdded = req.getParameter("profileAdded");
        if (profileAdded == null) // WHY?
            profileAdded = "";
        String dateCreated = req.getParameter("dateCreated");
        String modifiedBy = req.getParameter("modifiedBy");
        if (modifiedBy == null) // WHY?
            modifiedBy = "";
        String dateUpdated = req.getParameter("dateUpdated");
        String notificationProc = req.getParameter("notificationProc");
        if (notificationProc == null) // WHY?
            notificationProc = "";
        String notificationText = req.getParameter("notificationText");
        if (notificationText == null) // WHY?
            notificationText = "";
    
        // childs
        String sol_countryPriceEuro = req.getParameter("country");
        String sol_solFocusStr = req.getParameter("solFocus");
        String[] sol_geographic_coverage = req.getParameterValues("geographic_coverage");
        String[] sol_industry = req.getParameterValues("industry");
        String[] sol_mySAPAllInOneVers = req.getParameterValues("mySAPAllInOneVers");
        String[] sol_mySAPOneProductVers = req.getParameterValues("mySAPOneProductVers");
    
        String sol_maturity = req.getParameter("maturity");
        String sol_statusByProvider = req.getParameter("statusByProvider");
        String sol_statusBySAP = req.getParameter("statusBySAP");
    
        String[] sol_targetCompSize = req.getParameterValues("targetCompSize");
        String[] sol_categTarget = req.getParameterValues("categTarget");
        String[] sol_langAvailable = req.getParameterValues("langAvailable");
    
        String sol_userType = req.getParameter("userType");
    
        String[] sol_progLang = req.getParameterValues("progLang");
        String[] sol_os = req.getParameterValues("os");
        String[] sol_aioBased = req.getParameterValues("aioBased");
    
        //search related
        try {
            SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");
            DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
            Date tempDate = new Date();
            if (command.equals("add")) {
                // user
                // user adress + phone
    
                // solution
                SolutionItem solutionItem = new SolutionItem();
    
                //public int companyId;
                solutionItem.companyId = companyId; // get the first 
                solutionItem.solName = solName;
                solutionItem.solDesc = solDesc;
                solutionItem.partComSite = partComSite;
                //solutionItem.solFocus =    ;
                //solutionItem.solStatusPartner;
                //solutionItem.solStatusSAP;
                //solutionItem.solMaturity;
                //solutionItem.statusByProvider;
                //solutionItem.statusBySAP;
                //solutionItem.solUserType;
    
                //date
                if (sapCertSince != null && !sapCertSince.isEmpty()) {
                    try {
                        tempDate = format.parse(sapCertSince);
                        String value = tempDate.toString();
                        System.out.println("date since = " + value);
                        solutionItem.sapCertSince = tempDate;
                    } catch (ParseException ex) {
                    }
                }
    
                if (lastReviewBySAP != null && !lastReviewBySAP.isEmpty()) {
                    try {
                        tempDate = format.parse(lastReviewBySAP);
                        String value = tempDate.toString();
                        solutionItem.lastReviewBySAP = tempDate;
                    } catch (ParseException ex) {
                    }
                }
    
                solutionItem.averTrainEndUser = averTrainEndUser;
                solutionItem.averImplTrainingDays = averImplTrainingDays;
                solutionItem.averImplEffort = averImplEffort;
                solutionItem.averImplDuration = averImplDuration;
                solutionItem.averSizeImplTeam = averSizeImplTeam;
                solutionItem.averSaleCycle = averSaleCycle;
                solutionItem.noCustomers = noCustomers;
                solutionItem.smallImpl = smallImpl;
                solutionItem.largeImpl = largeImpl;
                solutionItem.smallImplTime = smallImplTime;
                solutionItem.largeImplTime = largeImplTime;
                solutionItem.smallImplTeamNo = smallImplTeamNo;
                solutionItem.largeImplTeamNo = largeImplTeamNo;
    
                solutionItem.solSite = solSite;
    
                //solutionItem.countryPriceEuro;
    
                solutionItem.refCustAvailForUse = refCustAvailForUse;
                solutionItem.totalAppBaseLinePrice = totalAppBaseLinePrice;
                solutionItem.appPriceEur = appPriceEur;
                solutionItem.hardwareCost = hardwareCost;
                solutionItem.hardwareCostEur = hardwareCostEur;
                solutionItem.averLicensePrice = averLicensePrice;
                solutionItem.averLicensePriceEur = averLicensePriceEur;
                solutionItem.addServiceCost = addServiceCost;
                solutionItem.addServicePriceEur = addServicePriceEur;
                solutionItem.implCost = implCost;
                solutionItem.implCostEur = implCostEur;
                solutionItem.sapDiscount = sapDiscount;
                solutionItem.dbUsed = dbUsed;
                solutionItem.SAPBusUsed = SAPBusUsed;
                solutionItem.SAPGUIUsed = SAPGUIUsed;
                solutionItem.compA1B1Used = compA1B1Used;
                solutionItem.thirdPartyUsed = thirdPartyUsed;
                solutionItem.thirdPartyName = thirdPartyName;
                solutionItem.otherIT = otherIT;
                solutionItem.addRemarks = addRemarks;
                solutionItem.solSAPMicroSite = solSAPMicroSite;
    
                // date
                if (lastPartRevieDate != null && !lastPartRevieDate.isEmpty()) {
                    try {
                        tempDate = format.parse(lastPartRevieDate);
                        String value = tempDate.toString();
                        solutionItem.lastPartRevieDate = tempDate;
                    } catch (ParseException ex) {
                    }
                }
    
                solutionItem.reviewedBy = reviewedBy;
                solutionItem.profileAdded = profileAdded;
                //date
                solutionItem.dateCreated = new Date();
    
                solutionItem.modifiedBy = modifiedBy;
    
                //date
                solutionItem.dateUpdated = new Date();
                solutionItem.notificationProc = notificationProc;
                solutionItem.notificationText = notificationText;
    
                SolutionItemDAO.addSolutionItem(solutionItem);
                // childs
                SolutionUtil.updateSolutionSolFocus(solutionItem, sol_solFocusStr);
                SolutionUtil.updateSolutionCountryPriceEuro(solutionItem, sol_countryPriceEuro);
                SolutionUtil.updateSolutionGeographicCoverage(solutionItem, sol_geographic_coverage);
                SolutionUtil.updateSolutionIndustry(solutionItem, sol_industry);
                SolutionUtil.updateMySAPAllInOneVers(solutionItem, sol_mySAPAllInOneVers);
                SolutionUtil.updateMySAPOneProductVers(solutionItem, sol_mySAPOneProductVers);
                SolutionUtil.updateMaturity(solutionItem, sol_maturity);
                SolutionUtil.updateSolStatusByProvider(solutionItem, sol_statusByProvider);
                SolutionUtil.updateSolStatusBySAP(solutionItem, sol_statusBySAP);
                SolutionUtil.updateSolTargetCompSize(solutionItem, sol_targetCompSize);
                SolutionUtil.updateSolCategTarget(solutionItem, sol_categTarget);
                SolutionUtil.updateSolUserType(solutionItem, sol_userType);
                SolutionUtil.updateSolProgLang(solutionItem, sol_progLang);
                SolutionUtil.updateSolOS(solutionItem, sol_os);
                SolutionUtil.updateSolAioBased(solutionItem, sol_aioBased);
                //perform extra update
                SolutionItemDAO.updateSolutionItem(solutionItem);
    
            } else if (command.equals("edit")) {
                //user
                SolutionItem solutionItem = SolutionItemDAO.getSolutionItem(id);
                //public int companyId;
                solutionItem.solName = solName;
                solutionItem.solDesc = solDesc;
                solutionItem.partComSite = partComSite;
                //solutionItem.solFocus =    ;
                //solutionItem.solStatusPartner;
                //solutionItem.solStatusSAP;
                //solutionItem.solMaturity;
                //solutionItem.statusByProvider;
                //solutionItem.statusBySAP;
                //solutionItem.solUserType;
    
                //date
                if (sapCertSince != null && !sapCertSince.isEmpty()) {
                    try {
                        tempDate = format.parse(sapCertSince);
                        String value = tempDate.toString();
                        System.out.println("date since = " + value);
                        solutionItem.sapCertSince = tempDate;
                    } catch (ParseException ex) {
                    }
                }
    
                if (lastReviewBySAP != null && !lastReviewBySAP.isEmpty()) {
                    try {
                        tempDate = format.parse(lastReviewBySAP);
                        String value = tempDate.toString();
                        solutionItem.lastReviewBySAP = tempDate;
                    } catch (ParseException ex) {
                    }
                }
    
                solutionItem.averTrainEndUser = averTrainEndUser;
                solutionItem.averImplTrainingDays = averImplTrainingDays;
                solutionItem.averImplEffort = averImplEffort;
                solutionItem.averImplDuration = averImplDuration;
                solutionItem.averSizeImplTeam = averSizeImplTeam;
                solutionItem.averSaleCycle = averSaleCycle;
                solutionItem.noCustomers = noCustomers;
                solutionItem.smallImpl = smallImpl;
                solutionItem.largeImpl = largeImpl;
                solutionItem.smallImplTime = smallImplTime;
                solutionItem.largeImplTime = largeImplTime;
                solutionItem.smallImplTeamNo = smallImplTeamNo;
                solutionItem.largeImplTeamNo = largeImplTeamNo;
    
                solutionItem.solSite = solSite;
    
                //solutionItem.countryPriceEuro;
    
                solutionItem.refCustAvailForUse = refCustAvailForUse;
                solutionItem.totalAppBaseLinePrice = totalAppBaseLinePrice;
                solutionItem.appPriceEur = appPriceEur;
                solutionItem.hardwareCost = hardwareCost;
                solutionItem.hardwareCostEur = hardwareCostEur;
                solutionItem.averLicensePrice = averLicensePrice;
                solutionItem.averLicensePriceEur = averLicensePriceEur;
                solutionItem.addServiceCost = addServiceCost;
                solutionItem.addServicePriceEur = addServicePriceEur;
                solutionItem.implCost = implCost;
                solutionItem.implCostEur = implCostEur;
                solutionItem.sapDiscount = sapDiscount;
                solutionItem.dbUsed = dbUsed;
                solutionItem.SAPBusUsed = SAPBusUsed;
                solutionItem.SAPGUIUsed = SAPGUIUsed;
                solutionItem.compA1B1Used = compA1B1Used;
                solutionItem.thirdPartyUsed = thirdPartyUsed;
                solutionItem.thirdPartyName = thirdPartyName;
                solutionItem.otherIT = otherIT;
                solutionItem.addRemarks = addRemarks;
                solutionItem.solSAPMicroSite = solSAPMicroSite;
    
                // date
                if (lastPartRevieDate != null && !lastPartRevieDate.isEmpty()) {
                    try {
                        tempDate = format.parse(lastPartRevieDate);
                        String value = tempDate.toString();
                        solutionItem.lastPartRevieDate = tempDate;
                    } catch (ParseException ex) {
                    }
                }
    
                solutionItem.reviewedBy = reviewedBy;
                solutionItem.profileAdded = profileAdded;
                //date
                solutionItem.dateCreated = new Date();
    
                solutionItem.modifiedBy = modifiedBy;
    
                //date
                solutionItem.dateUpdated = new Date();
                solutionItem.notificationProc = notificationProc;
                solutionItem.notificationText = notificationText;
                // Do update in main table
                SolutionUtil.updateSolutionSolFocus(solutionItem, sol_solFocusStr);
                SolutionUtil.updateSolutionCountryPriceEuro(solutionItem, sol_countryPriceEuro);
                SolutionUtil.updateSolutionGeographicCoverage(solutionItem, sol_geographic_coverage);
                SolutionUtil.updateSolutionIndustry(solutionItem, sol_industry);
                SolutionUtil.updateMySAPAllInOneVers(solutionItem, sol_mySAPAllInOneVers);
                SolutionUtil.updateMySAPOneProductVers(solutionItem, sol_mySAPOneProductVers);
                SolutionUtil.updateMaturity(solutionItem, sol_maturity);
                SolutionUtil.updateSolStatusByProvider(solutionItem, sol_statusByProvider);
                SolutionUtil.updateSolStatusBySAP(solutionItem, sol_statusBySAP);
                SolutionUtil.updateSolTargetCompSize(solutionItem, sol_targetCompSize);
                SolutionUtil.updateSolCategTarget(solutionItem, sol_categTarget);
                SolutionUtil.updateSolUserType(solutionItem, sol_userType);
                SolutionUtil.updateSolProgLang(solutionItem, sol_progLang);
                SolutionUtil.updateSolOS(solutionItem, sol_os);
                SolutionUtil.updateSolAioBased(solutionItem, sol_aioBased);
    
                SolutionItemDAO.updateSolutionItem(solutionItem);
    
            } else if (command.equals("delete")) {
                System.out.println("a facut delete ");
                System.out.println("a facut delete cu " + String.valueOf(id));
    
                SolutionItemDAO.deleteSolutionItem(id);
            }
    
        } catch (SQLException sqle) {
            throw new PortletException(sqle);
        }
    
    }
    

    From source file:com.dell.asm.asmcore.asmmanager.app.AsmManagerApp.java

    private void createDefaultFileSystemMaintenanceJob() {
        _logger.info("Create Default File System Maintenance job.");
        IJobManager jobMgr = JobManager.getInstance();
        try {//from  ww  w. j  av a  2  s .co  m
            Set<JobKey> jobKeySet = jobMgr.getScheduler()
                    .getJobKeys(GroupMatcher.jobGroupEquals(FileSystemMaintenanceJob.class.getSimpleName()));
            if (jobKeySet != null && jobKeySet.size() > 0) {
                for (JobKey jobKey : jobKeySet) {
                    jobMgr.deleteJob(jobKey);
                }
            }
    
            // create and run startup job
            JobDetail startUpJobDetail = jobMgr.createNamedJob(FileSystemMaintenanceJob.class);
            SimpleScheduleBuilder simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
            Trigger simpleTrigger = jobMgr.createNamedTrigger(simpleScheduleBuilder, startUpJobDetail, true);
            Date nextRun = jobMgr.scheduleJob(startUpJobDetail, simpleTrigger);
            _logger.info("Start Up File System Maintenance Job scheduled at: " + nextRun.toString());
    
            // create cron job to run every Sunday at 1 am
            CronScheduleBuilder schedBuilder = CronScheduleBuilder.cronSchedule(fileSystemMaintenanceCron);
            JobDetail chronJobDetail = jobMgr.createNamedJob(FileSystemMaintenanceJob.class);
            Trigger trigger = jobMgr.createNamedTrigger(schedBuilder, chronJobDetail, false);
            nextRun = jobMgr.scheduleJob(chronJobDetail, trigger);
            _logger.info("next run of File System Maintenance Job scheduled at: " + nextRun.toString());
    
            if (!jobMgr.getScheduler().isStarted()) {
                jobMgr.getScheduler().start();
                _logger.info("scheduler started");
            }
        } catch (Exception e) {
            String msg = "Failed to schedule recurring file system maintenance job: " + e.getMessage();
            _logger.error(msg, e);
        }
    }
    

    From source file:de.bangl.lm.LotManagerPlugin.java

    public void getInactiveLotList(CommandSender sender) {
        try {//from  www . j av  a 2 s.co  m
            if (this.hasEssentials) {
    
                Calendar cal = Calendar.getInstance();
                cal.setTime(new Date());
                cal.add(Calendar.HOUR, -(24 * 7 * 2)); // Vor vier Wochen
                cal.set(Calendar.HOUR, 0);
                cal.set(Calendar.MINUTE, 0);
                cal.set(Calendar.SECOND, 0);
                cal.set(Calendar.MILLISECOND, 0);
    
                Boolean foundone = false;
                for (World world : this.getServer().getWorlds()) {
                    for (Lot lot : this.lots.getAllLots().values()) {
                        final ProtectedRegion wgregion = this.wg.getRegionManager(world).getRegion(lot.getId());
                        if (wgregion != null) {
                            DefaultDomain owners = wgregion.getOwners();
                            if (owners != null) {
                                for (UUID player : owners.getUniqueIds()) {
                                    User essuser = this.ess.getUser(player);
                                    if (essuser != null) {
                                        final Date lastonline = new Date(essuser.getLastLogin());
                                        if (lastonline.before(cal.getTime())) {
                                            this.sendInfo(sender, lot.getId() + " - " + essuser.getDisplayName()
                                                    + " (" + lastonline.toString() + ")");
                                            foundone = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (!foundone) {
                    this.sendInfo(sender, "All lots given away seem to be actively used.");
                }
            } else {
                sendError(sender, "Sorry, you need \"Essentials\" to use this feature.");
            }
        } catch (Exception e) {
            logError(e.getMessage());
            sendError(sender, e.getMessage());
        }
    }
    

    From source file:com.BeatYourRecord.SubmitActivity.java

    public void submitToYtdDomain(String ytdDomain, String assignmentId, String videoId, String youTubeName,
            String clientLoginToken, String title, String description, Date dateTaken, String videoLocation,
            String tags) {/*  w  w w .  j a va  2  s . c o  m*/
    
        JSONObject payload = new JSONObject();
        try {
    
            payload.put("method", "NEW_MOBILE_VIDEO_SUBMISSION");
            JSONObject params = new JSONObject();
            Log.v("params videoId", videoId);
            vidId = videoId;
            params.put("videoId", videoId);
            params.put("youTubeName", youTubeName);
            params.put("clientLoginToken", clientLoginToken);
            params.put("title", title);
            params.put("description", description);
            params.put("videoDate", dateTaken.toString());
            params.put("tags", tags);
    
            if (videoLocation != null) {
                params.put("videoLocation", videoLocation);
            }
    
            if (assignmentId != null) {
                params.put("assignmentId", assignmentId);
            }
    
            payload.put("params", params);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    
        String jsonRpcUrl = "http://" + ytdDomain + "/jsonrpc";
        String json = Util.makeJsonRpcCall(jsonRpcUrl, payload);
    
        if (json != null) {
            try {
                JSONObject jsonObj = new JSONObject(json);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
    

    From source file:org.jini.commands.files.FindFiles.java

    /**
     * Find Files with a wild card pattern/*  w  ww  .j  av a 2  s  .c o  m*/
     *
     * @param dirName
     * @param wildCardPattern
     * @param recursive
     */
    void findFilesWithWildCard(String dirName, String wildCardPattern, boolean recursive) {
    
        PrintChar printChar = new PrintChar();
        printChar.setOutPutChar(">");
    
        if ((this.getJcError() == false) && (this.isDir(dirName) == false)) {
            this.setJcError(true);
            this.addErrorMessages("Error : Directory [" + dirName + "] does not exsist.");
        }
    
        if (this.getJcError() == false) {
            printChar.start();
    
            try {
                File root = new File(dirName);
    
                Collection files = FileUtils.listFiles(root, null, recursive);
    
                TablePrinter tableF = new TablePrinter("Name", "Type", "Readable", "Writable", "Executable",
                        "Size KB", "Size MB", "Last Modified");
    
                for (Iterator iterator = files.iterator(); iterator.hasNext();) {
    
                    File file = (File) iterator.next();
    
                    if (file.getName().matches(wildCardPattern)) {
    
                        if (this.withDetails == false) {
                            System.out.println(file.getAbsolutePath());
                        } else {
    
                            java.util.Date lastModified = new java.util.Date(file.lastModified());
                            long filesizeInKB = file.length() / 1024;
                            double bytes = file.length();
                            double kilobytes = (bytes / 1024);
                            double megabytes = (kilobytes / 1024);
    
                            String type = "";
    
                            DecimalFormat df = new DecimalFormat("####.####");
    
                            if (file.isDirectory()) {
                                type = "Dir";
                            }
                            if (file.isFile()) {
                                type = "File";
                            }
    
                            if (file.isFile() && file.isHidden()) {
                                type = "File (Hidden)";
                            }
                            if (file.isDirectory() && (file.isHidden())) {
                                type = "Dir (Hidden)";
                            }
    
                            String canExec = "" + file.canExecute();
                            String canRead = "" + file.canRead();
                            String canWrite = "" + file.canWrite();
                            String filesizeInKBStr = Long.toString(filesizeInKB);
                            String filesizeInMBStr = df.format(megabytes);
    
                            tableF.addRow(file.getAbsolutePath(), type, canRead, canWrite, canExec, filesizeInKBStr,
                                    filesizeInMBStr, lastModified.toString());
                        }
                    }
                }
    
                if (this.withDetails == true) {
                    if (files.isEmpty() == false) {
                        tableF.print();
                    }
                }
    
                printChar.setStopPrinting(true);
            } catch (Exception e) {
    
                this.setJcError(true);
                this.addErrorMessages("Error : " + e.toString());
            }
    
        }
    
        printChar.setStopPrinting(true);
        this.done = true;
    }
    

    From source file:fr.gouv.culture.vitam.eml.PstExtract.java

    private String extractInfoMessage(PSTMessage email) {
        if (email instanceof PSTContact) {
            Element node = extractInfoContact((PSTContact) email);
            config.addRankId(node);/*from  w  w w.ja  va2 s .  c o m*/
            //node.addAttribute(EMAIL_FIELDS.rankId.name, id);
            Element identifications = XmlDom.factory.createElement("identification");
            Element identity = XmlDom.factory.createElement("identity");
            identity.addAttribute("format", "Microsoft Outlook Address Book");
            identity.addAttribute("mime", "application/vnd.ms-outlook");
            identifications.add(identity);
            node.add(identifications);
            node.addAttribute(EMAIL_FIELDS.status.name, "ok");
            currentRoot.add(node);
            return "";
        } else if (email instanceof PSTTask) {
            Element node = extractInfoTask((PSTTask) email);
            config.addRankId(node);
            //node.addAttribute(EMAIL_FIELDS.rankId.name, id);
            Element identifications = XmlDom.factory.createElement("identification");
            Element identity = XmlDom.factory.createElement("identity");
            identity.addAttribute("format", "Microsoft Outlook Task");
            identity.addAttribute("mime", "application/vnd.ms-outlook");
            identifications.add(identity);
            node.add(identifications);
            node.addAttribute(EMAIL_FIELDS.status.name, "ok");
            currentRoot.add(node);
            return "";
        } else if (email instanceof PSTActivity) {
            Element node = extractInfoActivity((PSTActivity) email);
            config.addRankId(node);
            //node.addAttribute(EMAIL_FIELDS.rankId.name, id);
            Element identifications = XmlDom.factory.createElement("identification");
            Element identity = XmlDom.factory.createElement("identity");
            identity.addAttribute("format", "Microsoft Outlook Activity");
            identity.addAttribute("mime", "application/vnd.ms-outlook");
            identifications.add(identity);
            node.add(identifications);
            node.addAttribute(EMAIL_FIELDS.status.name, "ok");
            currentRoot.add(node);
            return "";
        } else if (email instanceof PSTRss) {
            Element node = extractInfoRss((PSTRss) email);
            config.addRankId(node);
            //node.addAttribute(EMAIL_FIELDS.rankId.name, id);
            Element identifications = XmlDom.factory.createElement("identification");
            Element identity = XmlDom.factory.createElement("identity");
            identity.addAttribute("format", "Microsoft Outlook Rss");
            identity.addAttribute("mime", "application/vnd.ms-outlook");
            identifications.add(identity);
            node.add(identifications);
            node.addAttribute(EMAIL_FIELDS.status.name, "ok");
            currentRoot.add(node);
            return "";
        } else if (email instanceof PSTAppointment) {
            Element node = extractInfoAppointment((PSTAppointment) email);
            config.addRankId(node);
            //node.addAttribute(EMAIL_FIELDS.rankId.name, id);
            Element identifications = XmlDom.factory.createElement("identification");
            Element identity = XmlDom.factory.createElement("identity");
            identity.addAttribute("format", "Microsoft Outlook Appointment");
            identity.addAttribute("mime", "application/vnd.ms-outlook");
            identifications.add(identity);
            node.add(identifications);
            node.addAttribute(EMAIL_FIELDS.status.name, "ok");
            currentRoot.add(node);
            return "";
        }
        Element root = XmlDom.factory.createElement(EMAIL_FIELDS.formatMSG.name);
        Element keywords = XmlDom.factory.createElement(EMAIL_FIELDS.keywords.name);
        Element metadata = XmlDom.factory.createElement(EMAIL_FIELDS.metadata.name);
    
        String id = config.addRankId(root);
        //root.addAttribute(EMAIL_FIELDS.rankId.name, id);
        Element identifications = XmlDom.factory.createElement("identification");
        Element identity = XmlDom.factory.createElement("identity");
        identity.addAttribute("format", "Microsoft Outlook Email Message");
        identity.addAttribute("mime", "application/vnd.ms-outlook");
        identity.addAttribute("puid", "x-fmt/430");
        identity.addAttribute("extensions", "msg");
        identifications.add(identity);
        root.add(identifications);
    
        Element sub = XmlDom.factory.createElement(EMAIL_FIELDS.from.name);
        addAddress(sub, EMAIL_FIELDS.fromUnit.name, email.getSenderName(), email.getSenderEmailAddress());
        metadata.add(sub);
        int NumberOfRecipients = 0;
        Element toRecipients = XmlDom.factory.createElement(EMAIL_FIELDS.toRecipients.name);
        Element ccRecipients = XmlDom.factory.createElement(EMAIL_FIELDS.ccRecipients.name);
        Element bccRecipients = XmlDom.factory.createElement(EMAIL_FIELDS.bccRecipients.name);
        try {
            NumberOfRecipients = email.getNumberOfRecipients();
        } catch (PSTException e1) {
        } catch (IOException e1) {
        }
        for (int i = 0; i < NumberOfRecipients; i++) {
            try {
                PSTRecipient recipient = email.getRecipient(i);
                // MAPI_TO = 1; MAPI_CC = 2; MAPI_BCC = 3;
                Element choose = null;
                String type = "??";
                switch (recipient.getRecipientType()) {
                case PSTRecipient.MAPI_TO:
                    type = EMAIL_FIELDS.toUnit.name;
                    choose = toRecipients;
                    break;
                case PSTRecipient.MAPI_CC:
                    type = EMAIL_FIELDS.ccUnit.name;
                    choose = ccRecipients;
                    break;
                case PSTRecipient.MAPI_BCC:
                    type = EMAIL_FIELDS.bccUnit.name;
                    choose = bccRecipients;
                    break;
                }
                if (choose != null) {
                    addAddress(choose, type, recipient.getDisplayName(), recipient.getEmailAddress());
                }
            } catch (PSTException e) {
            } catch (IOException e) {
            }
        }
        if (toRecipients.hasContent()) {
            metadata.add(toRecipients);
        }
        if (ccRecipients.hasContent()) {
            metadata.add(ccRecipients);
        }
        if (bccRecipients.hasContent()) {
            metadata.add(bccRecipients);
        }
        // get the subject
        String Subject = email.getSubject();
        if (Subject != null) {
            sub = XmlDom.factory.createElement(EMAIL_FIELDS.subject.name);
            sub.setText(StringUtils.unescapeHTML(Subject, true, false));
            metadata.add(sub);
        }
        // Conversation topic This is basically the subject from which Fwd:, Re, etc.
        Subject = email.getConversationTopic();
        if (Subject != null) {
            sub = XmlDom.factory.createElement(EMAIL_FIELDS.conversationTopic.name);
            sub.setText(StringUtils.unescapeHTML(Subject, true, false));
            metadata.add(sub);
        }
        // get the client submit time (sent ?)
        Date ClientSubmitTime = email.getClientSubmitTime();
        if (ClientSubmitTime != null) {
            sub = XmlDom.factory.createElement(EMAIL_FIELDS.sentDate.name);
            sub.setText(ClientSubmitTime.toString());
            metadata.add(sub);
        }
        // Message delivery time
        Date MessageDeliveryTime = email.getMessageDeliveryTime();
        if (MessageDeliveryTime != null) {
            sub = XmlDom.factory.createElement(EMAIL_FIELDS.receivedDate.name);
            sub.setText(MessageDeliveryTime.toString());
            metadata.add(sub);
        }
        // Transport message headers ASCII or Unicode string These contain the SMTP e-mail headers.
        String TransportMessageHeaders = email.getTransportMessageHeaders();
        if (TransportMessageHeaders != null) {
            sub = XmlDom.factory.createElement(EMAIL_FIELDS.receptionTrace.name);
            sub.add(XmlDom.factory.createElement(EMAIL_FIELDS.trace.name)
                    .addText(StringUtils.unescapeHTML(TransportMessageHeaders, true, false)));
            metadata.add(sub);
            if (TransportMessageHeaders.contains("X-RDF:")) {
                System.err.println("Found a X-RDF");
                int pos = TransportMessageHeaders.indexOf("X-RDF:") + "X-RDF:".length();
                while (pos < TransportMessageHeaders.length()) {
                    char test = TransportMessageHeaders.charAt(pos);
                    if (test != ' ' && test != '\r' && test != '\n') {
                        pos++;
                    } else {
                        break;
                    }
                }
                int pos2 = TransportMessageHeaders.indexOf(":", pos);
                while (pos2 > pos) {
                    char test = TransportMessageHeaders.charAt(pos2);
                    if (test != ' ' && test != '\r' && test != '\n') {
                        pos2--;
                    } else {
                        break;
                    }
                }
                String xrdf = TransportMessageHeaders.substring(pos, pos2);
                String rdf = null;
                try {
                    byte[] decoded = org.apache.commons.codec.binary.Base64.decodeBase64(xrdf);
                    //byte [] decoded = Base64.decode(xrdf);
                    rdf = new String(decoded);
                    System.err.println(rdf);
                    try {
                        Document tempDocument = DocumentHelper.parseText(rdf);
                        Element erdf = sub.addElement("x-rdf");
                        erdf.add(tempDocument.getRootElement());
                    } catch (Exception e) {
                        System.err.println("Cannot decode X-RDF: " + e.getMessage());
                        e.printStackTrace();
                        Element erdf = sub.addElement("x-rdf");
                        erdf.addText(rdf);
                    }
                } catch (Exception e) {
                    System.err.println("Cannot decode X-RDF: " + e.getMessage());
                    System.err.println(xrdf);
                    e.printStackTrace();
                }
            }
            TransportMessageHeaders = null;
        }
        long internalSize = email.getMessageSize();
        if (internalSize > 0) {
            sub = XmlDom.factory.createElement(EMAIL_FIELDS.emailSize.name);
            sub.setText(Long.toString(internalSize));
            metadata.add(sub);
        }
        // Message ID for this email as allocated per rfc2822
        String InternetMessageId = email.getInternetMessageId();
        if (InternetMessageId != null) {
            InternetMessageId = StringUtils.removeChevron(StringUtils.unescapeHTML(InternetMessageId, true, false))
                    .trim();
            if (InternetMessageId.length() > 1) {
                sub = XmlDom.factory.createElement(EMAIL_FIELDS.messageId.name);
                sub.setText(InternetMessageId);
                metadata.add(sub);
            }
        }
        // In-Reply-To
        String InReplyToId = email.getInReplyToId();
        if (InReplyToId != null) {
            InReplyToId = StringUtils.removeChevron(StringUtils.unescapeHTML(InReplyToId, true, false)).trim();
            if (InReplyToId.length() > 1) {
                sub = XmlDom.factory.createElement(EMAIL_FIELDS.inReplyTo.name);
                sub.setText(InReplyToId);
                if (InternetMessageId != null && InternetMessageId.length() > 1) {
                    String old = EmlExtract.filEmls.get(InReplyToId);
                    if (old == null) {
                        old = InternetMessageId;
                    } else {
                        old += "," + InternetMessageId;
                    }
                    EmlExtract.filEmls.put(InReplyToId, old);
                }
                metadata.add(sub);
            }
            InReplyToId = null;
            InternetMessageId = null;
        }
        sub = XmlDom.factory.createElement(EMAIL_FIELDS.properties.name);
        // is the action flag for this item "forward"?
        boolean Forwarded = email.hasForwarded();
        sub.addAttribute(EMAIL_FIELDS.propForwarded.name, Boolean.toString(Forwarded));
        // is the action flag for this item "replied"?
        boolean Replied = email.hasReplied();
        sub.addAttribute(EMAIL_FIELDS.propReplied.name, Boolean.toString(Replied));
        //
        boolean Read = email.isRead();
        sub.addAttribute(EMAIL_FIELDS.propRead.name, Boolean.toString(Read));
        //
        boolean Unsent = email.isUnsent();
        sub.addAttribute(EMAIL_FIELDS.propUnsent.name, Boolean.toString(Unsent));
        // Recipient Reassignment Prohibited Boolean 0 = false 0 != true
        boolean RecipientReassignmentProhibited = email.getRecipientReassignmentProhibited();
        sub.addAttribute(EMAIL_FIELDS.propRecipientReassignmentProhibited.name,
                Boolean.toString(RecipientReassignmentProhibited));
        // get the importance of the email
        // PSTMessage.IMPORTANCE_LOW + PSTMessage.IMPORTANCE_NORMAL + PSTMessage.IMPORTANCE_HIGH
        int Importance = email.getImportance();
        String imp = "??";
        switch (Importance) {
        case PSTMessage.IMPORTANCE_LOW:
            imp = "LOW";
            break;
        case PSTMessage.IMPORTANCE_NORMAL:
            imp = "NORMAL";
            break;
        case PSTMessage.IMPORTANCE_HIGH:
            imp = "HIGH";
            break;
        }
        sub.addAttribute(EMAIL_FIELDS.importance.name, imp);
        // Priority Integer 32-bit signed -1 = NonUrgent 0 = Normal 1 = Urgent
        int Priority = email.getPriority();
        switch (Priority) {
        case -1:
            imp = "LOW";
            break;
        case 0:
            imp = "NORMAL";
            break;
        case 1:
            imp = "HIGH";
            break;
        default:
            imp = "LEV" + Priority;
        }
        sub.addAttribute(EMAIL_FIELDS.priority.name, imp);
        // Sensitivity Integer 32-bit signed sender's opinion of the sensitivity of an email 0 =
        // None 1 = Personal 2 = Private 3 = Company Confidential
        int Sensitivity = email.getSensitivity();
        String sens = "??";
        switch (Sensitivity) {
        case 0:
            sens = "None";
            break;
        case 1:
            sens = "Personal";
            break;
        case 2:
            sens = "Private";
            break;
        case 3:
            sens = "Confidential";
            break;
        }
        sub.addAttribute(EMAIL_FIELDS.sensitivity.name, sens);
    
        //
        boolean Attachments = email.hasAttachments();
        sub.addAttribute(EMAIL_FIELDS.hasAttachment.name, Boolean.toString(Attachments));
        metadata.add(sub);
    
        String result = "";
        Element identification = null;
        if (Attachments) {
            File oldPath = curPath;
            if (config.extractFile) {
                File newDir = new File(curPath, id);
                newDir.mkdirs();
                curPath = newDir;
                argument.currentOutputDir = curPath;
            }
            identification = XmlDom.factory.createElement(EMAIL_FIELDS.attachments.name);
            // get the number of attachments for this message
            int NumberOfAttachments = email.getNumberOfAttachments();
            identification.addAttribute(EMAIL_FIELDS.attNumber.name, Integer.toString(NumberOfAttachments));
            // get a specific attachment from this email.
            for (int attachmentNumber = 0; attachmentNumber < NumberOfAttachments; attachmentNumber++) {
                try {
                    PSTAttachment attachment = email.getAttachment(attachmentNumber);
                    if (argument.extractKeyword) {
                        result += " " + extractInfoAttachment(attachment, identification);
                    } else {
                        extractInfoAttachment(attachment, identification);
                    }
                } catch (PSTException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            curPath = oldPath;
            argument.currentOutputDir = curPath;
        }
        // Plain text e-mail body
        String body = "";
        if (argument.extractKeyword || config.extractFile) {
            body = email.getBody();
            boolean isTxt = true;
            boolean isHttp = false;
            if (body == null || body.isEmpty()) {
                isTxt = false;
                body = email.getBodyHTML();
                isHttp = true;
                if (body == null || body.isEmpty()) {
                    isHttp = false;
                    try {
                        body = email.getRTFBody();
                    } catch (PSTException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
            if (body != null && !body.isEmpty()) {
                if (config.extractFile) {
                    // XXX FIXME could saved email from HTML Body (clearer) if possible
                    // use curRank in name, and attachment will be under directory named
                    // add currank in field
                    File newDir = new File(curPath, id);
                    newDir.mkdirs();
                    File oldPath = curPath;
                    curPath = newDir;
                    argument.currentOutputDir = curPath;
                    String filenamebody = InternetMessageId;
                    if (filenamebody == null || !filenamebody.isEmpty()) {
                        filenamebody = id;
                    }
                    String html = null;
                    if (isHttp) {
                        html = body;
                    }
                    String rtf = null;
                    if (!isTxt && !isHttp) {
                        rtf = body;
                    }
                    if (isTxt) {
                        FileOutputStream output = null;
                        try {
                            output = new FileOutputStream(new File(newDir, filenamebody + ".txt"));
                            byte[] bb = body.getBytes();
                            output.write(bb, 0, bb.length);
                        } catch (FileNotFoundException e) {
                            e.printStackTrace();
                        } catch (IOException e) {
                            e.printStackTrace();
                        } finally {
                            if (output != null) {
                                try {
                                    output.close();
                                } catch (IOException e) {
                                }
                            }
                        }
                        html = email.getBodyHTML();
                    }
                    if (html != null && !html.isEmpty()) {
                        FileOutputStream output = null;
                        try {
                            output = new FileOutputStream(new File(newDir, filenamebody + ".html"));
                            byte[] bb = html.getBytes();
                            output.write(bb, 0, bb.length);
                        } catch (FileNotFoundException e) {
                            e.printStackTrace();
                        } catch (IOException e) {
                            e.printStackTrace();
                        } finally {
                            if (output != null) {
                                try {
                                    output.close();
                                } catch (IOException e) {
                                }
                            }
                        }
                        html = null;
                    }
                    if (isTxt || isHttp) {
                        try {
                            rtf = email.getRTFBody();
                        } catch (PSTException e) {
                            e.printStackTrace();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                    if (rtf != null && !rtf.isEmpty()) {
                        FileOutputStream output = null;
                        try {
                            output = new FileOutputStream(new File(newDir, filenamebody + ".rtf"));
                            byte[] bb = rtf.getBytes();
                            output.write(bb, 0, bb.length);
                        } catch (FileNotFoundException e) {
                            e.printStackTrace();
                        } catch (IOException e) {
                            e.printStackTrace();
                        } finally {
                            if (output != null) {
                                try {
                                    output.close();
                                } catch (IOException e) {
                                }
                            }
                        }
                        rtf = null;
                    }
                    curPath = oldPath;
                    argument.currentOutputDir = curPath;
                }
            }
        }
        if (metadata.hasContent()) {
            root.add(metadata);
        }
        if (identification != null && identification.hasContent()) {
            root.add(identification);
        }
        if (argument.extractKeyword) {
            result = body + " " + result;
            body = null;
            ExtractInfo.exportMetadata(keywords, result, "", config, null);
            if (keywords.hasContent()) {
                root.add(keywords);
            }
        }
        root.addAttribute(EMAIL_FIELDS.status.name, "ok");
        currentRoot.add(root);
        return result;
    }
    

    From source file:biz.taoconsulting.dominodav.methods.PROPPATCH.java

    /**
     * (non-Javadoc)/*from  w  w w.ja va2 s.co  m*/
     * 
     * @see biz.taoconsulting.dominodav.methods.AbstractDAVMethod#action()
     */
    @SuppressWarnings("deprecation")
    protected void action() throws Exception {
        // TODO Implement!
        IDAVRepository rep = this.getRepository();
        String curURI = (String) this.getHeaderValues().get("uri");
        IDAVResource resource = null;
        String relockToken = this.getRelockToken(this.getReq());
        LockManager lm = this.getLockManager();
        // int status = HttpServletResponse.SC_OK; // We presume success
        LockInfo li = null;
        HttpServletResponse resp = this.getResp();
        Long TimeOutValue = this.getTimeOutValue(this.getReq());
        try {
            // LOGGER.info("getResource");
            resource = rep.getResource(curURI, true);
    
        } catch (DAVNotFoundException e) {
            // This exception isn't a problem since we just can create the new
            // URL
            // LOGGER.info("Exception not found resource");
    
        }
        if (resource == null) {
            // LOGGER.info("Error, resource is null");
            // Set the return error
            // Unprocessable Entity (see
            // http://www.webdav.org/specs/rfc2518.html#status.code.extensions.to.http11)
            this.setHTTPStatus(403);
            return;
        }
        if (resource.isReadOnly()) {
            this.setHTTPStatus(403);
            return;
        }
        if (relockToken != null) {
            li = lm.relock(resource, relockToken, TimeOutValue);
            if (li == null) {
                String eString = "Relock failed for " + relockToken;
                LOGGER.debug(eString);
                this.setErrorMessage(eString, 423); // Precondition failed
                this.setHTTPStatus(423);
                return;
            }
        }
        String creationDate = null, modifiedDate = null;
        Date dt = new Date();
        Date dtM = new Date();
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        LOGGER.info("DB Factory built OK");
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        LOGGER.info("Document builder OK");
        Document doc = dBuilder.parse(this.getReq().getInputStream());
        LOGGER.info("XML Doc ok read");
        if (doc != null) {
            LOGGER.info("doc is not null");
            NodeList nlCreation = doc.getElementsByTagName("Z:Win32CreationTime");
            NodeList nlModified = doc.getElementsByTagName("Z:Win32LastModifiedTime");
            if (nlCreation != null) {
                LOGGER.info("nlCreation not null");
                Node nNodeCreation = nlCreation.item(0);
                if (nNodeCreation != null) {
                    LOGGER.info("nNodeCreation not null, is " + nNodeCreation.getTextContent());
                    creationDate = nNodeCreation.getTextContent();
                    LOGGER.info("Creation date=" + creationDate + "  Locale is "
                            + this.getReq().getLocale().toString());
                    DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.getDefault());
                    LOGGER.info("SimpleDate Format ok created");
                    try {
                        dt = df.parse(creationDate);
                    } catch (Exception e) {
                        creationDate += "+00";
                        dt = df.parse(creationDate);
                    }
                    try {
                        // dt.setTime(dt.getTime()-3*60*60*1000);
                        resource.patchCreationDate(dt);
                    } catch (Exception e) {
                    }
                    LOGGER.info("Date dt parsed with value=" + dt.toString());
                }
            }
            if (nlModified != null) {
                LOGGER.info("nlModified not null");
                Node nNodeModified = nlModified.item(0);
                if (nNodeModified != null) {
                    LOGGER.info("nNodeModified not null");
                    modifiedDate = nNodeModified.getTextContent();
                    LOGGER.info("Modified date=" + modifiedDate);
                    Locale defLoc = Locale.getDefault();
                    // This is the crap reason why Win7 didn;t work!
                    DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", defLoc);
                    try {
                        dtM = df.parse(modifiedDate);
                    } catch (Exception e) {
                        modifiedDate += "+00";
                        dtM = df.parse(modifiedDate);
                    }
                    try {
                        // dtM.setTime(dtM.getTime()-3*60*60*1000);
                        resource.patchLastModified(dtM);
                    } catch (Exception e) {
                    }
                    LOGGER.info("Date dtM parsed with value=" + dtM.toString());
                }
            }
        }
    
        IDAVXMLResponse xr = DavXMLResponsefactory.getXMLResponse(null, false);
        xr.openTag("multistatus");
        resource.addToDavXMLResponsePROPPATCH(xr);
        xr.closeDocument();
        this.setHTTPStatus(DAVProperties.STATUS_MULTIPART);
        // FIXME: this is depricated!
        resp.setStatus(DAVProperties.STATUS_MULTIPART, DAVProperties.STATUS_MULTIPART_STRING);
        resp.setContentType(DAVProperties.TYPE_XML);
        String result = xr.toString();
        resp.setContentLength(result.length());
        PrintWriter out = resp.getWriter();
        out.write(result);
        out.close();
    }
    

    From source file:com.acmeair.wxs.service.FlightServiceImpl.java

    @Override
    public List<Flight> getFlightByAirportsAndDepartureDate(String fromAirport, String toAirport, Date deptDate) {
        try {// www.  jav  a 2 s .  c o  m
            Session session = null;
            String originPortAndDestPortQueryString = fromAirport + toAirport;
            FlightSegment segment = originAndDestPortToSegmentCache.get(originPortAndDestPortQueryString);
            boolean startedTran = false;
    
            if (segment == null) {
                session = sessionManager.getObjectGridSession();
                if (!session.isTransactionActive()) {
                    startedTran = true;
                    session.begin();
                }
                ObjectQuery query = session.createObjectQuery(
                        "select obj from FlightSegment obj where obj.destPort=?1 and obj.originPort=?2");
                query.setParameter(2, fromAirport);
                query.setParameter(1, toAirport);
    
                int partitionId = sessionManager.getBackingMap(FLIGHT_SEGMENT_MAP_NAME).getPartitionManager()
                        .getPartition(fromAirport);
                query.setPartition(partitionId);
    
                @SuppressWarnings("unchecked")
                Iterator<Object> itr = query.getResultIterator();
                if (itr.hasNext())
                    segment = (FlightSegment) itr.next();
    
                if (segment == null) {
                    segment = new FlightSegment(); // put a sentinel value of a non-populated flightsegment
                }
                originAndDestPortToSegmentCache.putIfAbsent(originPortAndDestPortQueryString, segment);
            }
    
            // cache flights that not available (checks against sentinel value above indirectly)
            if (segment.getFlightName() == null) {
                return new ArrayList<Flight>();
            }
    
            String segId = segment.getFlightName();
            String flightSegmentIdAndScheduledDepartureTimeQueryString = segId + deptDate.toString();
            List<Flight> flights = flightSegmentAndDataToFlightCache
                    .get(flightSegmentIdAndScheduledDepartureTimeQueryString);
    
            if (flights == null) {
                flights = new ArrayList<Flight>();
                if (session == null) {
                    session = sessionManager.getObjectGridSession();
                    if (!session.isTransactionActive()) {
                        startedTran = true;
                        session.begin();
                    }
                }
                Flight flight;
                // Has to make the partition field last otherwise getting exception
                ObjectQuery query = session.createObjectQuery(
                        "select obj from Flight obj where obj.scheduledDepartureTime=?1 and obj.flightSegmentId=?2");
                query.setParameter(1, deptDate);
                query.setParameter(2, segId);
    
                int partitionId = sessionManager.getBackingMap(FLIGHT_MAP_NAME).getPartitionManager()
                        .getPartition(segId);
                query.setPartition(partitionId);
                @SuppressWarnings("unchecked")
                Iterator<Object> itr = query.getResultIterator();
    
                while (itr.hasNext()) {
                    flight = (Flight) itr.next();
                    flight.setFlightSegment(segment);
                    flights.add(flight);
                }
    
                flightSegmentAndDataToFlightCache.putIfAbsent(flightSegmentIdAndScheduledDepartureTimeQueryString,
                        flights);
    
                if (startedTran)
                    session.commit();
            }
            return flights;
    
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }