public static void create(long personID, String content) { try { User user = User.loadFromSession(); Person person = Person.findById(personID); Policy policy = Policy.getInstance( Play.applicationPath.getAbsolutePath() + "/conf/antisamy-myspace-1.3.xml"); AntiSamy as = new AntiSamy(); CleanResults cr = as.scan(content, policy); InsConfidential c = new InsConfidential(); c.content = cr.getCleanHTML(); c.createAt = new GregorianCalendar(); c.employe = user.person; c.person = person; c.save(); flash.success("messageAdded"); InsConfidentials.show(personID); } catch (ScanException ex) { Logger.error(InsConfidentials.class.getName() + " : " + ex); } catch (PolicyException ex) { Logger.error(InsConfidentials.class.getName() + " : " + ex); } }
public static void save(long id, String content) { try { Policy policy = Policy.getInstance( Play.applicationPath.getAbsolutePath() + "/conf/antisamy-myspace-1.3.xml"); AntiSamy as = new AntiSamy(); CleanResults cr = as.scan(content, policy); InsConfidential c = InsConfidential.findById(id); c.content = cr.getCleanHTML(); c.save(); PersonEvaluation.changeMessage(c); renderJSON("{\"result\":\"ok\"}"); } catch (ScanException ex) { Logger.error(InsConfidentials.class.getName() + " : " + ex); renderJSON("{\"result\":\"ko\"}"); } catch (PolicyException ex) { Logger.error(InsConfidentials.class.getName() + " : " + ex); renderJSON("{\"result\":\"ko\"}"); } }