Example usage for javax.servlet.http HttpSession getId

List of usage examples for javax.servlet.http HttpSession getId

Introduction

In this page you can find the example usage for javax.servlet.http HttpSession getId.

Prototype

public String getId();

Source Link

Document

Returns a string containing the unique identifier assigned to this session.

Usage

From source file:Controller.ProviderController.java

@RequestMapping(value = "/Package/PreView/{packageID}", method = RequestMethod.GET)
public String goToPreview(@PathVariable("packageID") int packageID, HttpSession session, ModelMap model) {
    try {//  w w  w  . ja va2  s .co  m
        String reportType = commonService.getReportType();
        String json = providerService.getTemporaryPackageForPreviewing(packageID, true);
        model.addAttribute("ReportType", reportType);

        // if temporary package data is not correct
        if (json.equals("fail")) {
            return "forward:/Provider/Package/Creation/";
        } else {
            model.addAttribute("isFinished", true);
            model.addAttribute("packageDTO", json);
            model.addAttribute("toDate", commonService.getToDateUnderFormatMMddyyyy());
            return "provider/packagePreview";
        }
    } catch (Exception e) {
        String content = "Function: ProviderController - goToPreview\n" + "****Error****\n" + e.getMessage()
                + "\n" + "**********";
        model.addAttribute("errorID", session.getId());
        model.addAttribute("errorTime", errorService.logBugWithAccount(content, session, e));
        return "forward:/Common/Error";
    }
}

From source file:de.sub.goobi.metadaten.Metadaten.java

/**
 * identifyImage.//from  ww  w.j av a 2s. co  m
 *
 * @param welches
 *            int
 */
public void identifyImage(int welches) {
    /*
     * wenn die Bilder nicht angezeigt werden, brauchen wir auch das Bild
     * nicht neu umrechnen
     */
    logger.trace("start identifyImage 1");
    if (!this.displayImage) {
        logger.trace("end identifyImage 1");
        return;
    }
    logger.trace("ocr identifyImage");
    this.ocrResult = "";

    logger.trace("dataList");
    List<URI> dataList = this.imageHelper.getImageFiles(digitalDocument.getPhysicalDocStruct());
    logger.trace("dataList 2");
    if (ConfigCore.getBooleanParameter(Parameters.WITH_AUTOMATIC_PAGINATION, true)
            && (dataList == null || dataList.isEmpty())) {
        try {
            createPagination();
            dataList = this.imageHelper.getImageFiles(digitalDocument.getPhysicalDocStruct());
        } catch (IOException | TypeNotAllowedForParentException e) {
            logger.error(e);
        }
    }
    if (dataList != null && dataList.size() > 0) {
        logger.trace("dataList not null");
        this.lastImage = dataList.size();
        logger.trace("myBildLetztes");
        for (int i = 0; i < dataList.size(); i++) {
            if (logger.isTraceEnabled()) {
                logger.trace("file: " + i);
            }
            if (this.image == null) {
                this.image = dataList.get(0);
            }
            /* wenn das aktuelle Bild gefunden ist, das neue ermitteln */
            if (isCurrentImageCorrectImage(dataList, i)) {
                logger.trace("index == picture");
                int pos = i + welches;
                if (logger.isTraceEnabled()) {
                    logger.trace("pos: " + pos);
                }
                /* aber keine Indexes ausserhalb des Array erlauben */
                if (pos < 0) {
                    pos = 0;
                }
                if (pos > dataList.size() - 1) {
                    pos = dataList.size() - 1;
                }
                if (this.currentTifFolder != null) {
                    if (logger.isTraceEnabled()) {
                        logger.trace("currentTifFolder: " + this.currentTifFolder);
                    }
                    dataList = this.imageHelper.getImageFiles(this.process, this.currentTifFolder);
                    if (dataList == null) {
                        return;
                    }
                }
                /* das aktuelle tif erfassen */
                if (dataList.size() > pos) {
                    this.image = dataList.get(pos);
                } else {
                    this.image = dataList.get(dataList.size() - 1);
                }
                logger.trace("found myBild");
                /* die korrekte Seitenzahl anzeigen */
                this.imageNumber = pos + 1;
                if (logger.isTraceEnabled()) {
                    logger.trace("myBildNummer: " + this.imageNumber);
                }
                /* Pages-Verzeichnis ermitteln */
                URI myPfad = ConfigCore.getTempImagesPathAsCompleteDirectory();
                if (logger.isTraceEnabled()) {
                    logger.trace("myPfad: " + myPfad);
                }
                /*
                 * den Counter fr die Bild-ID auf einen neuen Wert setzen,
                 * damit nichts gecacht wird
                 */
                this.imageCounter++;
                if (logger.isTraceEnabled()) {
                    logger.trace("myBildCounter: " + this.imageCounter);
                }

                /* Session ermitteln */
                FacesContext context = FacesContext.getCurrentInstance();
                HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
                String mySession = session.getId() + "_" + this.imageCounter + ".png";
                logger.trace("facescontext");

                /* das neue Bild zuweisen */
                try {
                    URI tiffconverterpfad = fileService.getImagesDirectory(this.process)
                            .resolve(this.currentTifFolder + "/" + this.image);
                    if (logger.isTraceEnabled()) {
                        logger.trace("tiffconverterpfad: " + tiffconverterpfad);
                    }
                    if (!fileService.fileExist(tiffconverterpfad)) {
                        tiffconverterpfad = serviceManager.getProcessService()
                                .getImagesTifDirectory(true, this.process).resolve(this.image);
                        Helper.setFehlerMeldung("formularOrdner:TifFolders", "",
                                "image " + this.image + " does not exist in folder " + this.currentTifFolder
                                        + ", using image from " + new File(serviceManager.getProcessService()
                                                .getImagesTifDirectory(true, this.process)).getName());
                    }
                    this.imageHelper.scaleFile(tiffconverterpfad, myPfad.resolve(mySession), this.imageSize,
                            this.imageRotation);
                    logger.trace("scaleFile");
                } catch (Exception e) {
                    Helper.setFehlerMeldung("could not getById image folder", e);
                    logger.error(e);
                }
                break;
            }
        }
    }
    checkImage();
}

From source file:Controller.ProviderController.java

@RequestMapping(value = "/BookingEngine", method = RequestMethod.GET)
public String toBookingEngine(HttpServletRequest request, HttpSession session) {
    try {/*from  w ww .  java2  s  .c  om*/
        AccountSession account = (AccountSession) session.getAttribute("account");
        int providerID = account.getId();
        //            request.setAttribute("bookingData", providerService.getBookingEngineDat(providerID));

        //            request.setAttribute("packages", providerService.getPackagesOfProvider(providerID));
        //            request.setAttribute("sales", providerService.getSales(null, providerID));
        String timeNow = new DateTime().toString("MM/dd/yyyy HH:mm:ss");
        request.setAttribute("timeNow", timeNow);
        //            return "provider/newBookingEngine";
        return "provider/BookingEngine";
    } catch (Exception e) {
        String content = "Function: ProviderController - toBookingEngine\n" + "****Error****\n" + e.getMessage()
                + "\n" + "**********";
        request.setAttribute("errorID", session.getId());
        request.setAttribute("errorTime", errorService.logBugWithAccount(content, session, e));
        return "forward:/Common/Error";
    }
}

From source file:Controller.ProviderController.java

@RequestMapping(value = "/Notification")
String getNotification(ModelMap map, HttpSession session) {
    try {/*from  w  ww .j  av a2  s.c  om*/
        AccountSession account = (AccountSession) session.getAttribute("account");
        List<ProviderNotification> providerNoti = providerService.getProviderNotification();
        Gson gson = new Gson();
        List<ProviderNotificationSetting> providerSetting = providerService
                .getProviderNotificationSetting(account.getId());
        List<Integer> providerSettingList = new ArrayList<Integer>();
        for (int i = 0; i < providerSetting.size(); i++) {
            providerSettingList.add(providerSetting.get(i).getProviderNotificationID());
        }
        map.addAttribute("providerSetting", gson.toJson(providerSettingList));
        map.addAttribute("providerNotification", gson.toJson(providerNoti));
        map.addAttribute("page", "providerNotification");
        return "provider/notification";
    } catch (Exception e) {
        String content = "Function: ProviderController - getNotification\n" + "****Error****\n" + e.getMessage()
                + "\n" + "**********";
        map.addAttribute("errorID", session.getId());
        map.addAttribute("errorTime", errorService.logBugWithAccount(content, session, e));
        return "forward:/Common/Error";
    }
}

From source file:Controller.ProviderController.java

@RequestMapping(value = "/ChangePassword", method = RequestMethod.POST)
public String changePassword(HttpServletRequest request) {
    try {/* ww w  .  j  a va2  s  . c o m*/
        String oldPassword = request.getParameter("currentPass");
        String newPassword = (String) request.getParameter("newPass");
        HttpSession session = request.getSession();
        AccountSession account = (AccountSession) session.getAttribute("account");
        boolean result = providerService.changeProviderPassword(account.getId(), oldPassword, newPassword);
        if (result) {
            if (request.getParameter("language") != null) {
                return "redirect:/Provider/AccountInfo" + "?language=" + request.getParameter("language");
            } else {
                return "redirect:/Provider/AccountInfo";
            }

        } else {
            request.setAttribute("message", "Your current password not correct!");
        }
        return "provider/password";
    } catch (Exception e) {
        HttpSession session = request.getSession();
        String content = "Function: ProviderController - changePassword\n" + "***Input***\n" + "currentPass: "
                + request.getParameter("currentPass") + "\n" + "newPass: " + request.getParameter("newPass")
                + "\n" + "**********\n" + "****Error****\n" + e.getMessage() + "\n" + "**********";
        request.setAttribute("errorID", session.getId());
        request.setAttribute("errorTime", errorService.logBugWithAccount(content, session, e));
        return "forward:/Common/Error";
    }
}

From source file:Controller.ProviderController.java

@RequestMapping(value = "/Package/Apply/{packageID}", method = RequestMethod.GET)
public String applyTempPackageToPreview(@PathVariable int packageID, ModelMap model, HttpSession session,
        HttpServletRequest request) {//from   ww w .  j  a  va  2 s.  co  m
    try {
        System.out.println("GETsssss");
        AccountSession account = (AccountSession) session.getAttribute("account");
        int providerID = account.getId();
        boolean isRedirectToMyPacakges = !providerService.applyTempPackageToPreview(packageID, providerID);
        if (isRedirectToMyPacakges) {
            if (request.getParameter("language") != null) {
                return "redirect:/Provider/Package" + "?language=" + request.getParameter("language");
            } else {
                return "redirect:/Provider/Package";
            }

        } else if (request.getParameter("language") != null) {
            return "provider/apply" + "?language=" + request.getParameter("language");
        } else {
            return "provider/apply";
        }
    } catch (Exception e) {
        String content = "Function: ProviderController - applyTempPackageToPreview\n" + "***Input***\n"
                + "packageID: " + packageID + "\n" + "**********\n" + "****Error****\n" + e.getMessage() + "\n"
                + "**********";
        model.addAttribute("errorID", session.getId());
        model.addAttribute("errorTime", errorService.logBugWithAccount(content, session, e));
        return "forward:/Common/Error";
    }
}

From source file:Controller.ProviderController.java

@RequestMapping(value = "/Package/Editing/{packageID}", method = RequestMethod.GET)
public String editPackage(ModelMap model, HttpSession session, @PathVariable int packageID) {
    try {/*from  w ww  .ja v a  2s. c om*/
        AccountSession account = (AccountSession) session.getAttribute("account");
        PackageDTO packageDTO = providerService.getPackage(packageID);

        if (packageDTO.getProviderID() == account.getId()) {
            String packageFormJSON = providerService.getPackageFormForEdit(account.getId());
            // change to json
            Gson gson = new Gson();
            String packageJSON = gson.toJson(packageDTO);
            // set attribute
            String mac = commonService.getGeolocation();
            model.addAttribute("packageEdit", packageJSON);
            model.addAttribute("packageForm", packageFormJSON);
            model.addAttribute("macAddress", mac);

            String timeNow = new DateTime().toString("MM/dd/yyyy");
            model.addAttribute("timeNow", timeNow);
            return "provider/editPage";

        } else {
            return "forward:/Common/Error";
        }

    } catch (Exception e) {
        String content = "Function: ProviderController - editPackage\n" + "****Error****\n" + e.getMessage()
                + "\n" + "**********";
        model.addAttribute("errorID", session.getId());
        model.addAttribute("errorTime", errorService.logBugWithAccount(content, session, e));
        return "forward:/Common/Error";
    }
}

From source file:com.azprogrammer.qgf.controllers.HomeController.java

@RequestMapping(value = "/whiteboard")
public ModelAndView doWhiteboard(ModelMap model, HttpServletRequest req, String wbId) {

    ModelAndView mav = new ModelAndView();
    mav.addAllObjects(model);/*w  w  w.  j  a  v a2s .com*/
    PersistenceManager pm = getPM();
    HttpSession session = req.getSession();
    WhiteBoard wb = null;
    List<WBMessage> messages = null;

    if ((wbId == null) || ("".equals(wbId))) {
        wbId = req.getParameter("wb");
    }

    if ((wbId != null) && (!"".equals(wbId.trim()))) {
        wbId = cleanupWbId(wbId);
        try {
            Key key = KeyFactory.stringToKey(wbId);
            wb = pm.getObjectById(WhiteBoard.class, key);
            //String query = "select from " + WBMessage.class.getName() + " where wbKey == KEY('" + wbId + "')";

            Query query = pm.newQuery(WBMessage.class, "this.wbKey == key");
            query.declareParameters("com.google.appengine.api.datastore.Key key");
            query.setOrdering("creationTime asc");
            //Collection result = (Collection)query.execute(date);

            messages = (List<WBMessage>) query.execute(key);// pm.newQuery(query).execute();

        } catch (Exception e) {
            model.put("errorMsg", e.getMessage());
        }
    } else {
        wb = new WhiteBoard();
        wb.setCreatedBySessionId(req.getSession().getId());
        wb.setCreationDate(new Date());
        wb.setReferer(req.getHeader("referer"));
        wb.setUserAgent(req.getHeader("user-agent"));
        pm.makePersistent(wb);

        ExternalRedirectView rv = new ExternalRedirectView(
                "/whiteboard/" + KeyFactory.keyToString(wb.getKey()));
        mav.setView(rv);
        return mav;

    }

    ChannelService channelService = ChannelServiceFactory.getChannelService();

    if (wb == null) {
        mav.setViewName("badWbId");
        return mav;
    }

    if (messages == null) {
        messages = new ArrayList<WBMessage>();
    }

    //don't need key data in JSON
    JsonConfig jsconfig = new JsonConfig();
    String[] exlcudes = new String[] { "key", "wbKey", "userList", "shapeId" };
    jsconfig.setExcludes(exlcudes);
    HashMap<String, Object> messagesMap = new HashMap<String, Object>();
    messagesMap.put("messages", messages);
    model.put("messageMapJSON", JSONObject.fromObject(messagesMap, jsconfig).toString());

    String wbKeyStr = KeyFactory.keyToString(wb.getKey());

    Object userNameObj = req.getSession().getAttribute("userName");
    String userName = null;
    if (userNameObj != null) {
        userName = userNameObj.toString();
        WBChannel wbc = null;
        try {
            //String query = "select from " + WBChannel.class.getName() + " where sessionId == '" + session.getId () + "' && wbKey == '" + wbKeyStr + "'";
            //List<WBChannel> channels = (List<WBChannel>) pm.newQuery(query).execute();

            Query query = pm.newQuery(WBChannel.class, "this.wbKey == key && this.sessionId == sessId");
            query.declareParameters("com.google.appengine.api.datastore.Key key, String sessId");

            List<WBChannel> channels = (List<WBChannel>) query.execute(wb.getKey(), session.getId());// pm.newQuery(query).execute();

            if ((channels != null) && (channels.size() > 0)) {
                wbc = channels.get(0);
                Transaction tx = pm.currentTransaction();
                tx.begin();
                wbc.setTime(System.currentTimeMillis());
                tx.commit();
            }
        } catch (Exception e) {

        }

        if (wbc == null) {
            wbc = new WBChannel();
            wbc.setSessionId(session.getId());
            wbc.setWbKey(wb.getKey());
            wbc.setUserName(userName);
            wbc.setTime(System.currentTimeMillis());
            wbc.setUserAgent(req.getHeader("user-agent"));
            pm.makePersistent(wbc);
        }

        pushNewUserList(wbId);

        model.put("userName", userName);
        String token = channelService.createChannel(session.getId());
        model.put("token", token);
    }

    model.put("wbId", wbKeyStr);
    if (WebUtil.isMobile(req)) {
        model.put("mobileTheme", WebUtil.getMobileTheme(req));
        mav.setViewName("mobileboard");
    } else {
        mav.setViewName("whiteboard");
    }
    return mav;
}

From source file:Controller.ProviderController.java

@RequestMapping(value = "/Package/Apply", method = RequestMethod.POST)
public String applyTempPackageToAprove(HttpServletRequest request, ModelMap model, HttpSession session) {
    try {//from  w w  w. ja va  2s .  co m
        System.out.println("sssss");
        String packageIDStr = request.getParameter("packageID");
        int packageID = Integer.parseInt(packageIDStr);
        AccountSession account = (AccountSession) session.getAttribute("account");
        int providerID = account.getId();
        boolean isRedirectToMyPacakges = !providerService.applyTempPackageToPreview(packageID, providerID);
        if (isRedirectToMyPacakges) {
            if (request.getParameter("language") != null) {
                return "redirect:/Provider/Package" + "?language=" + request.getParameter("language");
            } else {
                return "redirect:/Provider/Package";
            }

        } else if (request.getParameter("language") != null) {
            return "provider/apply" + "?language=" + request.getParameter("language");
        } else {
            return "provider/apply";
        }
    } catch (Exception e) {
        String content = "Function: ProviderController - applyTempPackageToAprove\n" + "***Input***\n"
                + "packageID: " + request.getParameter("packageID") + "\n" + "**********\n" + "****Error****\n"
                + e.getMessage() + "\n" + "**********";
        model.addAttribute("errorID", session.getId());
        model.addAttribute("errorTime", errorService.logBugWithAccount(content, session, e));
        return "forward:/Common/Error";
    }
}