Commits

Juan Carlos Picado Herrera committed 6142519

After removed dojo source code.
We need run ant build to get dojo source code before build with maven.
New Json HashTagh Service.

git-svn-id: http://svn.encuesta.me/trunk/encuestame@88739e2479b-dd58-4041-9f67-69c9b71f0610

Comments (0)

Files changed (8)

 
 After get source code is necesary move to top level and  run following command:
 
-    mvn install
+    ant build - to get dojo source code, maybe you need change parameters on buildDojo.sh
+
+    mvn install - to install app
 
 After doing this, you can run jetty server running following command:
 
 If you want deploy on webcontainer you can find WAR file on (after run mvn install on top level):
 
     encuestame-war/target/encuestame.war
-
-
+<project name="encuestame">
+	<target name="build">
+		<exec executable="/bin/bash">
+			<arg value="buildDojo.sh"/>
+			<arg value="/tmp"/>
+		</exec>
+	</target>
+</project>
+#!/bin/bash
+DOJO_PATH=/home/jpicado/workspaceTrunk/dojo
+SVN_DOJO=http://svn.dojotoolkit.org/src/tags/release-1.5.0/
+
+echo 'Building Dojo'
+
+function createSymbolic {
+        rm encuestame-war/src/main/webapp/resource/js/dojo
+        rm encuestame-war/src/main/webapp/resource/js/dojox
+        rm encuestame-war/src/main/webapp/resource/js/dijit
+        cp -Rf ${DOJO_PATH}/dojo encuestame-war/src/main/webapp/resource/js/
+        cp -Rf ${DOJO_PATH}/dojox encuestame-war/src/main/webapp/resource/js/
+        cp -Rf ${DOJO_PATH}/dijit encuestame-war/src/main/webapp/resource/js/
+}
+
+
+if [ -d ${DOJO_PATH} ]; then
+    echo "Create Links"
+    createSymbolic
+else
+    echo "Create Dir"
+    mkdir ${DOJO_PATH}
+    #cd ${DOJO_PATH}
+    echo "SVN Checkout"
+    svn co ${SVN_DOJO} ${DOJO_PATH}
+    echo "Create Links"
+    createSymbolic
+fi
+echo 'Done'

encuestame-mvc/src/main/java/org/encuestame/mvc/controller/json/HashTagsJsonService.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2010 encuestame: system online surveys Copyright (C) 2009
+ * encuestame Development Team.
+ * Licensed under the Apache Software License version 2.0
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to  in writing,  software  distributed
+ * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
+ * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
+ * specific language governing permissions and limitations under the License.
+ ************************************************************************************
+ */
+package org.encuestame.mvc.controller.json;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.collections.ListUtils;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.encuestame.mvc.controller.AbstractJsonController;
+import org.encuestame.utils.web.UnitHashTag;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * HashTag Json Controller.
+ * @author Picado, Juan juanATencuestame.org
+ * @since Nov 20, 2010 12:43:46 PM
+ * @version $Id:$
+ */
+@Controller
+public class HashTagsJsonService extends AbstractJsonController{
+
+    private final static Integer LIMIT_DEFAULT = 10;
+
+     /**
+     * Get List of Users.
+     * @param username username
+     * @param request request
+     * @param response response
+     * @return list of json users.
+     * @throws JsonGenerationException
+     * @throws JsonMappingException
+     * @throws IOException
+     */
+    @PreAuthorize("hasRole('ENCUESTAME_USER')")
+    @RequestMapping(value = "/api/common/hashtags.json", method = RequestMethod.GET)
+    public ModelMap get(
+            @RequestParam(value = "limit", required = false) Integer limit,
+            @RequestParam(value = "keyword", required = false) String keyword,
+            HttpServletRequest request,
+            HttpServletResponse response) throws JsonGenerationException, JsonMappingException, IOException {
+            try {
+                final Map<String, Object> jsonResponse = new HashMap<String, Object>();
+                if(limit == null){
+                    limit = LIMIT_DEFAULT;
+                }
+                log.debug("Limit "+limit);
+                log.debug("Keyword "+keyword);
+                if(keyword == null || keyword.isEmpty()){
+                    jsonResponse.put("hashtags", ListUtils.EMPTY_LIST);
+                } else {
+                    final List<UnitHashTag> hashTags = getTweetPollService().listSuggestHashTags(keyword, limit);
+                    log.debug("List Hash Tags "+hashTags.size());
+                    jsonResponse.put("hashtags", hashTags);
+                }
+                setItemResponse(jsonResponse);
+            } catch (Exception e) {
+                 log.error(e);
+                 e.printStackTrace();
+                 setError(e.getMessage(), response);
+            }
+            return returnData();
+        }
+
+}

encuestame-war/src/main/webapp/WEB-INF/urlrewrite.xml

 
     <rule>
         <from>^/user/signin</from>
-        <to>/signin.html</to>
+        <to>/signin.jspx</to>
     </rule>
     <rule>
-      <from>^/signin.html</from>
+      <from>^/signin.jspx</from>
       <to type="redirect">user/signin</to>
     </rule>
     <rule>
-      <from>^/index.html</from>
+      <from>^/index.jspx</from>
       <to type="redirect">home</to>
     </rule>
     <rule>
         <from>^/home</from>
-        <to>/index.html</to>
+        <to>/index.jspx</to>
     </rule>
     <rule>
-      <from>^/dashboard.html</from>
+      <from>^/dashboard.jspx</from>
       <to type="redirect">account/dashboard</to>
     </rule>
     <rule>
         <from>^/account/dashboard</from>
-        <to>/dashboard.html</to>
+        <to>/dashboard.jspx</to>
     </rule>
     <rule>
-      <from>^/error.html</from>
+      <from>^/error.jspx</from>
       <to type="redirect">user/denied</to>
     </rule>
     <rule>
         <from>^/user/denied</from>
-        <to>/error.html</to>
+        <to>/error.jspx</to>
     </rule>
     <rule>
         <from>^/user/signup</from>
-        <to>/user/signup.html</to>
+        <to>/user/signup.jspx</to>
     </rule>
     <rule>
         <from>^/user/forgot</from>
-        <to>/user/forgot.html</to>
+        <to>/user/forgot.jspx</to>
     </rule>
 
     <!-- Detail View Votes -->
     <rule>
         <from>^/tweet/view/(.*)$</from>
-        <to>/view/tweetPoll.html?id=$1</to>
+        <to>/view/tweetPoll.jspx?id=$1</to>
     </rule>
     <rule>
         <from>^/poll/view/(.*)$</from>
-        <to>/votes/poll.html?id=$1</to>
+        <to>/votes/poll.jspx?id=$1</to>
     </rule>
     <rule>
         <from>^/survey/view/(.*)$</from>
-        <to>/votes/survey.html?id=$1</to>
+        <to>/votes/survey.jspx?id=$1</to>
     </rule>
 
     <!--  Votes -->
     <rule>
         <from>^/tweet/vote/(.*)$</from>
-        <to>/vote/tweet.html?id=$1</to>
+        <to>/vote/tweet.jspx?id=$1</to>
     </rule>
     <rule>
         <from>^/poll/vote/(.*)$</from>
-        <to>/vote/poll.html?id=$1</to>
+        <to>/vote/poll.jspx?id=$1</to>
     </rule>
     <rule>
         <from>^/survey/vote/(.*)$</from>
-        <to>/vote/survey.html?id=$1</to>
+        <to>/vote/survey.jspx?id=$1</to>
     </rule>
 
 </urlrewrite>

encuestame-war/src/main/webapp/WEB-INF/web.xml

     -->
     <servlet-mapping>
         <servlet-name>encuestame-spring-dispacher</servlet-name>
-        <url-pattern>*.html</url-pattern>
+        <url-pattern>*.jspx</url-pattern>
     </servlet-mapping>
     <servlet-mapping>
         <servlet-name>encuestame-spring-dispacher</servlet-name>

encuestame-war/src/main/webapp/index.jsp

 <%
-    String redirectURL = "index.html";
+    String redirectURL = "home";
     response.sendRedirect(redirectURL);
 
 %>

encuestame-web/src/main/resources/encuestame-mvc-context.xml

   <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
     <property name="mappings">
       <value>
-        /main.html=urlFilenameViewController
-        /admon/groups.html=urlFilenameViewController
-        /admon/users.html=urlFilenameViewController
-        /admon/location.html=urlFilenameViewController
-        /admon/project.html=urlFilenameViewController
-
-        /tweetpoll.html=urlFilenameViewController
-        /poll.html=urlFilenameViewController
-        /survey.html=urlFilenameViewController
-
-        /user/profile.html=urlFilenameViewController
-        /user/social.html=urlFilenameViewController
-        /user/resister.html=urlFilenameViewController
-        /user/signin.html=urlFilenameViewController
-        /user/forgot.html=urlFilenameViewController
-        /user/lists.html=urlFilenameViewController
-
-        /votes/tweetPoll.html=urlFilenameViewController
-        /votes/poll.html=urlFilenameViewController
-        /votes/survey.html=urlFilenameViewController
+        /main.jspx=urlFilenameViewController
+        /admon/groups.jspx=urlFilenameViewController
+        /admon/users.jspx=urlFilenameViewController
+        /admon/location.jspx=urlFilenameViewController
+        /admon/project.jspx=urlFilenameViewController
+
+        /tweetpoll.jspx=urlFilenameViewController
+        /poll.jspx=urlFilenameViewController
+        /survey.jspx=urlFilenameViewController
+
+        /user/profile.jspx=urlFilenameViewController
+        /user/social.jspx=urlFilenameViewController
+        /user/resister.jspx=urlFilenameViewController
+        /user/signin.jspx=urlFilenameViewController
+        /user/forgot.jspx=urlFilenameViewController
+        /user/lists.jspx=urlFilenameViewController
+
+        /votes/tweetPoll.jspx=urlFilenameViewController
+        /votes/poll.jspx=urlFilenameViewController
+        /votes/survey.jspx=urlFilenameViewController
 
        </value>
     </property>