List of usage examples for javax.servlet.http HttpSession getServletContext
public ServletContext getServletContext();
From source file:be.fedict.eid.idp.protocol.saml2.AbstractSAML2ProtocolService.java
public ReturnResponse handleReturnResponse(HttpSession httpSession, String userId, Map<String, Attribute> attributes, SecretKey secretKey, PublicKey publicKey, String rpTargetUrl, HttpServletRequest request, HttpServletResponse response) throws Exception { LOG.debug("handle return response"); LOG.debug("userId: " + userId); String targetUrl = rpTargetUrl; if (null == targetUrl) { targetUrl = getTargetUrl(httpSession); }// www . j a v a 2 s. c o m IdentityProviderConfiguration configuration = getIdPConfiguration(httpSession.getServletContext()); String requestIssuer = getIssuer(httpSession); String relayState = getRelayState(httpSession); String inResponseTo = getInResponseTo(httpSession); String issuerName = getResponseIssuer(configuration); Response samlResponse = Saml2Util.getResponse(inResponseTo, targetUrl, issuerName); // generate assertion Assertion assertion = Saml2Util.getAssertion(issuerName, inResponseTo, requestIssuer, targetUrl, configuration.getResponseTokenValidity(), samlResponse.getIssueInstant(), getAuthenticationPolicy(), userId, attributes, secretKey, publicKey); samlResponse.getAssertions().add(assertion); return handleSamlResponse(request, targetUrl, samlResponse, relayState); }
From source file:com.orchestra.portale.controller.NewPoiController.java
@RequestMapping(value = "/insertpoi", method = RequestMethod.POST) public ModelAndView insertPoi(@RequestParam Map<String, String> params, @RequestParam("file") MultipartFile[] files, @RequestParam("cover") MultipartFile cover, HttpServletRequest request) throws InterruptedException { CompletePOI poi = new CompletePOI(); CompletePOI poitest = new CompletePOI(); ModelAndView model = new ModelAndView("insertpoi"); ModelAndView model2 = new ModelAndView("errorViewPoi"); poitest = pm.findOneCompletePoiByName(params.get("name")); if (poitest != null && poitest.getName().toLowerCase().equals(params.get("name").toLowerCase())) { model2.addObject("err", "Esiste gi un poi chiamato " + params.get("name")); return model2; } else {//from www. java 2 s.com poi.setName(params.get("name")); poi.setVisibility(params.get("visibility")); poi.setAddress(params.get("address")); double lat = Double.parseDouble(params.get("latitude")); double longi = Double.parseDouble(params.get("longitude")); poi.setLocation(new double[] { lat, longi }); poi.setShortDescription(params.get("shortd")); int i = 1; ArrayList<String> categories = new ArrayList<String>(); while (params.containsKey("category" + i)) { categories.add(params.get("category" + i)); i = i + 1; } poi.setCategories(categories); ArrayList<AbstractPoiComponent> listComponent = new ArrayList<AbstractPoiComponent>(); //componente cover if (!cover.isEmpty()) { CoverImgComponent coverimg = new CoverImgComponent(); coverimg.setLink("cover.jpg"); listComponent.add(coverimg); } //componente galleria immagini ArrayList<ImgGallery> links = new ArrayList<ImgGallery>(); if (files.length > 0) { ImgGalleryComponent img_gallery = new ImgGalleryComponent(); i = 0; while (i < files.length) { ImgGallery img = new ImgGallery(); Thread.sleep(100); Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("MMddyyyyhmmssSSa"); String currentTimestamp = sdf.format(date); img.setLink("img_" + currentTimestamp + ".jpg"); if (params.containsKey("credit" + (i + 1))) img.setCredit(params.get("credit" + (i + 1))); i = i + 1; links.add(img); } img_gallery.setLinks(links); listComponent.add(img_gallery); } //componente contatti ContactsComponent contacts_component = new ContactsComponent(); //Recapiti telefonici i = 1; boolean contacts = false; if (params.containsKey("tel" + i)) { ArrayList<PhoneContact> phoneList = new ArrayList<PhoneContact>(); while (params.containsKey("tel" + i)) { PhoneContact phone = new PhoneContact(); if (params.containsKey("tel" + i)) { phone.setLabel(params.get("desctel" + i)); } phone.setNumber(params.get("tel" + i)); phoneList.add(phone); i = i + 1; } contacts = true; contacts_component.setPhoneList(phoneList); } //Recapiti mail i = 1; if (params.containsKey("email" + i)) { ArrayList<EmailContact> emailList = new ArrayList<EmailContact>(); while (params.containsKey("email" + i)) { EmailContact email = new EmailContact(); if (params.containsKey("email" + i)) { email.setLabel(params.get("descemail" + i)); } email.setEmail(params.get("email" + i)); emailList.add(email); i = i + 1; } contacts = true; contacts_component.setEmailsList(emailList); } //Recapiti fax i = 1; if (params.containsKey("fax" + i)) { ArrayList<FaxContact> faxList = new ArrayList<FaxContact>(); while (params.containsKey("fax" + i)) { FaxContact fax = new FaxContact(); if (params.containsKey("fax" + i)) { fax.setLabel(params.get("descfax" + i)); } fax.setFax(params.get("fax" + i)); faxList.add(fax); i = i + 1; } contacts = true; contacts_component.setFaxList(faxList); } //Social predefiniti i = 1; if (params.containsKey("SN" + i)) { while (params.containsKey("SN" + i)) { if (params.get("SN" + i).equals("facebook")) { contacts = true; contacts_component.setFacebook(params.get("LSN" + i)); } if (params.get("SN" + i).equals("twitter")) { contacts = true; contacts_component.setTwitter(params.get("LSN" + i)); } if (params.get("SN" + i).equals("google")) { contacts = true; contacts_component.setGoogle(params.get("LSN" + i)); } if (params.get("SN" + i).equals("skype")) { contacts = true; contacts_component.setSkype(params.get("LSN" + i)); } i = i + 1; } } //Social personalizzati i = 1; if (params.containsKey("CSN" + i)) { ArrayList<GenericSocial> customsocial = new ArrayList<GenericSocial>(); while (params.containsKey("CSN" + i)) { GenericSocial social = new GenericSocial(); contacts = true; social.setLabel(params.get("CSN" + i)); social.setSocial(params.get("LCSN" + i)); customsocial.add(social); i = i + 1; } contacts_component.setSocialList(customsocial); } if (contacts == true) { listComponent.add(contacts_component); } //DESCRIPTION COMPONENT i = 1; if (params.containsKey("par" + i)) { ArrayList<Section> list = new ArrayList<Section>(); while (params.containsKey("par" + i)) { Section section = new Section(); if (params.containsKey("titolo" + i)) { section.setTitle(params.get("titolo" + i)); } section.setDescription(params.get("par" + i)); list.add(section); i = i + 1; } DescriptionComponent description_component = new DescriptionComponent(); description_component.setSectionsList(list); listComponent.add(description_component); } //Orari i = 1; int k = 1; boolean ok = false; String gg = ""; boolean[] aperto = new boolean[8]; for (int z = 1; z <= 7; z++) { aperto[z] = false; } WorkingTimeComponent workingtime = new WorkingTimeComponent(); if (params.containsKey("WD" + i + "start" + k + "H")) { ok = true; ArrayList<CompactWorkingDays> workingdays = new ArrayList<CompactWorkingDays>(); while (params.containsKey("WD" + i)) { ArrayList<WorkingHours> Listwh = new ArrayList<WorkingHours>(); k = 1; while (params.containsKey("WD" + i + "start" + k + "H")) { WorkingHours wh = new WorkingHours(); wh.setStart(params.get("WD" + i + "start" + k + "H") + ":" + params.get("WD" + i + "start" + k + "M")); wh.setEnd(params.get("WD" + i + "end" + k + "H") + ":" + params.get("WD" + i + "end" + k + "M")); Listwh.add(wh); k = k + 1; } CompactWorkingDays cwd = new CompactWorkingDays(); cwd.setDays(params.get("WD" + i)); cwd.setWorkinghours(Listwh); workingdays.add(cwd); i = i + 1; } int grn = 1; ArrayList<CompactWorkingDays> wdef = new ArrayList<CompactWorkingDays>(); for (int z = 1; z <= 7; z++) { aperto[z] = false; } while (grn <= 7) { for (CompactWorkingDays g : workingdays) { if (grn == 1 && g.getDays().equals("Luned")) { aperto[1] = true; wdef.add(g); } if (grn == 2 && g.getDays().equals("Marted")) { aperto[2] = true; wdef.add(g); } if (grn == 3 && g.getDays().equals("Mercoled")) { aperto[3] = true; wdef.add(g); } if (grn == 4 && g.getDays().equals("Gioved")) { aperto[4] = true; wdef.add(g); } if (grn == 5 && g.getDays().equals("Venerd")) { aperto[5] = true; wdef.add(g); } if (grn == 6 && g.getDays().equals("Sabato")) { aperto[6] = true; wdef.add(g); } if (grn == 7 && g.getDays().equals("Domenica")) { aperto[7] = true; wdef.add(g); } } grn++; } workingtime.setWorkingdays(wdef); for (int z = 1; z <= 7; z++) { if (aperto[z] == false && z == 1) gg = gg + " " + "Luned"; if (aperto[z] == false && z == 2) gg = gg + " " + "Marted"; if (aperto[z] == false && z == 3) gg = gg + " " + "Mercoled"; if (aperto[z] == false && z == 4) gg = gg + " " + "Gioved"; if (aperto[z] == false && z == 5) gg = gg + " " + "Venerd"; if (aperto[z] == false && z == 6) gg = gg + " " + "Sabato"; if (aperto[z] == false && z == 7) gg = gg + " " + "Domenica"; } if (!gg.equals("")) { ok = true; workingtime.setWeekly_day_of_rest(gg); } } i = 1; String ggs = ""; while (params.containsKey("RDA" + i)) { ggs = ggs + " " + params.get("RDA" + i); i = i + 1; } if (!ggs.equals("")) { ok = true; workingtime.setDays_of_rest(ggs); } if (ok) { listComponent.add(workingtime); } i = 1; if (params.containsKey("type" + i)) { PricesComponent pc = new PricesComponent(); ArrayList<TicketPrice> tpList = new ArrayList<TicketPrice>(); while (params.containsKey("type" + i)) { TicketPrice tp = new TicketPrice(); tp.setType(params.get("type" + i)); double dp = Double.parseDouble(params.get("price" + i)); tp.setPrice(dp); tp.setType_description(params.get("typedesc" + i)); tpList.add(tp); i = i + 1; } pc.setPrices(tpList); listComponent.add(pc); } i = 1; if (params.containsKey("SERV" + i)) { ArrayList<String> servList = new ArrayList<String>(); while (params.containsKey("SERV" + i)) { servList.add(params.get("SERV" + i)); i = i + 1; } ServicesComponent servicescomponent = new ServicesComponent(); servicescomponent.setServicesList(servList); listComponent.add(servicescomponent); } poi.setComponents(listComponent); pm.savePoi(poi); CompletePOI poi2 = (CompletePOI) pm.findOneCompletePoiByName(poi.getName()); for (int z = 0; z < files.length; z++) { MultipartFile file = files[z]; try { byte[] bytes = file.getBytes(); // Creating the directory to store file HttpSession session = request.getSession(); ServletContext sc = session.getServletContext(); File dir = new File(sc.getRealPath("/") + "dist" + File.separator + "poi" + File.separator + "img" + File.separator + poi2.getId()); if (!dir.exists()) dir.mkdirs(); // Create the file on server File serverFile = new File(dir.getAbsolutePath() + File.separator + links.get(z).getLink()); BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(serverFile)); stream.write(bytes); stream.close(); } catch (Exception e) { return model; } } MultipartFile file = cover; try { byte[] bytes = file.getBytes(); // Creating the directory to store file HttpSession session = request.getSession(); ServletContext sc = session.getServletContext(); File dir = new File(sc.getRealPath("/") + "dist" + File.separator + "poi" + File.separator + "img" + File.separator + poi2.getId()); if (!dir.exists()) dir.mkdirs(); // Create the file on server File serverFile = new File(dir.getAbsolutePath() + File.separator + "cover.jpg"); BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(serverFile)); stream.write(bytes); stream.close(); } catch (Exception e) { return model; } return model; } }
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.MenuEditingFormGenerator.java
private void generateSelectForExisting(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration, Individual subject, ObjectProperty prop, WebappDaoFactory wdf) {/*from w w w . j a va 2 s. co m*/ if (prop.getSelectFromExisting()) { // set ProhibitedFromSearch object so picklist doesn't show // individuals from classes that should be hidden from list views OntModel displayOntModel = (OntModel) session.getServletContext().getAttribute("displayOntModel"); if (displayOntModel != null) { ProhibitedFromSearch pfs = new ProhibitedFromSearch(DisplayVocabulary.SEARCH_INDEX_URI, displayOntModel); if (editConfiguration != null) editConfiguration.setProhibitedFromSearch(pfs); } Map<String, String> rangeOptions = SelectListGeneratorVTwo.getOptions(editConfiguration, "objectVar", wdf); if (rangeOptions != null && rangeOptions.size() > 0) { vreq.setAttribute("rangeOptionsExist", true); vreq.setAttribute("rangeOptions.objectVar", rangeOptions); } else { vreq.setAttribute("rangeOptionsExist", false); } } }
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.DefaultObjectPropertyFormGenerator.java
private void processProhibitedFromSearch(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfig) { if (isSelectFromExisting(vreq)) { // set ProhibitedFromSearch object so picklist doesn't show // individuals from classes that should be hidden from list views OntModel displayOntModel = ModelAccess.on(session.getServletContext()).getOntModel(DISPLAY); ProhibitedFromSearch pfs = new ProhibitedFromSearch(DisplayVocabulary.SEARCH_INDEX_URI, displayOntModel);//from w ww . j a v a 2s.co m if (editConfig != null) editConfig.setProhibitedFromSearch(pfs); } }
From source file:edu.mit.csail.sls.wami.relay.WamiRelay.java
public void handleClientUpdate(HttpSession session, String xmlUpdate) { Document doc = XmlUtils.toXMLDocument(xmlUpdate); Element root = (Element) doc.getFirstChild(); logClientEvent(xmlUpdate, root);//w w w . j av a 2 s.com String type = root.getAttribute("type"); if ("hotswap".equals(type)) { hotswapComponent(WamiConfig.getConfiguration(session.getServletContext()), root); } else if (wamiApp != null) { wamiApp.onClientMessage(root); } else { System.err.println("warming: handleClientUpdate called with null wami app"); } }
From source file:uk.ac.ebi.ep.controller.SearchController.java
/** * Processes the search request. When user enters a search text and presses * the submit button the request is processed here. * * @param searchModel/* www . ja va2 s.c o m*/ * @param model * @param session * @param request * @return */ @RequestMapping(value = "/search", method = RequestMethod.POST) public String postSearchResult(SearchModel searchModel, Model model, HttpSession session, HttpServletRequest request) { String view = "error"; String searchKey = null; SearchResults results = null; try { // See if it is already there, perhaps we are paginating: Map<String, SearchResults> prevSearches = getPreviousSearches(session.getServletContext()); searchKey = getSearchKey(searchModel.getSearchparams()); results = prevSearches.get(searchKey); if (results == null) { // New search: clearHistory(session); switch (searchModel.getSearchparams().getType()) { case KEYWORD: results = searchKeyword(searchModel.getSearchparams()); LOGGER.warn("keyword search=" + searchModel.getSearchparams().getText()); break; case SEQUENCE: view = searchSequence(model, searchModel); break; case COMPOUND: results = searchCompound(model, searchModel); break; default: } } if (results != null) { // something to show cacheSearch(session.getServletContext(), searchKey, results); setLastSummaries(session, results.getSummaryentries()); searchModel.setSearchresults(results); applyFilters(searchModel, request); model.addAttribute("searchConfig", searchConfig); model.addAttribute("searchModel", searchModel); model.addAttribute("pagination", getPagination(searchModel)); clearHistory(session); addToHistory(session, searchModel.getSearchparams().getType(), searchKey); view = "search"; } } catch (Exception e) { LOGGER.error("one of the search params (Text or Sequence is :" + searchKey, e); } return view; }
From source file:com.crimelab.service.PolygraphServiceImpl.java
@Override public XWPFDocument create(Polygraph polygraph, HttpSession session) { XWPFDocument document = null;// w w w.j a v a 2s . c om //Insert into dbase // polygraphDAO.polygraphInfo(polygraph); try { //Blank Document InputStream inpDocx = session.getServletContext() .getResourceAsStream("/WEB-INF/templates/Polygraph.docx"); document = new XWPFDocument(inpDocx); //create Paragraph XWPFParagraph subjectNo = document.createParagraph(); XWPFRun r1 = subjectNo.createRun(); r1.setText("POLYGRAPH SUBJECT NO: " + polygraph.getSubjectNo()); subjectNo.setAlignment(ParagraphAlignment.CENTER); r1.setBold(true); ; //create table XWPFTable table = document.createTable(); //width CTTbl tableFix = table.getCTTbl(); CTTblPr pr = tableFix.getTblPr(); CTTblWidth tblW = pr.getTblW(); tblW.setW(BigInteger.valueOf(4800)); tblW.setType(STTblWidth.PCT); pr.setTblW(tblW); tableFix.setTblPr(pr); //create first row XWPFTableRow tableRowOne = table.getRow(0); XWPFTableCell headerCell = tableRowOne.getCell(0); XWPFParagraph headerParagraph = headerCell.getParagraphs().get(0); XWPFRun hRun = headerParagraph.createRun(); headerCell.setColor("CDCDB4"); hRun.setText("PERSONAL INFORMATION"); tableRowOne.addNewTableCell().setText(null); headerParagraph.setAlignment(ParagraphAlignment.CENTER); XWPFTableCell photoHeaderCell = tableRowOne.getCell(1); XWPFParagraph photoHeaderParagraph = photoHeaderCell.getParagraphs().get(0); XWPFRun pRun = photoHeaderParagraph.createRun(); photoHeaderCell.setColor("CDCDB4"); pRun.setText("PHOTO"); photoHeaderParagraph.setAlignment(ParagraphAlignment.CENTER); XWPFTableRow tableRowTwo = table.createRow(); XWPFTableCell cell = tableRowTwo.getCell(0); XWPFParagraph personalInfo = cell.getParagraphs().get(0); XWPFRun r2 = personalInfo.createRun(); r2.setText("Name"); r2.addTab(); r2.addTab(); r2.setText(": " + polygraph.getName()); r2.addBreak(); r2.setText("Gender"); r2.addTab(); r2.addTab(); r2.setText(": " + polygraph.getGender()); r2.addBreak(); r2.setText("Age"); r2.addTab(); r2.addTab(); r2.setText(": " + polygraph.getAge()); r2.addBreak(); r2.setText("Date of Birth"); r2.addTab(); r2.setText(": " + polygraph.getBirthdate()); r2.addBreak(); r2.setText("Civil Status"); r2.addTab(); r2.setText(": " + polygraph.getCivilStatus()); r2.addBreak(); r2.setText("ID Presented"); r2.addTab(); r2.setText(": " + polygraph.getIdPresented()); r2.addBreak(); r2.setText("Address"); r2.addTab(); r2.setText(": " + polygraph.getAddress()); //Adding the picture XWPFTableCell pictureCell = tableRowTwo.getCell(1); XWPFParagraph pictureHolder = pictureCell.getParagraphs().get(0); XWPFRun pictureRun = pictureHolder.createRun(); FileInputStream getPhoto = new FileInputStream(polygraph.getPhotoLocation()); FileInputStream getImage = new FileInputStream(polygraph.getPhotoLocation()); ImageInputStream imageInput = ImageIO.createImageInputStream(getPhoto); BufferedImage bi = ImageIO.read(imageInput); pictureHolder.setAlignment(ParagraphAlignment.RIGHT); pictureRun.addPicture(getImage, XWPFDocument.PICTURE_TYPE_JPEG, null, Units.toEMU(120), Units.toEMU(120)); XWPFParagraph spacing = document.createParagraph(); XWPFRun spacingRun = spacing.createRun(); //create table XWPFTable otherTable = document.createTable(); //width CTTbl tableFixTwo = otherTable.getCTTbl(); CTTblPr prTwo = tableFixTwo.getTblPr(); CTTblWidth tblWTwo = prTwo.getTblW(); tblWTwo.setW(BigInteger.valueOf(4800)); tblWTwo.setType(STTblWidth.PCT); prTwo.setTblW(tblWTwo); tableFixTwo.setTblPr(prTwo); XWPFTableRow examInfoHeader = otherTable.createRow(); XWPFTableCell cellInfo = examInfoHeader.getCell(0); XWPFParagraph examInfo = cellInfo.getParagraphs().get(0); XWPFRun r3 = examInfo.createRun(); cellInfo.setColor("CDCDB4"); r3.setText("EXAM INFORMATION"); examInfo.setAlignment(ParagraphAlignment.CENTER); XWPFTableRow examInfoRow = otherTable.createRow(); XWPFTableCell cellRowInfo = examInfoRow.getCell(0); XWPFParagraph examInfoRowP = cellRowInfo.getParagraphs().get(0); XWPFRun examRun = examInfoRowP.createRun(); examRun.setText("Case Number"); examRun.addTab(); examRun.addTab(); examRun.setText(": " + polygraph.getCaseNo()); examRun.addBreak(); examRun.setText("Requesting Party"); examRun.addTab(); examRun.setText(": " + polygraph.getRequestingParty()); examRun.addBreak(); examRun.setText("Time/Date Received"); examRun.addTab(); examRun.setText(": " + polygraph.getTimeDateReceived()); examRun.addBreak(); examRun.setText("Nature of Case"); examRun.addTab(); examRun.addTab(); examRun.setText(": " + polygraph.getNatureOfCase()); examRun.addBreak(); examRun.setText("Exam Location"); examRun.addTab(); examRun.addTab(); examRun.setText(": " + polygraph.getExamLocation()); examRun.addBreak(); examRun.setText("Exam Date"); examRun.addTab(); examRun.addTab(); examRun.setText(": " + polygraph.getExamDate()); otherTable.removeRow(0); XWPFParagraph purposeOfExamination = document.createParagraph(); XWPFRun r4 = purposeOfExamination.createRun(); r4.setUnderline(UnderlinePatterns.SINGLE); r4.addBreak(); r4.setText("SECTION 1: PURPOSE OF EXAMINATION"); r4.addTab(); r4.addTab(); r4.addTab(); r4.addTab(); r4.addTab(); r4.addTab(); r4.addTab(); r4.addTab(); r4.addTab(); XWPFParagraph purposeOfExaminationContents = document.createParagraph(); XWPFRun r4Contents = purposeOfExaminationContents.createRun(); r4Contents.setText(polygraph.getPurpose()); XWPFParagraph preTestInterview = document.createParagraph(); XWPFRun r5 = preTestInterview.createRun(); r5.setUnderline(UnderlinePatterns.SINGLE); r5.setText("SECTION 2: PRE-TEST INTERVIEW"); r5.addTab(); r5.addTab(); r5.addTab(); r5.addTab(); r5.addTab(); r5.addTab(); r5.addTab(); r5.addTab(); r5.addTab(); XWPFParagraph preTestInterviewContents = document.createParagraph(); XWPFRun r5Contents = preTestInterviewContents.createRun(); r5Contents.setText(polygraph.getPreTest()); XWPFParagraph inTestPhase = document.createParagraph(); XWPFRun r6 = inTestPhase.createRun(); r6.setUnderline(UnderlinePatterns.SINGLE); r6.setText("SECTION 3: IN-TEST PHASE"); r6.addTab(); r6.addTab(); r6.addTab(); r6.addTab(); r6.addTab(); r6.addTab(); r6.addTab(); r6.addTab(); r6.addTab(); r6.addTab(); XWPFParagraph inTestPhaseContents = document.createParagraph(); XWPFRun r6Contents = inTestPhaseContents.createRun(); r6Contents.setText(polygraph.getInTest()); XWPFParagraph result = document.createParagraph(); XWPFRun r7 = result.createRun(); r7.setUnderline(UnderlinePatterns.SINGLE); r7.setText("SECTION 4: RESULT"); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); r7.addTab(); XWPFParagraph resultContents = document.createParagraph(); XWPFRun r7Contents = resultContents.createRun(); r7Contents.setText(polygraph.getResult()); XWPFParagraph postTestInterview = document.createParagraph(); XWPFRun r8 = postTestInterview.createRun(); r8.setUnderline(UnderlinePatterns.SINGLE); r8.setText("SECTION 5: POST-TEST INTERVIEW"); r8.addTab(); r8.addTab(); r8.addTab(); r8.addTab(); r8.addTab(); r8.addTab(); r8.addTab(); r8.addTab(); r8.addTab(); XWPFParagraph postTestInterviewContents = document.createParagraph(); XWPFRun r8Contents = postTestInterviewContents.createRun(); r8Contents.setText(polygraph.getPostTest()); XWPFParagraph remarks = document.createParagraph(); XWPFRun r9 = remarks.createRun(); r9.setUnderline(UnderlinePatterns.SINGLE); r9.setText("REMARKS:"); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); r9.addTab(); XWPFParagraph remarksContents = document.createParagraph(); XWPFRun r9Contents = remarksContents.createRun(); r9Contents.setText(polygraph.getRemarks()); XWPFParagraph timeDateCompleted = document.createParagraph(); XWPFRun r10 = timeDateCompleted.createRun(); r10.setUnderline(UnderlinePatterns.SINGLE); r10.setText("TIME AND DATE COMPLETED:"); r10.addTab(); r10.addTab(); r10.addTab(); r10.addTab(); r10.addTab(); r10.addTab(); r10.addTab(); r10.addTab(); r10.addTab(); r10.addTab(); XWPFParagraph timeDateCompletedContents = document.createParagraph(); XWPFRun r10Contents = timeDateCompletedContents.createRun(); r10Contents.setText(polygraph.getTimeDateCompleted()); XWPFParagraph examinedBy = document.createParagraph(); XWPFRun r11 = examinedBy.createRun(); r11.setUnderline(UnderlinePatterns.SINGLE); r11.setText("EXAMINED BY:"); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); r11.addTab(); XWPFParagraph examinedByContents = document.createParagraph(); XWPFRun r11Contents = examinedByContents.createRun(); r11Contents.setText(polygraph.getExaminerName()); r11Contents.addBreak(); r11Contents.setText(polygraph.getExaminerRank()); r11Contents.addBreak(); r11Contents.setText(polygraph.getExaminerPosition()); XWPFParagraph approvedBy = document.createParagraph(); XWPFRun r12 = approvedBy.createRun(); r12.setUnderline(UnderlinePatterns.SINGLE); r12.setText("APPROVED BY:"); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); r12.addTab(); XWPFParagraph approvedByContents = document.createParagraph(); XWPFRun r12Contents = approvedByContents.createRun(); // r12Contents.setText(polygraph.getApprovedName()); // r12Contents.addBreak(); // r12Contents.setText(polygraph.getApprovedRank()); // r12Contents.addBreak(); // r12Contents.setText(polygraph.getApprovedPosition()); // r12Contents.addBreak(); XWPFParagraph notedBy = document.createParagraph(); XWPFRun r13 = notedBy.createRun(); r13.setUnderline(UnderlinePatterns.SINGLE); r13.setText("NOTED BY:"); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); r13.addTab(); XWPFParagraph notedByContents = document.createParagraph(); XWPFRun r13Contents = notedByContents.createRun(); r13Contents.setText(polygraph.getNotedName()); r13Contents.addBreak(); r13Contents.setText(polygraph.getNotedRank()); r13Contents.addBreak(); r13Contents.setText(polygraph.getNotedPosition()); r13Contents.addBreak(); table.setInsideVBorder(XWPFTable.XWPFBorderType.NIL, 0, 0, "white"); document.getXWPFDocument(); } catch (Exception e) { e.printStackTrace(); } return document; }
From source file:org.wise.portal.presentation.web.filters.WISEAuthenticationProcessingFilter.java
@Override protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authentication) throws IOException, ServletException { HttpSession session = request.getSession(); //get the user UserDetails userDetails = (UserDetails) authentication.getPrincipal(); User user = userService.retrieveUser(userDetails); session.setAttribute(User.CURRENT_USER_SESSION_KEY, user); if (LOGGER.isDebugEnabled()) { LOGGER.debug("UserDetails logging in: " + userDetails.getUsername()); }// w w w . j ava 2 s. c o m // add new session in a allLoggedInUsers servletcontext HashMap variable String sessionId = session.getId(); HashMap<String, User> allLoggedInUsers = (HashMap<String, User>) session.getServletContext() .getAttribute("allLoggedInUsers"); if (allLoggedInUsers == null) { allLoggedInUsers = new HashMap<String, User>(); session.getServletContext().setAttribute(WISESessionListener.ALL_LOGGED_IN_USERS, allLoggedInUsers); } allLoggedInUsers.put(sessionId, user); super.successfulAuthentication(request, response, chain, authentication); }
From source file:Admin_Thesaurus.ImportData.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (SystemIsLockedForAdministrativeJobs(request, response)) { return;//from ww w . jav a 2s . com } String basePath = request.getSession().getServletContext().getRealPath(""); // ---------------------- LOCK SYSTEM ---------------------- ConfigDBadmin config = new ConfigDBadmin(basePath); DBAdminUtilities dbAdminUtils = new DBAdminUtilities(); dbAdminUtils.LockSystemForAdministrativeJobs(config); response.setContentType("text/html;charset=UTF-8"); request.setCharacterEncoding("UTF-8"); HttpSession session = request.getSession(); ServletContext context = session.getServletContext(); SessionWrapperClass sessionInstance = new SessionWrapperClass(); init(request, response, sessionInstance); PrintWriter out = response.getWriter(); OutputStreamWriter logFileWriter = null; try { // check for previous logon but because of ajax usage respond with Session Invalidate str UserInfoClass SessionUserInfo = (UserInfoClass) sessionInstance.getAttribute("SessionUser"); if (SessionUserInfo == null || !SessionUserInfo.servletAccessControl(this.getClass().getName())) { out.println("Session Invalidate"); response.sendRedirect("Index"); return; } //tools Utilities u = new Utilities(); DBGeneral dbGen = new DBGeneral(); DBImportData dbImport = new DBImportData(); DBMergeThesauri dbMerge = new DBMergeThesauri(); StringObject translatedMsgObj = new StringObject(""); Vector<String> thesauriNames = new Vector<String>(); CommonUtilsDBadmin common_utils = new CommonUtilsDBadmin(config); StringObject resultObj = new StringObject(""); String initiallySelectedThesaurus = SessionUserInfo.selectedThesaurus; //Parameters String xmlFilePath = request.getParameter("importXMLfilename"); //String importSchemaName = request.getParameter("schematype"); String importSchemaName = ConstantParameters.xmlschematype_THEMAS; String importThesaurusName = request.getParameter("Import_Thesaurus_NewName_NAME"); String importMethodChoice = request.getParameter("ImportThesaurusMode");//thesaurusImport or bulkImport String importHierarchyName = u .getDecodedParameterValue(request.getParameter("Import_Thesaurus_HierarchyName")); String pathToErrorsXML = context.getRealPath("/translations/Consistencies_Error_Codes.xml"); String language = context.getInitParameter("LocaleLanguage"); String country = context.getInitParameter("LocaleCountry"); String WebAppUsersFileName = request.getSession().getServletContext() .getRealPath("/" + UsersClass.WebAppUsersXMLFilePath); String logPath = context.getRealPath("/" + ConstantParameters.LogFilesFolderName); String logFileNamePath = logPath; String webAppSaveResults_Folder = Parameters.Save_Results_Folder; String pathToSaveScriptingAndLocale = context .getRealPath("/translations/SaveAll_Locale_And_Scripting.xml"); Locale targetLocale = new Locale(language, country); if ((importMethodChoice.equals("thesaurusImport") && (importThesaurusName != null)) || (importMethodChoice.equals("bulkImport") && importHierarchyName != null)) { UpDownFiles fup = new UpDownFiles(); String[] formData = new String[10]; FileItem[] dom = fup.prepareToUpBinary(request, formData); //Hashtable initParams = UpDownFiles.uploadParams; if (dom[0] != null) { String filename = xmlFilePath; ///String caption = (String) initParams.get("caption"); filename = filename.substring(filename.lastIndexOf(File.separator) + 1); String fileType = filename.substring(filename.lastIndexOf(".") + 1); String userFileName = filename.substring(0, filename.lastIndexOf(".")); filename = userFileName + "(" + getDate() + " " + getTime() + ")." + fileType; String fullPath = getServletContext().getRealPath("/Uploads") + "/" + filename; xmlFilePath = fullPath; if (fup.writeBinary(dom[0], fullPath)) { //mode = 1; } else { //mode = -1; } } else { //mode = -1; } } QClass Q = new QClass(); TMSAPIClass TA = new TMSAPIClass(); IntegerObject sis_session = new IntegerObject(); IntegerObject tms_session = new IntegerObject(); //open connection and start transaction if (dbGen.openConnectionAndStartQueryOrTransaction(Q, TA, sis_session, null, null, true) == QClass.APIFail) { Utils.StaticClass .webAppSystemOutPrintln("OPEN CONNECTION ERROR @ servlet " + this.getServletName()); return; } dbGen.GetExistingThesaurus(false, thesauriNames, Q, sis_session); if (importMethodChoice.equals("thesaurusImport")) { //Format Name Of import Thesaurus importThesaurusName = importThesaurusName.trim(); importThesaurusName = importThesaurusName.replaceAll(" ", "_"); importThesaurusName = importThesaurusName.toUpperCase(); if (thesauriNames.contains(importThesaurusName)) { resultObj.setValue(u.translateFromMessagesXML("root/ImportData/importThesaurusNameFailure", new String[] { importThesaurusName })); //resultObj.setValue("Thesaurus '" + importThesaurusName + "' already exists in database. Please choose a different name for the Thesaurus."); Vector<String> allHierarchies = new Vector<String>(); Vector<String> allGuideTerms = new Vector<String>(); dbGen.getDBAdminHierarchiesStatusesAndGuideTermsXML(SessionUserInfo, Q, sis_session, allHierarchies, allGuideTerms); //end query and close connection Q.free_all_sets(); Q.TEST_end_query(); //Q.TEST_abort_transaction(); dbGen.CloseDBConnection(Q, null, sis_session, null, false); StringBuffer xml = new StringBuffer(); xml.append(u.getXMLStart(ConstantParameters.LMENU_THESAURI)); xml.append(u.getDBAdminHierarchiesStatusesAndGuideTermsXML(allHierarchies, allGuideTerms, targetLocale)); xml.append(getXMLMiddle(thesauriNames, u.translateFromMessagesXML("root/ImportData/ImportFunctionFailure", null) + resultObj.getValue(), importMethodChoice)); xml.append(u.getXMLUserInfo(SessionUserInfo)); xml.append(u.getXMLEnd()); u.XmlPrintWriterTransform(out, xml, sessionInstance.path + "/xml-xsl/page_contents.xsl"); // ---------------------- UNLOCK SYSTEM ---------------------- dbAdminUtils.UnlockSystemForAdministrativeJobs(); return; } } else if (importMethodChoice.equals("bulkImport")) { importThesaurusName = SessionUserInfo.selectedThesaurus; if (thesauriNames.contains(importThesaurusName) == false) { //String pathToMessagesXML = context.getRealPath("/translations/Messages.xml"); //StringObject resultMessageObj = new StringObject(); StringObject resultMessageObj_2 = new StringObject(); //Vector<String> errorArgs = new Vector<String>(); resultObj.setValue(u.translateFromMessagesXML("root/ImportData/ThesaurusDoesNotExist", new String[] { importThesaurusName })); //resultObj.setValue("Thesaurus '" + importThesaurusName + "' does not exist in database. Please choose a different thesaurus if this one still exists."); Vector<String> allHierarchies = new Vector<String>(); Vector<String> allGuideTerms = new Vector<String>(); dbGen.getDBAdminHierarchiesStatusesAndGuideTermsXML(SessionUserInfo, Q, sis_session, allHierarchies, allGuideTerms); //end query and close connection Q.free_all_sets(); Q.TEST_end_query(); //Q.TEST_abort_transaction(); dbGen.CloseDBConnection(Q, null, sis_session, null, false); StringBuffer xml = new StringBuffer(); xml.append(u.getXMLStart(ConstantParameters.LMENU_THESAURI)); xml.append(u.getDBAdminHierarchiesStatusesAndGuideTermsXML(allHierarchies, allGuideTerms, targetLocale)); resultMessageObj_2 .setValue(u.translateFromMessagesXML("root/ImportData/InsertionFailure", null)); xml.append(getXMLMiddle(thesauriNames, resultMessageObj_2.getValue() + resultObj.getValue(), importMethodChoice)); //xml.append(getXMLMiddle(thesauriNames, "Data insertion failure. " + resultObj.getValue(),importMethodChoice)); xml.append(u.getXMLUserInfo(SessionUserInfo)); xml.append(u.getXMLEnd()); u.XmlPrintWriterTransform(out, xml, sessionInstance.path + "/xml-xsl/page_contents.xsl"); // ---------------------- UNLOCK SYSTEM ---------------------- dbAdminUtils.UnlockSystemForAdministrativeJobs(); return; } } //end query and close connection Q.free_all_sets(); Q.TEST_end_query(); dbGen.CloseDBConnection(Q, null, sis_session, null, false); Utils.StaticClass.closeDb(); StringObject DBbackupFileNameCreated = new StringObject(""); long startTime = Utilities.startTimer(); String time = Utilities.GetNow(); String Filename = "Import_Thesaurus_" + importThesaurusName + "_" + time; logFileNamePath += "/" + Filename + ".xml"; try { OutputStream fout = new FileOutputStream(logFileNamePath); OutputStream bout = new BufferedOutputStream(fout); logFileWriter = new OutputStreamWriter(bout, "UTF-8"); logFileWriter.append(ConstantParameters.xmlHeader);//+ "\r\n" //logFileWriter.append("<?xml-stylesheet type=\"text/xsl\" href=\"../" + webAppSaveResults_Folder + "/ImportCopyMergeThesaurus_Report.xsl" + "\"?>\r\n"); logFileWriter.append("<page language=\"" + Parameters.UILang + "\" primarylanguage=\"" + Parameters.PrimaryLang.toLowerCase() + "\">\r\n"); logFileWriter.append("<title>" + u.translateFromMessagesXML("root/ImportData/ReportTitle", new String[] { importThesaurusName, time }) + "</title>\r\n" + "<pathToSaveScriptingAndLocale>" + pathToSaveScriptingAndLocale + "</pathToSaveScriptingAndLocale>\r\n"); //logFileWriter.append("<!--"+time + " LogFile for data import in thesaurus: " + importThesaurusName +".-->\r\n"); Utils.StaticClass.webAppSystemOutPrintln(Parameters.LogFilePrefix + time + " LogFile for data import in thesaurus: " + importThesaurusName + "."); } catch (Exception exc) { Utils.StaticClass.webAppSystemOutPrintln( Parameters.LogFilePrefix + "Error in opening file: " + exc.getMessage()); Utils.StaticClass.handleException(exc); } if (importMethodChoice.equals("thesaurusImport")) { if (dbImport.thesaurusImportActions(SessionUserInfo, common_utils, config, targetLocale, pathToErrorsXML, xmlFilePath, importSchemaName, importThesaurusName, "backup_before_import_data_to_thes_" + importThesaurusName, DBbackupFileNameCreated, resultObj, logFileWriter) == false) { abortActions(request, sessionInstance, context, targetLocale, common_utils, initiallySelectedThesaurus, importThesaurusName, DBbackupFileNameCreated, resultObj, out); return; } } else if (importMethodChoice.equals("bulkImport")) { /* //open connection and start Transaction if(dbGen.openConnectionAndStartQueryOrTransaction(Q, TA, sis_session, tms_session, SessionUserInfo.selectedThesaurus, false)==QClass.APIFail) { Utils.StaticClass.webAppSystemOutPrintln("OPEN CONNECTION ERROR @ servlet " + this.getServletName()); return; } */ if (dbImport.bulkImportActions(sessionInstance, context, common_utils, config, targetLocale, pathToErrorsXML, xmlFilePath, importThesaurusName, importHierarchyName, "backup_before_import_data_to_thes_" + importThesaurusName, DBbackupFileNameCreated, resultObj, logFileWriter) == false) { abortActions(request, sessionInstance, context, targetLocale, common_utils, initiallySelectedThesaurus, importThesaurusName, DBbackupFileNameCreated, resultObj, out); return; } } commitActions(request, WebAppUsersFileName, sessionInstance, context, targetLocale, importThesaurusName, out, Filename.concat(".html")); //ReportSuccessMessage logFileWriter .append("\r\n<creationInfo>" + u.translateFromMessagesXML("root/ImportData/ReportSuccessMessage", new String[] { importThesaurusName, xmlFilePath, ((Utilities.stopTimer(startTime)) / 60) + "" }) + "</creationInfo>\r\n"); if (logFileWriter != null) { logFileWriter.append("</page>"); logFileWriter.flush(); logFileWriter.close(); } //Now XSL should be found and java xsl transformation should be performed String XSL = context.getRealPath("/" + webAppSaveResults_Folder) + "/ImportCopyMergeThesaurus_Report.xsl"; u.XmlFileTransform(logFileNamePath, XSL, logPath + "/" + Filename.concat(".html")); } catch (Exception e) { Utils.StaticClass.webAppSystemOutPrintln(Parameters.LogFilePrefix + ".Exception catched in servlet " + getServletName() + ". Message:" + e.getMessage()); Utils.StaticClass.handleException(e); if (logFileWriter != null) { logFileWriter.append("</page>"); logFileWriter.flush(); logFileWriter.close(); } } finally { out.flush(); out.close(); sessionInstance.writeBackToSession(session); } }
From source file:com.orchestra.portale.controller.EditPoiController.java
@RequestMapping(value = "/updatepoi", method = RequestMethod.POST) public ModelAndView updatePoi(@RequestParam Map<String, String> params, @RequestParam(value = "file", required = false) MultipartFile[] files, @RequestParam(value = "cover", required = false) MultipartFile cover, @RequestParam(value = "fileprec", required = false) String[] fileprec, @RequestParam(value = "imgdel", required = false) String[] imgdel, HttpServletRequest request) throws InterruptedException { CompletePOI poi = pm.getCompletePoiById(params.get("id")); CoverImgComponent coverimg = new CoverImgComponent(); ArrayList<AbstractPoiComponent> listComponent = new ArrayList<AbstractPoiComponent>(); for (AbstractPoiComponent comp : poi.getComponents()) { //associazione delle componenti al model tramite lo slug String slug = comp.slug(); int index = slug.lastIndexOf("."); String cname = slug.substring(index + 1).replace("Component", "").toLowerCase(); if (cname.equals("coverimg")) { coverimg = (CoverImgComponent) comp; }/* w w w .j a v a 2 s . com*/ } ModelAndView model = new ModelAndView("editedpoi"); poi.setId(params.get("id")); ModelAndView model2 = new ModelAndView("errorViewPoi"); poi.setName(params.get("name")); poi.setVisibility(params.get("visibility")); poi.setAddress(params.get("address")); double lat = Double.parseDouble(params.get("latitude")); double longi = Double.parseDouble(params.get("longitude")); poi.setLocation(new double[] { lat, longi }); poi.setShortDescription(params.get("shortd")); int i = 1; ArrayList<String> categories = new ArrayList<String>(); while (params.containsKey("category" + i)) { categories.add(params.get("category" + i)); model.addObject("nome", categories.get(i - 1)); i = i + 1; } poi.setCategories(categories); //componente cover if (!cover.isEmpty()) { coverimg.setLink("cover.jpg"); } listComponent.add(coverimg); //componente galleria immagini ImgGalleryComponent img_gallery = new ImgGalleryComponent(); ArrayList<ImgGallery> links = new ArrayList<ImgGallery>(); i = 0; if (files != null && files.length > 0) { while (i < files.length) { ImgGallery img = new ImgGallery(); Thread.sleep(100); Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("MMddyyyyhmmssSSa"); String currentTimestamp = sdf.format(date); img.setLink("img_" + currentTimestamp + ".jpg"); if (params.containsKey("newcredit" + (i + 1))) img.setCredit(params.get("newcredit" + (i + 1))); i = i + 1; links.add(img); } } int iximg = 0; if (fileprec != null && fileprec.length > 0) { while (iximg < fileprec.length) { ImgGallery img = new ImgGallery(); img.setLink(fileprec[iximg]); if (params.containsKey("credit" + (iximg + 1))) img.setCredit(params.get("credit" + (iximg + 1))); iximg = iximg + 1; links.add(img); } } if ((fileprec != null && fileprec.length > 0) || (files != null && files.length > 0)) { img_gallery.setLinks(links); listComponent.add(img_gallery); } //componente contatti ContactsComponent contacts_component = new ContactsComponent(); //Recapiti telefonici i = 1; boolean contacts = false; if (params.containsKey("tel" + i)) { ArrayList<PhoneContact> phoneList = new ArrayList<PhoneContact>(); while (params.containsKey("tel" + i)) { PhoneContact phone = new PhoneContact(); if (params.containsKey("tel" + i)) { phone.setLabel(params.get("desctel" + i)); } phone.setNumber(params.get("tel" + i)); phoneList.add(phone); i = i + 1; } contacts = true; contacts_component.setPhoneList(phoneList); } //Recapiti mail i = 1; if (params.containsKey("email" + i)) { ArrayList<EmailContact> emailList = new ArrayList<EmailContact>(); while (params.containsKey("email" + i)) { EmailContact email = new EmailContact(); if (params.containsKey("email" + i)) { email.setLabel(params.get("descemail" + i)); } email.setEmail(params.get("email" + i)); emailList.add(email); i = i + 1; } contacts = true; contacts_component.setEmailsList(emailList); } //Recapiti fax i = 1; if (params.containsKey("fax" + i)) { ArrayList<FaxContact> faxList = new ArrayList<FaxContact>(); while (params.containsKey("fax" + i)) { FaxContact fax = new FaxContact(); if (params.containsKey("fax" + i)) { fax.setLabel(params.get("descfax" + i)); } fax.setFax(params.get("fax" + i)); faxList.add(fax); i = i + 1; } contacts = true; contacts_component.setFaxList(faxList); } //Social predefiniti i = 1; if (params.containsKey("SN" + i)) { while (params.containsKey("SN" + i)) { if (params.get("SN" + i).equals("facebook")) { contacts = true; contacts_component.setFacebook(params.get("LSN" + i)); } if (params.get("SN" + i).equals("twitter")) { contacts = true; contacts_component.setTwitter(params.get("LSN" + i)); } if (params.get("SN" + i).equals("google")) { contacts = true; contacts_component.setGoogle(params.get("LSN" + i)); } if (params.get("SN" + i).equals("skype")) { contacts = true; contacts_component.setSkype(params.get("LSN" + i)); } i = i + 1; } } //Social personalizzati i = 1; if (params.containsKey("CSN" + i)) { ArrayList<GenericSocial> customsocial = new ArrayList<GenericSocial>(); while (params.containsKey("CSN" + i)) { GenericSocial social = new GenericSocial(); contacts = true; social.setLabel(params.get("CSN" + i)); social.setSocial(params.get("LCSN" + i)); customsocial.add(social); i = i + 1; } contacts_component.setSocialList(customsocial); } if (contacts == true) { listComponent.add(contacts_component); } //DESCRIPTION COMPONENT i = 1; if (params.containsKey("par" + i)) { ArrayList<Section> list = new ArrayList<Section>(); while (params.containsKey("par" + i)) { Section section = new Section(); if (params.containsKey("titolo" + i)) { section.setTitle(params.get("titolo" + i)); } section.setDescription(params.get("par" + i)); list.add(section); i = i + 1; } DescriptionComponent description_component = new DescriptionComponent(); description_component.setSectionsList(list); listComponent.add(description_component); } //Orari i = 1; int k = 1; boolean ok = false; String gg = ""; boolean[] aperto = new boolean[8]; for (int z = 1; z <= 7; z++) { aperto[z] = false; } WorkingTimeComponent workingtime = new WorkingTimeComponent(); if (params.containsKey("WD" + i + "start" + k + "H")) { ok = true; ArrayList<CompactWorkingDays> workingdays = new ArrayList<CompactWorkingDays>(); while (params.containsKey("WD" + i)) { ArrayList<WorkingHours> Listwh = new ArrayList<WorkingHours>(); k = 1; while (params.containsKey("WD" + i + "start" + k + "H")) { WorkingHours wh = new WorkingHours(); wh.setStart(params.get("WD" + i + "start" + k + "H") + ":" + params.get("WD" + i + "start" + k + "M")); wh.setEnd( params.get("WD" + i + "end" + k + "H") + ":" + params.get("WD" + i + "end" + k + "M")); Listwh.add(wh); k = k + 1; } CompactWorkingDays cwd = new CompactWorkingDays(); cwd.setDays(params.get("WD" + i)); cwd.setWorkinghours(Listwh); workingdays.add(cwd); i = i + 1; } int grn = 1; ArrayList<CompactWorkingDays> wdef = new ArrayList<CompactWorkingDays>(); for (int z = 1; z <= 7; z++) { aperto[z] = false; } while (grn <= 7) { for (CompactWorkingDays g : workingdays) { if (grn == 1 && g.getDays().equals("Luned")) { aperto[1] = true; wdef.add(g); } if (grn == 2 && g.getDays().equals("Marted")) { aperto[2] = true; wdef.add(g); } if (grn == 3 && g.getDays().equals("Mercoled")) { aperto[3] = true; wdef.add(g); } if (grn == 4 && g.getDays().equals("Gioved")) { aperto[4] = true; wdef.add(g); } if (grn == 5 && g.getDays().equals("Venerd")) { aperto[5] = true; wdef.add(g); } if (grn == 6 && g.getDays().equals("Sabato")) { aperto[6] = true; wdef.add(g); } if (grn == 7 && g.getDays().equals("Domenica")) { aperto[7] = true; wdef.add(g); } } grn++; } workingtime.setWorkingdays(wdef); for (int z = 1; z <= 7; z++) { if (aperto[z] == false && z == 1) gg = gg + " " + "Luned"; if (aperto[z] == false && z == 2) gg = gg + " " + "Marted"; if (aperto[z] == false && z == 3) gg = gg + " " + "Mercoled"; if (aperto[z] == false && z == 4) gg = gg + " " + "Gioved"; if (aperto[z] == false && z == 5) gg = gg + " " + "Venerd"; if (aperto[z] == false && z == 6) gg = gg + " " + "Sabato"; if (aperto[z] == false && z == 7) gg = gg + " " + "Domenica"; } if (!gg.equals("")) { ok = true; workingtime.setWeekly_day_of_rest(gg); } } i = 1; String ggs = ""; while (params.containsKey("RDA" + i)) { ggs = ggs + " " + params.get("RDA" + i); i = i + 1; } if (!ggs.equals("")) { ok = true; workingtime.setDays_of_rest(ggs); } if (ok) { listComponent.add(workingtime); } i = 1; if (params.containsKey("type" + i)) { PricesComponent pc = new PricesComponent(); ArrayList<TicketPrice> tpList = new ArrayList<TicketPrice>(); while (params.containsKey("type" + i)) { TicketPrice tp = new TicketPrice(); tp.setType(params.get("type" + i)); double dp = Double.parseDouble(params.get("price" + i)); tp.setPrice(dp); tp.setType_description(params.get("typedesc" + i)); tpList.add(tp); i = i + 1; } pc.setPrices(tpList); listComponent.add(pc); } i = 1; if (params.containsKey("SERV" + i)) { ArrayList<String> servList = new ArrayList<String>(); while (params.containsKey("SERV" + i)) { servList.add(params.get("SERV" + i)); i = i + 1; } ServicesComponent servicescomponent = new ServicesComponent(); servicescomponent.setServicesList(servList); listComponent.add(servicescomponent); } poi.setComponents(listComponent); pm.savePoi(poi); CompletePOI poi2 = (CompletePOI) pm.findOneCompletePoiByName(poi.getName()); for (int z = 0; z < files.length; z++) { MultipartFile file = files[z]; try { byte[] bytes = file.getBytes(); // Creating the directory to store file HttpSession session = request.getSession(); ServletContext sc = session.getServletContext(); File dir = new File(sc.getRealPath("/") + "dist" + File.separator + "poi" + File.separator + "img" + File.separator + poi2.getId()); if (!dir.exists()) dir.mkdirs(); // Create the file on server File serverFile = new File(dir.getAbsolutePath() + File.separator + links.get(z).getLink()); BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(serverFile)); stream.write(bytes); stream.close(); } catch (Exception e) { return model; } } if (!cover.isEmpty()) { MultipartFile file = cover; try { byte[] bytes = file.getBytes(); // Creating the directory to store file HttpSession session = request.getSession(); ServletContext sc = session.getServletContext(); File dir = new File(sc.getRealPath("/") + "dist" + File.separator + "poi" + File.separator + "img" + File.separator + poi2.getId()); if (!dir.exists()) dir.mkdirs(); // Create the file on server File serverFile = new File(dir.getAbsolutePath() + File.separator + "cover.jpg"); BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(serverFile)); stream.write(bytes); stream.close(); } catch (Exception e) { return model; } } // DELETE IMMAGINI DA CANCELLARE if (imgdel != null && imgdel.length > 0) { for (int kdel = 0; kdel < imgdel.length; kdel++) { delimg(request, poi.getId(), imgdel[kdel]); } } return model; }