当前位置: 首页>>代码示例>>Java>>正文


Java Validation.hasErrors方法代码示例

本文整理汇总了Java中play.data.validation.Validation.hasErrors方法的典型用法代码示例。如果您正苦于以下问题:Java Validation.hasErrors方法的具体用法?Java Validation.hasErrors怎么用?Java Validation.hasErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在play.data.validation.Validation的用法示例。


在下文中一共展示了Validation.hasErrors方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ftpserver_export_user_sessions

import play.data.validation.Validation; //导入方法依赖的package包/类
@Check("adminFtpServer")
public static void ftpserver_export_user_sessions(@Required String user_session_ref) throws Exception {
	if (Validation.hasErrors()) {
		notFound();
	}
	
	response.contentType = "text/csv";
	String contentDisposition = "%1$s; filename*=UTF-8''%2$s; filename=\"%2$s\"";
	
	response.setHeader("Content-Disposition", String.format(contentDisposition, "attachment", "FTP_activity_" + Loggers.dateFilename(System.currentTimeMillis()) + ".csv"));
	
	try {
		FTPActivity.getAllUserActivitiesCSV(user_session_ref, response.out);
	} catch (Exception e) {
		if (e.getMessage().equals("noindex")) {
			renderText("(No data)");
		}
	}
	IOUtils.closeQuietly(response.out);
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:21,代码来源:Manager.java

示例2: save

import play.data.validation.Validation; //导入方法依赖的package包/类
public static void save(@Required(message = "validation.requiere.email") String email, 
                        @Required(message = "validation.requiere.name") String name, 
                        @Required String preferredLang, String twitter, String organization, 
    String timeZone, String web) {
  checkAuthenticity();
  User current = getCurrentUser();
  User user = DarwinFactory.getInstance().loadUser(email);
  
  if (user != null && !Validation.hasErrors()) {
    if (current.getEmail().equals(email) || current.isAdminUser()) {
      Logger.debug("Edit profile "+email+", name="+name+", preferredLang="+preferredLang);
      user.setName(name);
      user.setPreferredLang(preferredLang);
      
      // Save SinfonierUser fields
      SinfonierUser sinfonierUser = (SinfonierUser) user.getImplementation();
      sinfonierUser.setTwitter(twitter);
      sinfonierUser.setOrganization(organization);
      sinfonierUser.setTimeZoneID(timeZone);
      sinfonierUser.setWeb(web);
      user.save();
      
      // TODO: Change render when Bug #19153 is fixed in Darwin library. 
      //showUserProfile(email);
      render("Profile/index.html", user);
    } else {
      forbidden();
    }
  } else if (Validation.hasErrors()) {
    params.flash();
    render("Profile/edit.html", user); 
  } else {
    notFound();
  }
}
 
开发者ID:telefonicaid,项目名称:fiware-sinfonier,代码行数:36,代码来源:ProfileSinfonier.java

示例3: authenticate

import play.data.validation.Validation; //导入方法依赖的package包/类
public static void authenticate(@Required String username, String password, boolean remember) throws Throwable {
    if (!Play.mode.isDev()) {
        Validation.required("password", password);
    } else {
        if (password == null) {
            password = "";
        }
    }
    if (Validation.hasErrors()) {
        badRequestJson();
    }

    // Check tokens
    String userId = (String) Security.invoke("authenticate", username, password);
    if (userId == null) {
        validation.addError("global", "login.error");
        forbiddenJson();
    }

    // Mark user as connected
    session.put("username", userId);

    // Remember if needed
    if (remember) {
        Date expiration = new Date();
        String duration = Play.configuration.getProperty("secure.rememberme.duration","30d");
        expiration.setTime(expiration.getTime() + Time.parseDuration(duration) * 1000 );
        response.setCookie("rememberme", Crypto.sign(username + "-" + expiration.getTime()) + "-" + username + "-" + expiration.getTime(), duration);
    }

    Security.invoke("afterAuthenticate", userId);

    okJson();
}
 
开发者ID:sismics,项目名称:play-restsecure,代码行数:35,代码来源:RestSecure.java

示例4: _ifErrors

import play.data.validation.Validation; //导入方法依赖的package包/类
public static void _ifErrors(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) {
    if (Validation.hasErrors()) {
        body.call();
        TagContext.parent().data.put("_executeNextElse", false);
    } else {
        TagContext.parent().data.put("_executeNextElse", true);
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:9,代码来源:FastTags.java

示例5: changePassword

import play.data.validation.Validation; //导入方法依赖的package包/类
public static void changePassword(String email,
                                  @Required(message = "validation.required.profile.password")
                                  @Password @Equals(value="newPassword2", message = "validation.match.profile.password") 
                                  String newPassword1,
                                  @Required(message = "validation.required.profile.password")
                                  String newPassword2) 
    throws SinfonierException {
  checkAuthenticity();    
  User current = getCurrentUser();
  User user = DarwinFactory.getInstance().loadUser(email);
  
  if (user != null) {
    if (!Validation.hasErrors()) {
      if (current.getEmail().equals(email) || current.isAdminUser()) {
        Logger.debug("Change password "+email);
        try {
          user.changePassword(newPassword1);
        } catch (PasswordConstraintViolationException e) {
          throw new SinfonierException(SinfonierError.PASSWORD_CONSTRAINS, e);
        }
        user.save();
        
        // TODO: Change render when Bug #19153 is fixed in Darwin library. 
        //showUserProfile(email);
        render("Profile/index.html", user);
      } else {
        forbidden();
      }
    } else {
      for (play.data.validation.Error error : Validation.errors()) {
        Logger.error(error.message());
      }
  
      params.flash();
      // TODO: Change redirect when Bug #19469 is fixed in Darwin library. 
      //showUserProfile(email);
      render("Profile/index.html", user);
    }
  } else {
    notFound();
  }
}
 
开发者ID:telefonicaid,项目名称:fiware-sinfonier,代码行数:43,代码来源:ProfileSinfonier.java

示例6: JavascriptRessource

import play.data.validation.Validation; //导入方法依赖的package包/类
public static void JavascriptRessource(@Required String name, Long suffix_date) {
	if (Validation.hasErrors()) {
		badRequest();
	}
	
	File ressource_file = JSSourceManager.getPhysicalFileFromRessourceName(name);
	if (ressource_file == null) {
		notFound();
	}
	long last_modified = ressource_file.lastModified();
	
	String etag = last_modified + "--";
	
	if (suffix_date != null) {
		if (suffix_date > 0) {
			response.setHeader("Cache-Control", "max-age=864000");
		}
	}
	
	if (request.isModified(etag, last_modified) == false) {
		response.setHeader("Etag", etag);
		notModified();
	}
	
	if (FilenameUtils.isExtension(ressource_file.getName(), "gz")) {
		if (request.headers.containsKey("accept-encoding") == false) {
			badRequest("// Your browser don't accept encoding files.");
		}
		if (request.headers.get("accept-encoding").value().indexOf("gzip") == -1) {
			badRequest("// Your browser don't accept GZipped files.");
		}
		response.setHeader("Content-Encoding", "gzip");
	}
	
	response.setHeader("Content-Length", ressource_file.length() + "");
	response.setHeader("Content-Type", "text/javascript");
	response.setHeader("Etag", etag);
	response.setHeader("Last-Modified", Utils.getHttpDateFormatter().format(new Date(last_modified)));
	
	try {
		FileUtils.copyFile(ressource_file, response.out);
	} catch (IOException e) {
		Loggers.Play_JSSource.error("Can't response (send) js file: " + ressource_file, e);
		notFound();
	}
	
	ok();
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:49,代码来源:AsyncJavascript.java

示例7: authenticate

import play.data.validation.Validation; //导入方法依赖的package包/类
public static void authenticate(@Required String username, @Required String password, String domainidx, boolean remember) throws Throwable {
	String remote_address = request.remoteAddress;
	
	if (Validation.hasErrors()) {
		rejectUser();
		return;
	}
	
	if (AccessControl.validThisIP(remote_address) == false) {
		Loggers.Play.warn("Refuse IP addr for user username: " + username + ", domainidx: " + domainidx + ", remote_address: " + remote_address);
		rejectUser();
		return;
	}
	
	UserNG authuser = null;
	
	if (MyDMAM.getPlayBootstrapper().getAuth().isForceSelectDomain()) {
		String domain_name = null;
		
		try {
			domain_name = MyDMAM.getPlayBootstrapper().getAuth().getDeclaredDomainList().get(Integer.valueOf(domainidx));
		} catch (Exception e) {
		}
		authuser = MyDMAM.getPlayBootstrapper().getAuth().authenticateWithThisDomain(remote_address, username.trim().toLowerCase(), password, domain_name, Lang.getLocale().getLanguage());
	} else {
		authuser = MyDMAM.getPlayBootstrapper().getAuth().authenticate(remote_address, username.trim().toLowerCase(), password, Lang.getLocale().getLanguage());
	}
	
	if (authuser == null) {
		Loggers.Play.error("Can't login username: " + username + ", domainidx: " + domainidx + ", " + getUserSessionInformation());
		AccessControl.failedAttempt(remote_address, username);
		rejectUser();
	}
	
	username = authuser.getKey();
	
	AccessControl.releaseIP(remote_address);
	
	Session.current().put("username", Crypto.encryptAES(username));
	
	Cache.set("user:" + username + ":privileges", authuser.getUser_groups_roles_privileges(), MyDMAM.getPlayBootstrapper().getSessionTTL());
	
	String long_name = authuser.getFullname();
	if (long_name == null) {
		long_name = authuser.getName();
	}
	
	Loggers.Play.info(long_name + " has a successful authentication, with privileges: " + getSessionPrivileges().toString() + ". User key: " + username);
	
	redirect("Application.index");
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:52,代码来源:Secure.java


注:本文中的play.data.validation.Validation.hasErrors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。