- WebdbMultipartRequest mp = new WebdbMultipartRequest(req);
-
- HashMap withValues = mp.getParameters();
- withValues.put("date", StringUtil.date2webdbDate(new GregorianCalendar()));
- withValues.put("publish_path", StringUtil.webdbDate2path((String)withValues.get("date")));
- withValues.put("is_produced", "0");
- // op-articles are immediatly published
- withValues.put("is_published","1");
- // if op direct article-type == newswire
- if (directOp.equals("yes")) withValues.put("to_article_type","1");
-
- // owner is openposting user
- withValues.put("to_publisher","1");
- if (withValues.get("creator").toString().equals(""))
- withValues.put("creator","Anonym");
-
- // inserting content into database
- String cid = contentModule.add(withValues);
-
- // if op contains uploaddata
- String mediaId=null;
- int i=1;
- for(Iterator it = mp.requestList.iterator(); it.hasNext();){
- MpRequest mpReq = (MpRequest)it.next();
- byte[] mediaData=mpReq.getMedia();
- String fileName=mpReq.getFilename();
- String contentType=mpReq.getContentType();
- if (mediaData!=null && fileName!=null) {
- HashMap mediaValues = new HashMap();
- mediaValues.put("date", StringUtil.date2webdbDate(new GregorianCalendar()));
- mediaValues.put("to_publisher", "1"); // op user
- mediaValues.put("to_media_folder", "7"); // op media_folder
- mediaValues.put("is_produced", "0");
- mediaValues.put("is_published","1");
-
- String mediaTitle=(String)withValues.get("media_title"+i);
- i++;
- if (mediaTitle==null)
- mediaTitle = (String)withValues.get("title");
- mediaValues.put("title",mediaTitle);
-
- if (fileName.toLowerCase().endsWith("rm")) {
- // this is video !!
- //theLog.printDebugInfo("--GOT VIDEO");
- EntityVideo entVideo = new EntityVideo(DatabaseVideos.getInstance());
- entVideo.setValues(mediaValues);
- mediaId = entVideo.insert();
- entVideo.setVideoData(mediaData);
+ final String[] search_variables = {
+ "search_content", "search_boolean", "search_creator",
+ "search_topic", "search_hasImages", "search_hasAudio", "search_hasVideo", "search_sort",
+ "search_submit", "search_back", "search_forward"};
+ HTTPRequestParser requestParser = new HTTPRequestParser(req);
+
+ int increment = 10;
+
+ HttpSession session = req.getSession(false);
+
+ String queryString = "";
+
+ Map mergeData = new HashMap();
+
+ KeywordSearchTerm dateTerm = new KeywordSearchTerm("date_formatted", "search_date", "webdb_create_formatted", "webdb_create_formatted", "webdb_create_formatted");
+ UnIndexedSearchTerm whereTerm = new UnIndexedSearchTerm("", "", "", "where", "where");
+ TextSearchTerm creatorTerm = new TextSearchTerm("creator", "search_creator", "creator", "creator", "creator");
+ TextSearchTerm titleTerm = new TextSearchTerm("title", "search_content", "title", "title", "title");
+ TextSearchTerm descriptionTerm = new TextSearchTerm("description", "search_content", "description", "description", "description");
+ ContentSearchTerm contentTerm = new ContentSearchTerm("content_data", "search_content", "content", "", "");
+ TopicSearchTerm topicTerm = new TopicSearchTerm();
+ TopicMatrixSearchTerm topicMatrixTerm = new TopicMatrixSearchTerm();
+ ImagesSearchTerm imagesTerm = new ImagesSearchTerm();
+ AudioSearchTerm audioTerm = new AudioSearchTerm();
+ VideoSearchTerm videoTerm = new VideoSearchTerm();
+
+ //make the query available to subsequent iterations
+
+ Iterator j = Arrays.asList(search_variables).iterator();
+ while (j.hasNext()) {
+ String variable = (String) j.next();
+
+ mergeData.put(variable, requestParser.getParameter(variable));
+ }
+
+ try {
+ mergeData.put("topics", DatabaseTopics.getInstance().getPopupData());
+ }
+ catch (Throwable e) {
+ getLogger().debug("Can't get topics: " + e.toString());
+ }
+
+ String searchBackValue = req.getParameter("search_back");
+ String searchForwardValue = req.getParameter("search_forward");
+
+ if (searchBackValue != null) {
+ int totalHits = ( (Integer) session.getAttribute("numberOfHits")).intValue();
+ int newPosition = ( (Integer) session.getAttribute("positionInResults")).intValue() - increment;
+ if (newPosition < 0)
+ newPosition = 0;
+ if (newPosition >= totalHits)
+ newPosition = totalHits - 1;
+ session.setAttribute("positionInResults", new Integer(newPosition));
+ }
+ else {
+ if (searchForwardValue != null) {
+ int totalHits = ( (Integer) session.getAttribute("numberOfHits")).intValue();
+ int newPosition = ( (Integer) session.getAttribute("positionInResults")).intValue() + increment;
+ if (newPosition < 0)
+ newPosition = 0;
+ if (newPosition >= totalHits)
+ newPosition = totalHits - 1;
+
+ session.setAttribute("positionInResults", new Integer(newPosition));
+ }
+ else {
+ File indexFile = FileRoutines.getAbsoluteOrRelativeFile(getConfiguration().getHome(), getConfiguration().getString("IndexPath"));
+
+ String creatorFragment = creatorTerm.makeTerm(req);
+ if (creatorFragment != null) {
+ queryString = queryString + " +" + creatorFragment;
+ }
+
+ // search title, description, and content for something
+ // the contentTerm uses param "search_boolean" to combine its terms
+ String contentFragment = contentTerm.makeTerm(req);
+ if (contentFragment != null) {
+ getLogger().debug("contentFragment: " + contentFragment);
+ queryString = queryString + " +" + contentFragment;
+ }
+
+ String topicFragment = topicTerm.makeTerm(req);
+ if (topicFragment != null) {
+ queryString = queryString + " +" + topicFragment;
+ }
+
+ String topicMatrixFragment = topicMatrixTerm.makeTerm(req);
+ if (topicMatrixFragment != null) {
+ queryString = queryString + " +" + topicMatrixFragment;
+ }
+
+ String imagesFragment = imagesTerm.makeTerm(req);
+ if (imagesFragment != null) {
+ queryString = queryString + " +" + imagesFragment;
+ }
+
+ String audioFragment = audioTerm.makeTerm(req);
+ if (audioFragment != null) {
+ queryString = queryString + " +" + audioFragment;