public boolean existsCollection(String collectionName) throws SqlInjectionException { if (Logger.isTraceEnabled()) Logger.trace("Method Start"); OIndex idx = db.getMetadata().getIndexManager().getIndex(COLLECTION_NAME_INDEX); OIdentifiable record = (OIdentifiable) idx.get(collectionName); if (Logger.isTraceEnabled()) Logger.trace("Method End"); return (record != null); }
public static void serve404( NotFound e, ChannelHandlerContext ctx, Request request, HttpRequest nettyRequest) { Logger.trace("serve404: begin"); HttpResponse nettyResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.NOT_FOUND); nettyResponse.setHeader(SERVER, signature); nettyResponse.setHeader(CONTENT_TYPE, "text/html"); Map<String, Object> binding = getBindingForErrors(e, false); String format = Request.current().format; if (format == null) { format = "txt"; } nettyResponse.setHeader( CONTENT_TYPE, (MimeTypes.getContentType("404." + format, "text/plain"))); String errorHtml = TemplateLoader.load("errors/404." + format).render(binding); try { ChannelBuffer buf = ChannelBuffers.copiedBuffer(errorHtml.getBytes("utf-8")); nettyResponse.setContent(buf); ChannelFuture writeFuture = ctx.getChannel().write(nettyResponse); writeFuture.addListener(ChannelFutureListener.CLOSE); } catch (UnsupportedEncodingException fex) { Logger.error(fex, "(utf-8 ?)"); } Logger.trace("serve404: end"); }
@Override public boolean init() { Logger.trace("init: begin"); Request.current.set(request); Response.current.set(response); try { super.init(); if (Play.mode == Play.Mode.PROD && staticPathsCache.containsKey(request.path)) { RenderStatic rs = null; synchronized (staticPathsCache) { rs = staticPathsCache.get(request.path); } serveStatic(rs, ctx, request, response, nettyRequest, event); Logger.trace("init: end false"); return false; } Router.routeOnlyStatic(request); } catch (NotFound nf) { serve404(nf, ctx, request, nettyRequest); Logger.trace("init: end false"); return false; } catch (RenderStatic rs) { if (Play.mode == Play.Mode.PROD) { synchronized (staticPathsCache) { staticPathsCache.put(request.path, rs); } } serveStatic(rs, ctx, request, response, nettyRequest, this.event); Logger.trace("init: end false"); return false; } Logger.trace("init: end true"); return true; }
protected static void writeResponse( ChannelHandlerContext ctx, Response response, HttpResponse nettyResponse, HttpRequest nettyRequest) { Logger.trace("writeResponse: begin"); byte[] content = null; final boolean keepAlive = isKeepAlive(nettyRequest); if (nettyRequest.getMethod().equals(HttpMethod.HEAD)) { content = new byte[0]; } else { content = response.out.toByteArray(); } ChannelBuffer buf = ChannelBuffers.copiedBuffer(content); nettyResponse.setContent(buf); if (keepAlive) { // Add 'Content-Length' header only for a keep-alive connection. Logger.trace("writeResponse: content length [" + response.out.size() + "]"); setContentLength(nettyResponse, response.out.size()); } ChannelFuture f = ctx.getChannel().write(nettyResponse); // Decide whether to close the connection or not. if (!keepAlive) { // Close the connection when the whole content is written out. f.addListener(ChannelFutureListener.CLOSE); } Logger.trace("writeResponse: end"); }
@Override public F.Promise<SimpleResult> call(Context ctx) throws Throwable { if (Logger.isTraceEnabled()) Logger.trace("Method Start"); Context.current.set(ctx); if (Logger.isDebugEnabled()) Logger.debug("AnonymousLogin for resource " + Context.current().request()); String user = BBConfiguration.getBaasBoxUsername(); String password = BBConfiguration.getBaasBoxPassword(); // retrieve AppCode String appCode = RequestHeaderHelper.getAppCode(ctx); ctx.args.put("username", user); ctx.args.put("password", password); ctx.args.put("appcode", appCode); if (Logger.isDebugEnabled()) Logger.debug("username (defined in conf file): " + user); if (Logger.isDebugEnabled()) Logger.debug("password (defined in conf file): " + password); if (Logger.isDebugEnabled()) Logger.debug("appcode (from header or querystring): " + appCode); if (Logger.isDebugEnabled()) Logger.debug("token: N/A"); // executes the request F.Promise<SimpleResult> tempResult = delegate.call(ctx); WrapResponse wr = new WrapResponse(); // SimpleResult result=wr.wrap(ctx, tempResult); F.Promise<SimpleResult> result = wr.wrapAsync(ctx, tempResult); if (Logger.isTraceEnabled()) Logger.trace("Method End"); return result; }
@With({UserCredentialWrapFilter.class, ConnectToDBFilter.class}) @BodyParser.Of(BodyParser.Json.class) public static Result changePassword() { Logger.trace("Method Start"); Http.RequestBody body = request().body(); JsonNode bodyJson = body.asJson(); Logger.trace("changePassword bodyJson: " + bodyJson); if (bodyJson == null) return badRequest( "The body payload cannot be empty. Hint: put in the request header Content-Type: application/json"); // check and validate input if (!bodyJson.has("old")) return badRequest("The 'old' field is missing"); if (!bodyJson.has("new")) return badRequest("The 'new' field is missing"); String currentPassword = DbHelper.getCurrentHTTPPassword(); String oldPassword = (String) bodyJson.findValuesAsText("old").get(0); String newPassword = (String) bodyJson.findValuesAsText("new").get(0); if (!oldPassword.equals(currentPassword)) { return badRequest("The old password does not match with the current one"); } UserService.changePasswordCurrentUser(newPassword); Logger.trace("Method End"); return ok(); }
/** * * Creates an entry into the ODocument-Collection and create a new Class named "collectionName" * * @param collectionName * @return * @throws Throwable */ public ODocument create(String collectionName) throws Throwable { Logger.trace("Method Start"); try { if (existsCollection(collectionName)) throw new InvalidCollectionException("Collection " + collectionName + " already exists"); } catch (SqlInjectionException e) { throw new InvalidCollectionException(e); } ODocument doc = super.create(); doc.field("name", collectionName); save(doc); // create new class OClass documentClass = db.getMetadata().getSchema().getClass(CLASS_NODE_NAME); db.getMetadata().getSchema().createClass(collectionName, documentClass); // grants to the new class ORole registeredRole = RoleDao.getRole(DefaultRoles.REGISTERED_USER.toString()); ORole anonymousRole = RoleDao.getRole(DefaultRoles.ANONYMOUS_USER.toString()); registeredRole.addRule( ODatabaseSecurityResources.CLASS + "." + collectionName, ORole.PERMISSION_ALL); registeredRole.addRule( ODatabaseSecurityResources.CLUSTER + "." + collectionName, ORole.PERMISSION_ALL); anonymousRole.addRule( ODatabaseSecurityResources.CLASS + "." + collectionName, ORole.PERMISSION_READ); anonymousRole.addRule( ODatabaseSecurityResources.CLUSTER + "." + collectionName, ORole.PERMISSION_READ); PermissionsHelper.grantRead(doc, registeredRole); PermissionsHelper.grantRead(doc, anonymousRole); Logger.trace("Method End"); return doc; } // getNewModelInstance(String collectionName)
public boolean existsCollection(String collectionName) throws SqlInjectionException { Logger.trace("Method Start"); QueryParams criteria = QueryParams.getInstance().where(NAME + "=?").params(new String[] {collectionName}); List<ODocument> resultList = super.get(criteria); Logger.trace("Method End"); return (resultList.size() > 0); }
@Override public ODocument create() throws Throwable { if (Logger.isTraceEnabled()) Logger.trace("Method Start"); DbHelper.requestTransaction(); ODocument doc = super.create(); if (Logger.isTraceEnabled()) Logger.trace("Method End"); return doc; } // getNewModelInstance
/* @Path("/{id}") @ApiOperation(value = "Get info about current user", notes = "", httpMethod = "GET") */ @With({UserCredentialWrapFilter.class, ConnectToDBFilter.class}) public static Result getCurrentUser() throws SqlInjectionException { Logger.trace("Method Start"); ODocument profile = UserService.getCurrentUser(); String result = prepareResponseToJson(profile); Logger.trace("Method End"); return ok(result); }
public static void dropOrientDefault() { Logger.trace("Method Start"); OGraphDatabase db = DbHelper.getConnection(); db.getMetadata().getSecurity().dropUser("reader"); db.getMetadata().getSecurity().dropUser("writer"); db.getMetadata().getSecurity().dropRole("reader"); db.getMetadata().getSecurity().dropRole("writer"); Logger.trace("Method End"); }
@Override protected void service( HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { if (!routerInitializedWithContext) { loadRouter(httpServletRequest.getContextPath()); } if (Logger.isTraceEnabled()) { Logger.trace("ServletWrapper>service " + httpServletRequest.getRequestURI()); } Request request = null; try { Response response = new Response(); response.out = new ByteArrayOutputStream(); Response.current.set(response); request = parseRequest(httpServletRequest); if (Logger.isTraceEnabled()) { Logger.trace("ServletWrapper>service, request: " + request); } boolean raw = Play.pluginCollection.rawInvocation(request, response); if (raw) { copyResponse( Request.current(), Response.current(), httpServletRequest, httpServletResponse); } else { Invoker.invokeInThread( new ServletInvocation(request, response, httpServletRequest, httpServletResponse)); } } catch (NotFound e) { if (Logger.isTraceEnabled()) { Logger.trace("ServletWrapper>service, NotFound: " + e); } serve404(httpServletRequest, httpServletResponse, e); return; } catch (RenderStatic e) { if (Logger.isTraceEnabled()) { Logger.trace("ServletWrapper>service, RenderStatic: " + e); } serveStatic(httpServletResponse, httpServletRequest, e); return; } catch (Throwable e) { throw new ServletException(e); } finally { Request.current.remove(); Response.current.remove(); Scope.Session.current.remove(); Scope.Params.current.remove(); Scope.Flash.current.remove(); Scope.RenderArgs.current.remove(); Scope.RouteArgs.current.remove(); } }
@Override public void run() { try { Logger.trace("run: begin"); super.run(); } catch (Exception e) { serve500(e, ctx, nettyRequest); } Logger.trace("run: end"); }
public ODocument getByName(String collectionName) throws SqlInjectionException { Logger.trace("Method Start"); ODocument result = null; QueryParams criteria = QueryParams.getInstance().where(NAME + "=?").params(new String[] {collectionName}); List<ODocument> resultList = super.get(criteria); if (resultList != null && resultList.size() > 0) result = resultList.get(0); Logger.trace("Method End"); return result; }
@With({ AdminCredentialWrapFilter.class, ConnectToDBFilter.class, }) @BodyParser.Of(BodyParser.Json.class) public static Result signUp() { Logger.trace("Method Start"); Http.RequestBody body = request().body(); JsonNode bodyJson = body.asJson(); Logger.trace("signUp bodyJson: " + bodyJson); if (bodyJson == null) return badRequest( "The body payload cannot be empty. Hint: put in the request header Content-Type: application/json"); // check and validate input if (!bodyJson.has("username")) return badRequest("The 'username' field is missing"); if (!bodyJson.has("password")) return badRequest("The 'password' field is missing"); // extract mandatory fields JsonNode nonAppUserAttributes = bodyJson.get(UserDao.ATTRIBUTES_VISIBLE_BY_ANONYMOUS_USER); JsonNode privateAttributes = bodyJson.get(UserDao.ATTRIBUTES_VISIBLE_ONLY_BY_THE_USER); JsonNode friendsAttributes = bodyJson.get(UserDao.ATTRIBUTES_VISIBLE_BY_FRIENDS_USER); JsonNode appUsersAttributes = bodyJson.get(UserDao.ATTRIBUTES_VISIBLE_BY_REGISTERED_USER); String username = (String) bodyJson.findValuesAsText("username").get(0); String password = (String) bodyJson.findValuesAsText("password").get(0); if (privateAttributes != null && privateAttributes.has("email")) { // check if email address is valid if (!Util.validateEmail((String) privateAttributes.findValuesAsText("email").get(0))) return badRequest("The email address must be valid."); } // try to signup new user try { UserService.signUp( username, password, nonAppUserAttributes, privateAttributes, friendsAttributes, appUsersAttributes); } catch (UserAlreadyExistsException e) { Logger.debug("signUp", e); return badRequest(username + " already exists"); } catch (Throwable e) { Logger.warn("signUp", e); if (Play.isDev()) return internalServerError(ExceptionUtils.getFullStackTrace(e)); else return internalServerError(e.getMessage()); } Logger.trace("Method End"); return created(); }
public static void createDefaultUsers() throws Exception { Logger.trace("Method Start"); // the baasbox default user used to connect to the DB like anonymous user String username = BBConfiguration.getBaasBoxUsername(); String password = BBConfiguration.getBaasBoxPassword(); UserService.signUp( username, password, DefaultRoles.ANONYMOUS_USER.toString(), null, null, null, null); OGraphDatabase db = DbHelper.getConnection(); OUser admin = db.getMetadata().getSecurity().getUser("admin"); admin.setPassword(BBConfiguration.configuration.getString(BBConfiguration.ADMIN_PASSWORD)); admin.save(); Logger.trace("Method End"); }
public ODocument getByName(String collectionName) throws SqlInjectionException { if (Logger.isTraceEnabled()) Logger.trace("Method Start"); OIndex idx = db.getMetadata().getIndexManager().getIndex(COLLECTION_NAME_INDEX); OIdentifiable record = (OIdentifiable) idx.get(collectionName); if (record == null) return null; return db.load(record.getIdentity()); }
public static void rollbackTransaction() { OGraphDatabase db = getConnection(); if (isInTransaction()) { Logger.trace("Rollback transaction"); db.rollback(); } }
public static void commitTransaction() { OGraphDatabase db = getConnection(); if (isInTransaction()) { Logger.trace("Commit transaction"); db.commit(); } }
public static void requestTransaction() { OGraphDatabase db = getConnection(); if (!isInTransaction()) { Logger.trace("Begin transaction"); db.begin(); } }
public static Route getRoute( String method, String path, String action, String params, String headers, String sourceFile, int line) { Route route = new Route(); route.method = method; route.path = path.replace("//", "/"); route.action = action; route.routesFile = sourceFile; route.routesFileLine = line; route.addFormat(headers); route.addParams(params); route.compute(); if (Logger.isTraceEnabled()) { Logger.trace( "Adding [" + route.toString() + "] with params [" + params + "] and headers [" + headers + "]"); } return route; }
public static synchronized Stack<Evolution> listApplicationEvolutions() { Stack<Evolution> evolutions = new Stack<Evolution>(); evolutions.add(new Evolution(0, "", "", true)); if (evolutionsDirectory.exists()) { for (File evolution : evolutionsDirectory.listFiles()) { if (evolution.getName().matches("^[0-9]+[.]sql$")) { if (Logger.isTraceEnabled()) { Logger.trace("Loading evolution %s", evolution); } int version = Integer.parseInt(evolution.getName().substring(0, evolution.getName().indexOf("."))); String sql = IO.readContentAsString(evolution); StringBuffer sql_up = new StringBuffer(); StringBuffer sql_down = new StringBuffer(); StringBuffer current = new StringBuffer(); for (String line : sql.split("\r?\n")) { if (line.trim().matches("^#.*[!]Ups")) { current = sql_up; } else if (line.trim().matches("^#.*[!]Downs")) { current = sql_down; } else if (line.trim().startsWith("#")) { // skip } else if (!StringUtils.isEmpty(line.trim())) { current.append(line).append("\n"); } } evolutions.add(new Evolution(version, sql_up.toString(), sql_down.toString(), true)); } } Collections.sort(evolutions); } return evolutions; }
public static Route route(Http.Request request) { if (Logger.isTraceEnabled()) { Logger.trace("Route: " + request.path + " - " + request.querystring); } // request method may be overriden if a x-http-method-override parameter is given if (request.querystring != null && methodOverride.matches(request.querystring)) { Matcher matcher = methodOverride.matcher(request.querystring); if (matcher.matches()) { if (Logger.isTraceEnabled()) { Logger.trace( "request method %s overriden to %s ", request.method, matcher.group("method")); } request.method = matcher.group("method"); } } for (Route route : routes) { Map<String, String> args = route.matches(request.method, request.path, request.format, request.domain); if (args != null) { request.routeArgs = args; request.action = route.action; if (args.containsKey("format")) { request.format = args.get("format"); } if (request.action.indexOf("{") > -1) { // more optimization ? for (String arg : request.routeArgs.keySet()) { request.action = request.action.replace("{" + arg + "}", request.routeArgs.get(arg)); } } if (request.action.equals("404")) { throw new NotFound(route.path); } return route; } } // Not found - if the request was a HEAD, let's see if we can find a corresponding GET if (request.method.equalsIgnoreCase("head")) { request.method = "GET"; Route route = route(request); request.method = "HEAD"; if (route != null) { return route; } } throw new NotFound(request.method, request.path); }
@Override protected void service( HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { if (!routerInitializedWithContext) { // Reload the rules, but this time with the context. Not really efficient through... // Servlet 2.4 does not allow you to get the context path from the servletcontext... loadRouter(httpServletRequest.getContextPath()); } Logger.trace("ServletWrapper>service " + httpServletRequest.getRequestURI()); Request request = null; try { Response response = new Response(); response.out = new ByteArrayOutputStream(); Response.current.set(response); request = parseRequest(httpServletRequest); Logger.trace("ServletWrapper>service, request: " + request); boolean raw = false; for (PlayPlugin plugin : Play.plugins) { if (plugin.rawInvocation(request, response)) { raw = true; break; } } if (raw) { copyResponse( Request.current(), Response.current(), httpServletRequest, httpServletResponse); } else { Invoker.invokeInThread( new ServletInvocation(request, response, httpServletRequest, httpServletResponse)); } } catch (NotFound e) { Logger.trace("ServletWrapper>service, NotFound: " + e); serve404(httpServletRequest, httpServletResponse, e); return; } catch (RenderStatic e) { Logger.trace("ServletWrapper>service, RenderStatic: " + e); serveStatic(httpServletResponse, httpServletRequest, e); return; } catch (Throwable e) { throw new ServletException(e); } }
/** Stop the application */ public static synchronized void stop() { if (started) { Logger.trace("Stopping the play application"); pluginCollection.onApplicationStop(); started = false; Cache.stop(); Router.lastLoading = 0L; } }
public static void log( String level, String clazz, String clazzSimpleName, String packageName, String method, String signature, String fileName, String relativeFileName, int line, Object[] args) { Throwable throwable = null; String pattern = ""; if (args[0] instanceof Throwable) { throwable = (Throwable) args[0]; pattern = (String) args[1]; } else { pattern = (String) args[0]; } pattern = stringFormatPrefix + pattern; Object[] betterLogsArgs = new Object[argsPrefix.size()]; int i = 0; for (String argName : argsPrefix) { if ("class".equals(argName)) betterLogsArgs[i] = clazz; if ("simpleClass".equals(argName)) betterLogsArgs[i] = clazzSimpleName; if ("package".equals(argName)) betterLogsArgs[i] = packageName; if ("method".equals(argName)) betterLogsArgs[i] = method; if ("file".equals(argName)) betterLogsArgs[i] = fileName; if ("line".equals(argName)) betterLogsArgs[i] = line; if ("relativeFile".equals(argName)) betterLogsArgs[i] = relativeFileName; if ("signature".equals(argName)) betterLogsArgs[i] = signature; i++; } if ("trace".equals(level)) { Logger.trace(pattern, handleLogArgs(betterLogsArgs, args, 1)); } else if ("debug".equals(level)) { if (throwable != null) Logger.debug(throwable, pattern, handleLogArgs(betterLogsArgs, args, 2)); else Logger.debug(pattern, handleLogArgs(betterLogsArgs, args, 1)); } else if ("info".equals(level)) { if (throwable != null) Logger.info(throwable, pattern, handleLogArgs(betterLogsArgs, args, 2)); else Logger.info(pattern, handleLogArgs(betterLogsArgs, args, 1)); } else if ("warn".equals(level)) { if (throwable != null) Logger.warn(throwable, pattern, handleLogArgs(betterLogsArgs, args, 2)); else Logger.warn(pattern, handleLogArgs(betterLogsArgs, args, 1)); } else if ("error".equals(level)) { if (throwable != null) Logger.error(throwable, pattern, handleLogArgs(betterLogsArgs, args, 2)); else Logger.error(pattern, handleLogArgs(betterLogsArgs, args, 1)); } else if ("fatal".equals(level)) { if (throwable != null) Logger.fatal(throwable, pattern, handleLogArgs(betterLogsArgs, args, 2)); else Logger.fatal(pattern, handleLogArgs(betterLogsArgs, args, 1)); } }
@Override public void onSuccess() throws Exception { super.onSuccess(); if (response.chunked) { closeChunked(request, response, ctx, nettyRequest); } else { copyResponse(ctx, request, response, nettyRequest); } Logger.trace("execute: end"); }
public static synchronized Stack<Evolution> listDatabaseEvolutions(String moduleKey) { Stack<Evolution> evolutions = new Stack<Evolution>(); evolutions.add(new Evolution("", 0, "", "", false)); Connection connection = null; try { connection = EvolutionQuery.getNewConnection(); String tableName = "play_evolutions"; boolean tableExists = true; ResultSet rs = connection.getMetaData().getTables(null, null, tableName, null); if (!rs.next()) { // Table in lowercase does not exist // oracle gives table names in upper case tableName = tableName.toUpperCase(); Logger.trace("Checking " + tableName); rs.close(); rs = connection.getMetaData().getTables(null, null, tableName, null); // Does it exist? if (!rs.next()) { // did not find it in uppercase either tableExists = false; } } // Do we have a if (tableExists) { checkAndUpdateEvolutionsForMultiModuleSupport(connection); ResultSet databaseEvolutions = EvolutionQuery.getEvolutions(connection, moduleKey); while (databaseEvolutions.next()) { Evolution evolution = new Evolution( moduleKey, databaseEvolutions.getInt(1), databaseEvolutions.getString(3), databaseEvolutions.getString(4), false); evolutions.add(evolution); } } else { EvolutionQuery.createTable(); } } catch (SQLException e) { Logger.error(e, "SQL error while checking play evolutions"); } finally { EvolutionQuery.closeConnection(connection); } Collections.sort(evolutions); return evolutions; }
@SuppressWarnings("unchecked") public static void resolve(Http.Request request, Http.Response response) throws NotFound, RenderStatic { if (!Play.started) { return; } Http.Request.current.set(request); Http.Response.current.set(response); Scope.Params.current.set(request.params); Scope.RenderArgs.current.set(new Scope.RenderArgs()); Scope.RouteArgs.current.set(new Scope.RouteArgs()); Scope.Session.current.set(Scope.Session.restore()); Scope.Flash.current.set(Scope.Flash.restore()); CachedBoundActionMethodArgs.init(); ControllersEnhancer.currentAction.set(new Stack<String>()); if (request.resolved) { return; } // Route and resolve format if not already done if (request.action == null) { Play.pluginCollection.routeRequest(request); Route route = Router.route(request); Play.pluginCollection.onRequestRouting(route); } request.resolveFormat(); // Find the action method try { Method actionMethod = null; Object[] ca = getActionMethod(request.action); actionMethod = (Method) ca[1]; request.controller = ((Class) ca[0]).getName().substring(12).replace("$", ""); request.controllerClass = ((Class) ca[0]); request.actionMethod = actionMethod.getName(); request.action = request.controller + "." + request.actionMethod; request.invokedMethod = actionMethod; if (Logger.isTraceEnabled()) { Logger.trace("------- %s", actionMethod); } request.resolved = true; } catch (ActionNotFoundException e) { // Logger.error(e, "%s action not found", e.getAction()); // bran: avoid excessive messages Logger.error("%s action not found", e.getAction()); throw new NotFound(String.format("%s action not found", e.getAction())); } }
@With({UserCredentialWrapFilter.class, ConnectToDBFilter.class}) @BodyParser.Of(BodyParser.Json.class) public static Result updateProfile() { Logger.trace("Method Start"); Http.RequestBody body = request().body(); JsonNode bodyJson = body.asJson(); Logger.trace("updateProfile bodyJson: " + bodyJson); if (bodyJson == null) return badRequest( "The body payload cannot be empty. Hint: put in the request header Content-Type: application/json"); // extract the profile fields JsonNode nonAppUserAttributes = bodyJson.get(UserDao.ATTRIBUTES_VISIBLE_BY_ANONYMOUS_USER); JsonNode privateAttributes = bodyJson.get(UserDao.ATTRIBUTES_VISIBLE_ONLY_BY_THE_USER); JsonNode friendsAttributes = bodyJson.get(UserDao.ATTRIBUTES_VISIBLE_BY_FRIENDS_USER); JsonNode appUsersAttributes = bodyJson.get(UserDao.ATTRIBUTES_VISIBLE_BY_REGISTERED_USER); if (privateAttributes.has("email")) { // check if email address is valid if (!Util.validateEmail((String) privateAttributes.findValuesAsText("email").get(0))) return badRequest("The email address must be valid."); } ODocument profile; try { profile = UserService.updateCurrentProfile( nonAppUserAttributes, privateAttributes, friendsAttributes, appUsersAttributes); } catch (Throwable e) { Logger.warn("updateProfile", e); if (Play.isDev()) return internalServerError(ExceptionUtils.getFullStackTrace(e)); else return internalServerError(e.getMessage()); } Logger.trace("Method End"); return ok(prepareResponseToJson(profile)); } // updateProfile