Package gotnames.dm

Examples of gotnames.dm.ProfilePictureData


        } else {
          // profile picture
          int lastDot = fileName.lastIndexOf('.');
          String fullName = lastDot < 0 ? fileName : fileName.substring(0, lastDot);
          try {
             final ProfilePictureData profilePicture = ProfilePictureData.getProfilePicture(IOUtils.toByteArray(zipFile));
            msg.add("Read profile picture for " + fileName);
            profilePics.put(fullName, profilePicture);
          } catch (RuntimeException e) {
            msg.add("Failed to read profile picture for " + fileName + ": " + e.getMessage());
          }
        }
      }
      
       if (rows == null)
         return rawStringUtf8("No 'Users.csv' in zip file");
      
       List<User> users = Funcs.map(rows, new Func<String, User>() {
        @Override public User call(String row) {
           List<String> cells = Strings.split(row, "\t");
           final String firstName = notNull("First name", row, strip(cells.get(0)));
           final String lastName = notNull("Last name", row, strip(cells.get(1)));
           final String email = notNull("Email", row, strip(cells.get(2)));
           final Gender gender = notNull("Gender", row, Gender.parse(strip(cells.get(3))));
          
           final boolean disableEmail = cells.size() > 4 && Boolean.valueOf(strip(cells.get(4)).toLowerCase());
           final boolean admin = cells.size() > 5 && Boolean.valueOf(strip(cells.get(5)).toLowerCase());
          
           return new KTrans<User>(pm) {
            @Override protected User call() {
               User u = QueryBuilder.begin(pm, User.class).getSingleByField("email", email);
               if (u == null) {
                 u = User.newUser(groupKey);
                 u.setEmail(email);
               }
               u.setFirstName(firstName);
               u.setLastName(lastName);
               u.setGender(gender);
               u.setDisableEmail(disableEmail);
               u.setAdmin(admin);
              
               ProfilePictureData profilePicture = profilePics.get(u.getFullName());
               if (profilePicture != null)
                 u.setProfilePictureInfo(profilePicture);
              
               pm.makePersistent(u);
              
View Full Code Here


          OutputSettings jpeg = new OutputSettings(OutputEncoding.JPEG);
          image = ImagesServiceFactory.getImagesService().applyTransform(crop, image, jpeg);
        }
      }
     
      final ProfilePictureData profilePicture = ProfilePictureData.getProfilePicture(image.getImageData());
      ProfilePicture.saveProfilePicture(user, pm, profilePicture);
     
      userAuthenticator.userUpdated(new KTrans<User>(pm) {
        @Override protected User call() {
           User u = QueryBuilder.begin(pm, User.class).getSingleByKey(user.getKey());
View Full Code Here

            try {
              URL url = new URL(person[3]);
              byte[] rawProfilePictureBytes = IOUtils.toByteArray(url.openStream());

              ProfilePictureData profilePicture = ProfilePictureData.getProfilePicture(rawProfilePictureBytes);
              u.setProfilePictureInfo(profilePicture);

              pm.makePersistent(u);

              return Pair.cons(u, profilePicture);
View Full Code Here

  }
 
  void action(final User user, final Params p, PersistenceManager pm, UserAuthenticator userAuthenticator) {
    final String email = p.email();
   
    final ProfilePictureData profilePicture = ProfilePictureData.getProfilePicture(p.profilePicture());
   
    User u;
    if (email != null || profilePicture != null) {
      // save picture first
      ProfilePicture.saveProfilePicture(user, pm, profilePicture);
View Full Code Here

 
  PostAction action(final User user, final Params p, DynamicInput di, PersistenceManager pm, UserAuthenticator userAuthenticator) {
    if (!user.isAdmin())
      return redirectToTask(GuessNamesTask.class);
   
    final ProfilePictureData profilePicture = ProfilePictureData.getProfilePicture(p.profilePicture());

    final String email = p.email();
    if (email != null) {
      // Check if the email is already in use
      User existingUser = User.getByEmail(pm, email);
View Full Code Here

            u.setLastName(Utils.notNull(di.getInput(key + "_lastName", String.class), "Last name is required"));
            u.setGender(Utils.notNull(di.getInput(key + "_gender", Gender.class), "Gender is required"));
            u.setAdmin(di.getInput(key + "_admin", Boolean.TYPE));
            u.setDisableEmail(di.getInput(key + "_disableEmail", Boolean.TYPE));
           
            ProfilePictureData profilePicture = ProfilePictureData.getProfilePicture(di.getInput(key + "_profilePicture", byte[].class));
   
            if (profilePicture != null)
              u.setProfilePictureInfo(profilePicture);
   
            pm.makePersistent(u);
View Full Code Here

TOP

Related Classes of gotnames.dm.ProfilePictureData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.