Commits

Juan Carlos Picado Herrera committed 212362b

Update Profile after create Account

Comments (0)

Files changed (23)

encuestame-business/src/main/java/org/encuestame/business/service/AbstractBaseService.java

 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.encuestame.business.mail.MailServiceImpl;
-import org.encuestame.core.files.FileUpload;
+import org.encuestame.core.files.PathUtil;
 import org.encuestame.core.util.ConvertDomainBean;
 import org.encuestame.core.util.MD5Utils;
 import org.encuestame.core.util.MessageSourceFactoryBean;
            final Integer start) throws EnMeDomainNotFoundException {
         log.info("currentUsername "+currentUsername);
         List<UnitUserBean> loadListUsers = new LinkedList<UnitUserBean>();
-        final UserAccount userAccount = this.getUser(currentUsername);
+        final UserAccount userAccount = this.getUserAccount(currentUsername);
         if(userAccount != null){
             final Collection<UserAccount> listUsers = getAccountDao()
                  .retrieveListOwnerUsers(userAccount.getAccount(), start, maxResults);
      * @param account
      */
     public void createGlobalAccount(final Account account){
-        final File file = new File(getDataGlobalPath() + FileUpload.accounts);
+        final File file = new File(getDataGlobalPath() + PathUtil.accounts);
         if (file.exists()) {
             this.createAccountGlobalAccount(account);
         } else {
     public String getGlobalAccountPath(final Account account){
         final StringBuilder d = new StringBuilder();
         d.append(getDataGlobalPath());
-        d.append(FileUpload.accounts);
-        d.append(FileUpload.account);
+        d.append(PathUtil.accounts);
+        d.append(PathUtil.account);
         d.append(account.getUid());
         return d.toString();
     }

encuestame-business/src/main/java/org/encuestame/business/service/AbstractDataSource.java

      * @return user domain
      * @throws EnMeDomainNotFoundException exception
      */
-    public final UserAccount getUser(final String username) throws EnMeDomainNotFoundException {
+    public final UserAccount getUserAccount(final String username) throws EnMeDomainNotFoundException {
         final UserAccount userAccount = getAccountDao().getUserByUsername(username);
         if(userAccount == null){
             throw new EnMeDomainNotFoundException(" user not found {"+username+"}");
      * @throws EnMeDomainNotFoundException exception
      */
     public final Long getPrimaryUser(final String username) throws EnMeDomainNotFoundException{
-        return getUser(username).getAccount().getUid();
+        return getUserAccount(username).getAccount().getUid();
      }
 
     /**

encuestame-business/src/main/java/org/encuestame/business/service/LocationService.java

                         .getLocTypeDesc());
                 locationTypeDomain.setLocationTypeLevel(locatTypeBean
                         .getLevel());
-                locationTypeDomain.setUsers(getUser(username).getAccount());
+                locationTypeDomain.setUsers(getUserAccount(username).getAccount());
                 getGeoPointTypeDao().saveOrUpdate(locationTypeDomain);
                 locatTypeBean.setIdLocType(locationTypeDomain
                         .getLocationTypeId());
                 geoPointDomain.setLocationDescription(location.getName());
                 geoPointDomain.setLocationStatus(Status.ACTIVE);
                 geoPointDomain.setLocationLatitude(location.getLat());
-                geoPointDomain.setAccount(getUser(username).getAccount());
+                geoPointDomain.setAccount(getUserAccount(username).getAccount());
                 geoPointDomain.setLocationLongitude(location.getLng());
                 if(location.getTidtype() != null){
                     geoPointDomain.setTidtype(getGeoPointTypeDao().getLocationById(location.getTidtype()));
         final GeoPointFolder geoPointFolder = new GeoPointFolder();
         geoPointFolder.setFolderType(GeoPointFolderType.valueOf(locationFolder.getType()));
         geoPointFolder.setLocationFolderName(locationFolder.getName());
-        geoPointFolder.setAccount(getUser(username).getAccount());
+        geoPointFolder.setAccount(getUserAccount(username).getAccount());
         getGeoPointDao().saveOrUpdate(geoPointFolder);
         locationFolder.setId(geoPointFolder.getLocationFolderId());
         createNotification(NotificationEnum.LOCATION_FOLDER_NEW, "New Folder "+locationFolder.getName() +" is created.", geoPointFolder.getAccount());
         else {
             final GeoPoint geopoint = new GeoPoint();
             geopoint.setGeoPointFolder(locationFolder);
-            geopoint.setAccount(getUser(username).getAccount());
+            geopoint.setAccount(getUserAccount(username).getAccount());
             geopoint.setLocationStatus(Status.ACTIVE);
             geopoint.setLocationDescription("Default Item Name");
             getGeoPointDao().saveOrUpdate(geopoint);

encuestame-business/src/main/java/org/encuestame/business/service/PictureService.java

 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.encuestame.business.service.imp.IPictureService;
-import org.encuestame.core.files.FileUpload;
+import org.encuestame.core.files.PathUtil;
 import org.encuestame.persistence.domain.security.Account;
 import org.encuestame.persistence.domain.security.UserAccount;
 import org.encuestame.persistence.exception.EnMeDomainNotFoundException;
      */
     private String getPicturePath(final Account account){
         final StringBuilder d = new StringBuilder(getGlobalAccountPath(account));
-        d.append(FileUpload.profile);
+        d.append(PathUtil.profile);
         final File profileDir =  new File(d.toString());
         if (!profileDir.exists()) {
             profileDir.mkdirs();
      */
     public String getAccountUserPicturePath(final String username)
            throws EnMeDomainNotFoundException{
-        final UserAccount user = getUser(username);
+        final UserAccount user = getUserAccount(username);
         log.debug("getAccountUserPicturePath "+user);
         return this.getPicturePath(user.getAccount());
     }

encuestame-business/src/main/java/org/encuestame/business/service/PollService.java

         try {
             final Poll pollDomain = new Poll();
             pollDomain.setCreatedAt(pollBean.getCreationDate());
-            pollDomain.setPollOwner(getUser(currentUser).getAccount());
+            pollDomain.setPollOwner(getUserAccount(currentUser).getAccount());
             pollDomain.setPollCompleted(Boolean.FALSE);
             pollDomain.setCreatedAt(new Date());
             pollDomain.setPollHash(MD5Utils.md5(RandomStringUtils.randomAlphanumeric(500)));
      * @throws EnMeDomainNotFoundException
      */
     public List<UnitPoll> getPollsByFolder(final UnitFolder folder, final String username) throws EnMeDomainNotFoundException{
-        final Account account = getUser(username).getAccount();
+        final Account account = getUserAccount(username).getAccount();
         final List<Poll> polls = getPollDao().getPollsByPollFolder(account, getPollFolder(folder.getId()));
         return ConvertDomainBean.convertSetToUnitPollBean(polls);
     }
      * @throws EnMeDomainNotFoundException exception
      */
     public List<UnitFolder> retrieveFolderPoll(final String username) throws EnMeDomainNotFoundException{
-        final Account account = getUser(username).getAccount();
+        final Account account = getUserAccount(username).getAccount();
         final List<IFolder> folders = getPollDao().getPollFolderBySecUser(account);
         return ConvertDomainBean.convertListToUniUnitFolder(folders);
     }
      */
     public UnitFolder createPollFolder(final String folderName, final String username) throws EnMeDomainNotFoundException{
         final PollFolder pollFolder = new PollFolder();
-        pollFolder.setUsers(getUser(username).getAccount());
+        pollFolder.setUsers(getUserAccount(username).getAccount());
         pollFolder.setCreatedAt(new Date());
         pollFolder.setFolderName(folderName);
         this.getPollDao().saveOrUpdate(pollFolder);

encuestame-business/src/main/java/org/encuestame/business/service/ProjectService.java

      */
     public List<UnitProjectBean> loadListProjects(final String username) throws EnMeDomainNotFoundException {
             final List<UnitProjectBean> listProjects = new ArrayList<UnitProjectBean>();
-            final Collection<Project> projectList = getProjectDaoImp().findProjectsByUserID(getUser(username).getAccount().getUid());
+            final Collection<Project> projectList = getProjectDaoImp().findProjectsByUserID(getUserAccount(username).getAccount().getUid());
             //log.debug("project by user id: "+projectList.size());
             for (final Project project : projectList) {
                 //log.debug("adding project "+project.getProjectDescription());
             try {
                 final Project projectDomain = new Project();
                 final UserAccount secondary = getAccountDao().getSecondaryUserById(projectBean.getLeader());
-                final Account user = getUser(username).getAccount();
+                final Account user = getUserAccount(username).getAccount();
                 projectDomain.setProjectDateFinish(projectBean.getDateFinish());
                 projectDomain.setProjectDateStart(projectBean.getDateInit());
                 log.debug("new Project Leader "+projectBean.getName());
         }
         else{
             final UserAccount secondary = getAccountDao().getSecondaryUserById(projectBean.getLeader());
-            final Account user = getUser(username).getAccount();
+            final Account user = getUserAccount(username).getAccount();
             project.setProjectName(projectBean.getName());
             project.setHideProject(projectBean.getHide());
             project.setLead(secondary);

encuestame-business/src/main/java/org/encuestame/business/service/SecurityService.java

      * @throws EnMeDomainNotFoundException
      */
     public Long totalOwnUsers(final String username) throws EnMeDomainNotFoundException{
-        return getAccountDao().retrieveTotalUsers(getUser(username).getAccount());
+        return getAccountDao().retrieveTotalUsers(getUserAccount(username).getAccount());
     }
 
     /**
      * @throws EnMeDomainNotFoundException
      */
     public List<UnitGroupBean> loadGroups(final String currentUsername) throws EnMeDomainNotFoundException{
-        final UserAccount userAccount = getUser(currentUsername);
+        final UserAccount userAccount = getUserAccount(currentUsername);
         final List<UnitGroupBean> groupBeans = new ArrayList<UnitGroupBean>();
         final List<Group> groupsList = getGroupDao().loadGroupsByUser(userAccount.getAccount());
         for (Group groups : groupsList) {
      * @throws EnMeDomainNotFoundException
      */
     public void addNewTwitterAccount(final String account, final String username) throws EnMeDomainNotFoundException{
-        final Account user = getUser(username).getAccount();
+        final Account user = getUserAccount(username).getAccount();
         final SocialAccount userTwitterAccount = new SocialAccount();
         userTwitterAccount.setSecUsers(user);
         userTwitterAccount.setTwitterAccount(account);
      * @throws EnMeDomainNotFoundException
      */
     public void deleteUser(final UnitUserBean userBean) throws EnMeDomainNotFoundException{
-            final UserAccount userDomain = getUser(userBean.getUsername());
+            final UserAccount userDomain = getUserAccount(userBean.getUsername());
                 if (getSuspendedNotification()) {
                     log.info("notify delete account");
                     getServiceMail().sendDeleteNotification(userBean.getEmail(),
      */
     public String renewPassword(final UnitUserBean userBean, String newPassword) throws EnMeExpcetion {
         // search user
-        final UserAccount userDomain = getUser(userBean.getUsername());
+        final UserAccount userDomain = getUserAccount(userBean.getUsername());
         // validate user and password
         if (userDomain != null && newPassword != null) {
             //set new password
     public UnitGroupBean createGroup(final UnitGroupBean groupBean, final String username) throws EnMeDomainNotFoundException {
         //log.info("Create Group");
         final Group groupDomain = new Group();
-        final Account secUsers = getUser(username).getAccount();
+        final Account secUsers = getUserAccount(username).getAccount();
         groupDomain.setGroupDescriptionInfo(groupBean.getGroupDescription());
         groupDomain.setGroupName(groupBean.getGroupName());
         groupDomain.setIdState(null);
      */
     public void createUser(final UnitUserBean userBean, final String username) throws EnMeExpcetion {
         final UserAccount userAccount = new UserAccount();
-        final Account account = getUser(username).getAccount();
+        final Account account = getUserAccount(username).getAccount();
         //validate email and password
         if (userBean.getEmail() != null && userBean.getUsername() != null) {
             userAccount.setUserEmail(userBean.getEmail());
             final String username) throws EnMeDomainNotFoundException {
         final UserAccount userAccount = getUser(userId); //TODO: I need confirm this user perhaps same group of logged user.
         //search group by group id and owner user id.
-        final Group group = getGroupDao().getGroupById(groupId, getUser(username).getAccount());
+        final Group group = getGroupDao().getGroupById(groupId, getUserAccount(username).getAccount());
         if(group == null){
             throw new EnMeDomainNotFoundException("group not found");
         } else {
      */
     public List<UnitTwitterAccountBean> getUserLoggedTwitterAccount(final String username) throws EnMeDomainNotFoundException{
          return ConvertDomainBean.convertListTwitterAccountsToBean(getAccountDao()
-                                 .getTwitterAccountByUser(getUser(username).getAccount()));
+                                 .getTwitterAccountByUser(getUserAccount(username).getAccount()));
     }
 
     /**
      */
     public List<UnitTwitterAccountBean> getUserLoggedVerifiedTwitterAccount(final String username) throws EnMeDomainNotFoundException{
         return ConvertDomainBean.convertListTwitterAccountsToBean(getAccountDao()
-                                .getTwitterVerifiedAccountByUser(getUser(username).getAccount()));
+                                .getTwitterVerifiedAccountByUser(getUserAccount(username).getAccount()));
    }
 
     /**
      * @throws EnMeDomainNotFoundException
      */
     public Integer getFollowers(final String username) throws EnMeDomainNotFoundException{
-        UserAccount userAcc = getUser(username);
+        UserAccount userAcc = getUserAccount(username);
         final Integer followers = userAcc.getFollowers().size();
         return followers;
     }
     public void followOperations(final UserAccount userAcc,
             final String myUsername, final String followerUser,
             final FollowOperations operation) throws EnMeDomainNotFoundException {
-        final UserAccount myAccount = getUser(myUsername);
-        final UserAccount myFollower = getUser(followerUser);
+        final UserAccount myAccount = getUserAccount(myUsername);
+        final UserAccount myFollower = getUserAccount(followerUser);
         if (FollowOperations.FOLLOW.equals(operation)) {
             myAccount.getFollowers().add(myFollower);
         } else if (FollowOperations.UNFOLLOW.equals(operation)) {
      * @throws EnMeDomainNotFoundException
      */
     public UserAccount addFollower(final String myUsername, final String followerUser) throws EnMeDomainNotFoundException{
-        final UserAccount myAccount = getUser(myUsername);
-        final UserAccount myFollower = getUser(followerUser);
+        final UserAccount myAccount = getUserAccount(myUsername);
+        final UserAccount myFollower = getUserAccount(followerUser);
         myAccount.getFollowers().add(myFollower);
         getAccountDao().saveOrUpdate(myAccount);
         return myAccount;
     }
 
+    /**
+     * Update property for user account.
+     * @param property
+     * @param value
+     * @param username
+     * @throws EnMeDomainNotFoundException
+     */
+    public void upadteAccountProfile(
+            final String property,
+            final String value,
+            final String username) throws EnMeDomainNotFoundException{
+        final UserAccount account = getUserAccount(username);
+        if("completeName".equals(property)){
+            account.setCompleteName(value.trim());
+        }
+        //TODO: more properties to upadte.
+        getAccountDao().saveOrUpdate(account);
+    }
+
+    /**
+     * Follow Operations
+     * @author Picado, Juan juanATencuestame.org
+     * @since Jan 23, 2011 9:53:53 AM
+     * @version $Id:$
+     */
     public enum FollowOperations{
         FOLLOW,
         UNFOLLOW

encuestame-business/src/main/java/org/encuestame/business/service/SurveyService.java

     public UnitFolder createSurveyFolder(final String folderName, final String username)
             throws EnMeDomainNotFoundException{
         final SurveyFolder surveyFolderDomain = new SurveyFolder();
-        surveyFolderDomain.setUsers(getUser(username).getAccount());
+        surveyFolderDomain.setUsers(getUserAccount(username).getAccount());
         surveyFolderDomain.setCreatedAt(new Date());
         surveyFolderDomain.setFolderName(folderName);
         this.getSurveyDaoImp().saveOrUpdate(surveyFolderDomain);

encuestame-business/src/main/java/org/encuestame/business/service/TweetPollService.java

      */
     @Deprecated
     public Boolean validateUserTwitterAccount(final String username) throws EnMeDomainNotFoundException{
-        final Account users = getUser(username).getAccount();
+        final Account users = getUserAccount(username).getAccount();
         Boolean validate = false;
         log.info(users.getTwitterAccount());
         if(!users.getTwitterAccount().isEmpty() && !users.getTwitterPassword().isEmpty()){
      */
     public UnitFolder createTweetPollFolder(final String folderName, final String username) throws EnMeDomainNotFoundException{
         final TweetPollFolder tweetPollFolderDomain = new TweetPollFolder();
-        tweetPollFolderDomain.setUsers(getUser(username).getAccount());
+        tweetPollFolderDomain.setUsers(getUserAccount(username).getAccount());
         tweetPollFolderDomain.setCreatedAt(new Date());
 
         tweetPollFolderDomain.setFolderName(folderName);

encuestame-business/src/main/java/org/encuestame/business/service/imp/ISecurityService.java

     void changeUserStatus(final String username) throws EnmeFailOperation;
 
     /**
+     * Update property for user account.
+     * @param property
+     * @param value
+     * @param username
+     * @throws EnMeDomainNotFoundException
+     */
+    void upadteAccountProfile(
+            final String property,
+            final String value,
+            final String username) throws EnMeDomainNotFoundException;
+
+    /**
      * User Account Is Activated.
      * @param signUpBean
      * @return
     * @param operation
     * @throws EnMeDomainNotFoundException
     */
-	void followOperations(final UserAccount userAcc,
-			final String myUsername, final String followerUser,
-			final FollowOperations operation) throws EnMeDomainNotFoundException;
+    void followOperations(final UserAccount userAcc,
+            final String myUsername, final String followerUser,
+            final FollowOperations operation) throws EnMeDomainNotFoundException;
 }

encuestame-core/src/main/java/org/encuestame/core/files/FileUpload.java

-package org.encuestame.core.files;
-
-/**
- * File Upload Constants.
- * @author Picado, Juan juanATencuestame.org
- * @since Jan 22, 2011 9:44:41 PM
- * @version Id:
- */
-public class FileUpload {
-
-    /**
-     * Profile Images Folder.
-     */
-    public static final String profile = "/profile";
-
-    /**
-     * Upload Folder.
-     */
-    public static final String upload = "/upload";
-
-    /**
-     * Folder to store index for lucene.
-     */
-    public static final String index = "/index";
-
-    /**
-     * Global Accounts Folder Name.
-     */
-    public static final String accounts = "/accounts";
-
-
-    public static final String account = "/account";
-
-
-}

encuestame-core/src/main/java/org/encuestame/core/files/PathUtil.java

+package org.encuestame.core.files;
+
+/**
+ * File Upload Constants.
+ * @author Picado, Juan juanATencuestame.org
+ * @since Jan 22, 2011 9:44:41 PM
+ * @version Id:
+ */
+public class PathUtil {
+
+    /**
+     * Profile Images Folder.
+     */
+    public static final String profile = "/profile";
+
+    /**
+     * Upload Folder.
+     */
+    public static final String upload = "/upload";
+
+    /**
+     * Folder to store index for lucene.
+     */
+    public static final String index = "/index";
+
+    /**
+     * Global Accounts Folder Name.
+     */
+    public static final String accounts = "/accounts";
+
+
+    public static final String account = "/account";
+
+
+    public static final String profileUserImage = "/user/picture/profile";
+}

encuestame-mvc/src/main/java/org/encuestame/mvc/controller/FileUploadController.java

 import org.encuestame.core.util.MD5Utils;
 import org.encuestame.persistence.exception.EnMeDomainNotFoundException;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
      * @param multipartFile
      * @return
      */
+    @PreAuthorize("hasRole('ENCUESTAME_USER')")
     @RequestMapping(value = "/file/upload/profile", method = RequestMethod.POST)
     public ModelAndView handleUserProfileFileUpload(
             @RequestParam("file") MultipartFile multipartFile) {
             String filePath = null;
             try {
                 log.debug("getting file path for this user");
-                filePath = getPictureService().getAccountUserPicturePath("admin");
+                filePath = getPictureService().getAccountUserPicturePath(getUserPrincipalUsername());
                 InputStream stream = multipartFile.getInputStream();
                 try {
                     //generate thumbnails

encuestame-mvc/src/main/java/org/encuestame/mvc/controller/security/json/JsonUsersController.java

        }
        return returnData();
     }
+
+    /**
+     * Upgrade user account profile.
+     * @param request
+     * @param property
+     * @param value
+     * @param response
+     * @return
+     * @throws JsonGenerationException
+     * @throws JsonMappingException
+     * @throws IOException
+     */
+    @PreAuthorize("hasRole('ENCUESTAME_OWNER')")
+    @RequestMapping(value = "/api/user/profile/upgrade.json", method = RequestMethod.GET)
+    public ModelMap upgradeProfile(HttpServletRequest request,
+            @RequestParam(value = "property", required = true) String property,
+            @RequestParam(value = "value", required = true) String value,
+            HttpServletResponse response) throws JsonGenerationException,
+            JsonMappingException, IOException {
+        try {
+            getSecurityService().upadteAccountProfile(property, value,
+                    getUserPrincipalUsername());
+            setSuccesResponse();
+        } catch (Exception e) {
+            log.error(e);
+            e.printStackTrace();
+            setError(e.getMessage(), response);
+        }
+        return returnData();
+    }
 }

encuestame-mvc/src/main/java/org/encuestame/mvc/util/WidgetUtil.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2011 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.util;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.encuestame.core.files.PathUtil;
+import org.encuestame.core.util.MD5Utils;
+
+/**
+ * Dojo Widgeg Utils.
+ * @author Picado, Juan juanATencuestame.org
+ * @since Jan 23, 2011 8:23:58 AM
+ * @version $Id:$
+ */
+public class WidgetUtil {
+
+    private static final String GRAVATAR_URL = "http://www.gravatar.com/avatar/";
+
+    private static final String URL = "http://";
+
+    private static final Integer REQUEST_SERVER_PORT = 80;
+
+    /**
+     *
+     * @param request
+     * @return
+     */
+    public static String getUserProfileImagePath(final HttpServletRequest request) {
+        final StringBuilder domain = new StringBuilder(WidgetUtil.getDomain(request));
+        domain.append(PathUtil.profileUserImage);
+        return domain.toString();
+    }
+
+    /**
+     * Get Domain.
+     * @param request
+     * @return
+     */
+    public static final String getDomain(final HttpServletRequest request) {
+        final StringBuffer domain = new StringBuffer(WidgetUtil.URL);
+        domain.append(request.getServerName());
+        if (request.getServerPort() != WidgetUtil.REQUEST_SERVER_PORT) {
+            domain.append(":");
+            domain.append(request.getServerPort());
+        }
+        // buffer.append("//");
+        domain.append(request.getContextPath());
+        return domain.toString();
+    }
+
+    /**
+     * Get Gravatar.
+     * @param email
+     * @param size
+     * @return
+     */
+    public final String getGravatar(final String email, Integer size) {
+        final String hash = MD5Utils.md5Hex(email);
+        StringBuilder gravatarUl = new StringBuilder();
+        gravatarUl.append(WidgetUtil.GRAVATAR_URL);
+        gravatarUl.append(hash);
+        gravatarUl.append("?s=");
+        gravatarUl.append(size);
+        return gravatarUl.toString();
+    }
+}

encuestame-war/src/main/webapp/WEB-INF/flows/signup/profile.jsp

                 <div dojoType="encuestame.org.core.commons.signup.SignupProfile"
                      username="${signUpBean.username}"
                      email="${signUpBean.email}"
-                     fullName="${signUpBean.fullName}">
+                     fullName="${signUpBean.fullName}"
+                     contextPath="<%=WidgetUtil.getDomain(request)%>"
+                     imagePath="<%=WidgetUtil.getUserProfileImagePath(request)%>">
                 </div>
 
             </div>
             <br/>
-            <input type="submit" name="_eventId_next" value="Update My Profile"/>
+            <input type="submit" name="_eventId_next" value="Go to DashBoard"/>
         </form:form>
     </div>
 <%@ include file="/WEB-INF/jsp/includes/footer.jsp" %>

encuestame-war/src/main/webapp/WEB-INF/jsp/includes/taglibs.jsp

 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
 <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
 <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
-<%@ taglib uri="http://www.springframework.org/spring-social/facebook/tags" prefix="facebook" %>
+<%@ taglib uri="http://www.springframework.org/spring-social/facebook/tags" prefix="facebook" %>
+<%@page import="org.encuestame.mvc.util.WidgetUtil"%>

encuestame-war/src/main/webapp/resource/css/default.css

       min-height : 16px;
       display: inline-block;
       width: 16px;
+}
+
+div.updateProfile{
+
+}
+
+div.updateProfile .pictureWrapper{
+    min-height: 128px;
+    min-width: 95px;
+}
+
+div.updateProfile .pictureProfileNew{
+    padding: 10px;
+    text-align: center;
+    width: 400px;'
+}
+
+div.updateProfile .pictureProfileNew .class{
+    position: relative;
+    height: 100%;
+    width: auto;
+    opacity: 0;
+    -moz-opacity: 0;
+    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);
+}
+
+div.updateProfile .profileItem{
+    padding: 5px;
+}
+
+div.updateProfile .profileItem label{
+    font-size: 12px;
+    font-weight: bold;
 }
Add a comment to this file

encuestame-war/src/main/webapp/resource/images/default.png

Added
New image

encuestame-war/src/main/webapp/resource/js/encuestame/org/core/commons.js

 encuestame.service.list.removeNotification = encuestame.contextWidget()+"/api/remove-notification.json"
 encuestame.service.list.userInfo = encuestame.contextWidget()+"/api/admon/user-info.json";
 encuestame.service.list.createUser = encuestame.contextWidget()+"/api/admon/create-user.json";
+encuestame.service.list.upgradeProfile = encuestame.contextWidget()+"/api/user/profile/upgrade.json";
+
 encuestame.service.list.listPermissions = encuestame.contextWidget()+"/api/admon/list-permissions.json";
 encuestame.service.list.listUserPermissions = encuestame.contextWidget()+"/api/admon/list-user-permissions.json";
 encuestame.service.list.addPermission = encuestame.contextWidget()+"/api/admon/add-permission.json";
 encuestame.service.list.removePermission = encuestame.contextWidget()+"/api/admon/remove-permission.json";
 encuestame.service.list.hashtags = encuestame.contextWidget()+"/api/common/hashtags.json";
 encuestame.service.list.twitterAccount = encuestame.contextWidget()+"/api/common/twitter/valid-accounts.json";
+
 //tweetpoll service
 encuestame.service.list.publishTweetPoll = encuestame.contextWidget()+"/api/survey/tweetpoll/publish.json";
 encuestame.service.list.listTweetPoll = encuestame.contextWidget()+"/api/survey/tweetpoll/search.json";

encuestame-war/src/main/webapp/resource/js/encuestame/org/core/commons/signup/SignupProfile.js

 dojo.provide("encuestame.org.core.commons.signup.SignupProfile");
 
 dojo.require("dojo.io.iframe");
+dojo.require("dijit.form.TextBox");
+dojo.require("dijit.form.ComboButton");
+dojo.require("dijit.MenuItem");
+dojo.require("dijit.Menu");
 
 dojo.declare("encuestame.org.core.commons.signup.SignupProfile",
         [dijit._Widget, dijit._Templated ], {
 
     username : '',
 
+    context : '/',
+
+    imagePath : '/',
+
+    contextPath : '',
+
+    _size : ["preview", "default", "web"],
+
+    upgradeProfileService : encuestame.service.list.upgradeProfile,
+
     postCreate : function() {
         console.debug("username", this.username);
         console.debug("email", this.email);
         console.debug("fullName", this.fullName);
+        console.debug("dijit.byId", dijit.byId("completeName"));
+        var name = dijit.byId("completeName");
+        name.onChange = dojo.hitch(this, function(){
+            var name = dijit.byId("completeName").get('value');
+            console.debug("complete Name", name);
+            var d = dojo.hitch(this, function(respose){
+                console.debug(response);
+            });
+            this._upgradeProfile("completeName", name);
+        });
     },
 
     _uploadImage : function(event){
         this.uploadImage();
     },
 
+    _showPicture : function(url){
+        dojo.empty(this._pictureWrapper);
+        var textData = dojo.doc.createElement('img');
+        textData.src = url;
+        this._pictureWrapper.appendChild(textData);
+
+    },
+
+    /**
+     * Upgrade Profile.
+     * @param property
+     * @param value
+     * @param response
+     */
+    _upgradeProfile : function(property, value){
+        console.debug(property, value);
+        var params = {
+                 "property" : property,
+                "value" : value
+        };
+        var load = function(response){
+            console.debug("response", response);
+        };
+        var error = function(error) {
+            console.debug("error", error);
+        };
+        encuestame.service.xhrGet(
+                encuestame.service.list.upgradeProfile, params, load, error);
+    },
+
+    /**
+     * Upgrade CompleteName
+     * @param event
+     */
+    _upgradeCompleteName : function(event){
+
+    },
+
+    _upgradeEmail : function(event){
+        dojo.stopEvent(event);
+    },
+
     uploadImage : function() {
         dojo.io.iframe.send({
             form : dojo.byId("imageForm"),
             handleAs : "html",
-            handle : function(ioResponse, args) {
+            handle : dojo.hitch(this, function(ioResponse, args) {
                 if (ioResponse instanceof Error) {
                     console.error("handle error: " + ioResponse);
                 } else {
-                    console.info("handle response: " + ioResponse);
+                    var url =  this.imagePath+ "/" + this.username+"/" + this._size[1];
+                    console.debug(args);
+                    console.info("image path response: " + this.imagePath+ "/" + this.username+"/" + this._size[1]);
+                    this._showPicture(url);
                 }
-            },
+            }),
             // Callback on successful call:
             load: function(response, ioArgs) {
                 // do something

encuestame-war/src/main/webapp/resource/js/encuestame/org/core/commons/signup/templates/profile.inc

 <div class="updateProfile">
-        FORMULARIO ACTUALIZACION
-        <h1>Please upload a file</h1>
-        <form method="post" action="/encuestame/user/file/upload/profile" enctype="multipart/form-data" id="imageForm">
-              <input type="file" name="file" onkeydown="javascript:return false;"/>
-              <input type="button" value="Upload" dojoAttachEvent="onclick:_uploadImage"
-        </form>
+    <table>
+        <tr>
+            <td>
+                <div class="pictureWrapper" dojoAttachPoint="_pictureWrapper">
+                    <img src="${contextPath}/resource/images/default.png"/>
+                </div>
+            </td>
+            <td>
+                <div class="pictureProfileNew">
+                Choose one file from your computer (10 MB máx.):
+                <form method="post" action="/encuestame/user/file/upload/profile" enctype="multipart/form-data" id="imageForm">
+                      <input type="file" class="file" onkeydown="javascript:return false;" dojoAttachEvent="onchange:_uploadImage"/>
+                </form>
+                </div>
+            </td>
+        </tr>
+    </table>
+    <div>
+        <div class="profileItem">
+            <label>Your Real Name</label>
+            <input id="completeName" type="text" dojoAttachPoint="_suggest" dojoType="dijit.form.TextBox"
+                   trim="true"
+                   class="inputClass"></input>
+        </div>
+        <div class="profileItem">
+            <label>My Email</label>
+            <input type="text" dojoAttachPoint="_suggest" dojoType="dijit.form.TextBox" trim="true"
+                   class="inputClass" dojoAttachEvent="onChange:_upgradeEmail"></input>
+        </div>
+
+        <div class="profileItem">
+            <label>Language</label>
+            <div dojoType="dijit.form.ComboButton">
+                <span>
+                    Select Your Language
+                </span>
+                <div dojoType="dijit.Menu">
+                    <div dojoType="dijit.MenuItem" onClick="console.log('hi!')">
+                        Spanish
+                    </div>
+                    <div dojoType="dijit.MenuItem" onClick="console.log('ho!')">
+                        English
+                    </div>
+                </div>
+            </div>
+        </div>
+
+    </div>
 </div>

src/site/apt/index.apt

 
 Links
 
-    * {{{http://www.encuestame.org/} Official Website}}
-
-    * {{{http://www.encuesta.me/} Blog}}
-
     * {{{http://sourceforge.net/projects/encuestame/files/} Downloads}}
 
-    * {{{http://www.encuesta.me/cgi-bin/mailman/listinfo/encuestame-es} Email List}}
-
     * {{{http://trac.encuesta.me/} Trac && Bugs}}
 
     * {{{http://metrics.encuestame.org/} Metrics}}
 
     * {{{http://demo.encuestame.org/encuestame/} Demo}}
 
-    * {{{http://stats.encuestame.org/} SVN Stats}}
+    * {{{http://stats.encuestame.org/git/} GIT Stats}}
 
     * {{{http://wiki.encuestame.org/en/Build_Guide} Build Guide}}
 
-    * {{{http://svn.encuesta.me/trunk/encuestame} Subversion Source Code}}
-
     * {{{http://webalizer.encuestame.org/} Webalizer}}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.