r324 - in trunk/bow-ui/src/main/java/org/chorem/bow: . action action/admin action/bookmark action/login action/opensearch action/preference interceptor
Author: tchemit Date: 2011-08-29 14:21:36 +0200 (Mon, 29 Aug 2011) New Revision: 324 Url: http://chorem.org/repositories/revision/bow/324 Log: fix compilation( must be review since I do it as a blind guy...) fix code minimum style as required for a chorem application... Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java trunk/bow-ui/src/main/java/org/chorem/bow/BowConfig.java trunk/bow-ui/src/main/java/org/chorem/bow/BowConfigOption.java trunk/bow-ui/src/main/java/org/chorem/bow/BowMail.java trunk/bow-ui/src/main/java/org/chorem/bow/BowMigration04To05.java trunk/bow-ui/src/main/java/org/chorem/bow/BowMigration06To11.java trunk/bow-ui/src/main/java/org/chorem/bow/BowProxy.java trunk/bow-ui/src/main/java/org/chorem/bow/BowSearchResult.java trunk/bow-ui/src/main/java/org/chorem/bow/BowSession.java trunk/bow-ui/src/main/java/org/chorem/bow/BowUtils.java trunk/bow-ui/src/main/java/org/chorem/bow/UserMigration.java trunk/bow-ui/src/main/java/org/chorem/bow/action/AliasAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/BowBaseAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/MigrateDataAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/ReIndexationAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/AddOrUpdateAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/DeleteSearchResultsAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/EditAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/RemoveAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/login/ForgotPasswordAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LoginAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LogoutAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/login/RegisterAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchBaseAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchResultAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchSuggestionAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/AdminTagAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/DeleteImportAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ExportBookmarksAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/GenerateTokenAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ImportBookmarksAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/PreferenceBaseAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateSiteAction.java trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateUserAction.java trunk/bow-ui/src/main/java/org/chorem/bow/interceptor/LoginInterceptor.java trunk/bow-ui/src/main/java/org/chorem/bow/interceptor/LogoutInterceptor.java Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/BookmarkUtils.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,31 +23,31 @@ */ package org.chorem.bow; -import java.util.Date; -import java.util.Set; - import org.apache.commons.lang.StringUtils; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.StringUtil; - import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.search.Search; +import java.util.Date; +import java.util.Set; + public class BookmarkUtils { - /** - * Logger. - */ + /** Logger. */ public static Log log = LogFactory.getLog(BookmarkUtils.class); /** * Ajoute a la recherche tout ce qui est necessaire pour connaitre * toutes les informations que l'utilisateur peut voir, meme s'il n'est * pas le createur de ce bookmark + * + * @param search + * @param userId + * @return */ - static public Search addEqUser(Search search, String userId) { + public static Search addEqUser(Search search, String userId) { Search result = search.or(); result = result.eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, userId); result = result.eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_READER, userId); @@ -56,10 +56,13 @@ return search; } - static public Criteria getBookmarkListCriteriaByUser(BowUser user, - String tagLine, String fullTextLine, String order, int first) { + public static Criteria getBookmarkListCriteriaByUser(BowUser user, + String tagLine, + String fullTextLine, + String order, + int first) { Search search = Search.query(); - BookmarkUtils.addEqUser(search, user.getWikittyId()); + addEqUser(search, user.getWikittyId()); if (StringUtils.isNotBlank(fullTextLine)) { search.keyword(fullTextLine); @@ -82,17 +85,17 @@ boolean sortOrderAscending = StringUtils.startsWith(order, "asc"); String sortOrderField = null; - if (StringUtils.equals(order,"ascName")) { + if (StringUtils.equals(order, "ascName")) { sortOrderField = BowBookmark.FQ_FIELD_BOWBOOKMARK_DESCRIPTION; - } else if (StringUtils.equals(order,"ascDate")) { + } else if (StringUtils.equals(order, "ascDate")) { sortOrderField = BowBookmark.FQ_FIELD_BOWBOOKMARK_CREATIONDATE; - } else if (StringUtils.equals(order,"ascClick")) { + } else if (StringUtils.equals(order, "ascClick")) { sortOrderField = BowBookmark.FQ_FIELD_BOWBOOKMARK_CLICK; - } else if (StringUtils.equals(order,"descName")) { + } else if (StringUtils.equals(order, "descName")) { sortOrderField = BowBookmark.FQ_FIELD_BOWBOOKMARK_DESCRIPTION; - } else if (StringUtils.equals(order,"descDate")) { + } else if (StringUtils.equals(order, "descDate")) { sortOrderField = BowBookmark.FQ_FIELD_BOWBOOKMARK_CREATIONDATE; - } else if (StringUtils.equals(order,"descClick")) { + } else if (StringUtils.equals(order, "descClick")) { sortOrderField = BowBookmark.FQ_FIELD_BOWBOOKMARK_CLICK; } if (sortOrderField == null) { @@ -112,10 +115,10 @@ } /** - * @param url String which contains the bookmark url - * @param nameAndTags String which contains the name and the tags of the - * bookmark separated by '|' ==> name|tag1 tag2... - * @param user bookmark user + * @param url String which contains the bookmark url + * @param nameAndTags String which contains the name and the tags of the + * bookmark separated by '|' ==> name|tag1 tag2... + * @param user bookmark user * @return Bookmark the website bookmark, null if all fields are not correctly filled */ public static BowBookmark createBookmark(String url, String nameAndTags, BowUser user) { @@ -142,21 +145,22 @@ /** * Create new Bookmark * - * @param url of bookmark - * @param name of bookmark - * @param tags of bookmark - * @param user creating bookmark + * @param url of bookmark + * @param name of bookmark + * @param tags of bookmark + * @param user creating bookmark * @param privateAlias of bookmark - * @param date of creation + * @param publicAlias + * @param date of creation * @return bookMarl created */ public static BowBookmark createBookmark(String url, String name, String tags, - BowUser user, String privateAlias, String publicAlias, Date date) { + BowUser user, String privateAlias, String publicAlias, Date date) { BowBookmark bookmark = new BowBookmarkImpl(); bookmark.setDescription(BowUtils.normalizeString(name)); - + bookmark.addAllLabels(BowUtils.getWords(tags)); bookmark.setLink(BowUtils.normalizeUrl(url)); @@ -168,12 +172,12 @@ bookmark.setPrivateAlias(BowUtils.normalizeString(privateAlias)); bookmark.setPublicAlias(BowUtils.normalizeString(publicAlias)); - + return bookmark; } public static void updateBookmark(BowBookmark bookmark, String name, - String link, String tags, String privateAlias, String publicAlias) { + String link, String tags, String privateAlias, String publicAlias) { bookmark.setDescription(BowUtils.normalizeString(name)); bookmark.setLink(BowUtils.normalizeUrl(link)); Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowConfig.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/BowConfig.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/BowConfig.java 2011-08-29 12:21:36 UTC (rev 324) @@ -31,17 +31,17 @@ import org.nuiton.wikitty.WikittyConfigOption; /** - * * @author poussin * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ + * <p/> + * Last update: $Date$ + * by : $Author$ */ public class BowConfig { /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(BowConfig.class); + private static final Log log = LogFactory.getLog(BowConfig.class); + /** Singleton instance. */ protected static ApplicationConfig config; @@ -241,7 +241,7 @@ * Return password for specified admin email * * @param config bow configuration - * @param admin emails account + * @param admin emails account * @return null or password if available */ public static String getAdminPassword(ApplicationConfig config, String admin) { @@ -271,6 +271,7 @@ /** * Retourne le prefix par defaut a utiliser si l'utilisateur a mis le * separateur de prefix mais sans prefix + * * @return */ public static String getDefaultPrefix() { @@ -280,6 +281,7 @@ /** * Retourne le prefix par defaut a utiliser si l'utilisateur a mis le * separateur de prefix mais sans prefix + * * @return */ public static String getDefaultPrefix(ApplicationConfig config) { @@ -289,15 +291,17 @@ /** * Indique l'action par defaut a faire, si l'utilisateur n'indique ni * prefix ni separateur de prefix + * * @return */ public static String getDefaultAction() { return getDefaultAction(getConfig()); } - /** + /** * Indique l'action par defaut a faire, si l'utilisateur n'indique ni * prefix ni separateur de prefix + * * @return */ public static String getDefaultAction(ApplicationConfig config) { @@ -306,6 +310,7 @@ /** * le prefix pour indiquer que l'on souhaite une recherche sur les tags + * * @return */ public static String getTagSearchPrefix() { @@ -314,6 +319,7 @@ /** * le prefix pour indiquer que l'on souhaite une recherche sur les tags + * * @return */ public static String getTagSearchPrefix(ApplicationConfig config) { @@ -323,6 +329,7 @@ /** * le prefix pour indiquer que l'on souhaite une recherche sur fulltext * dans bow + * * @return */ public static String getFullTextSearchPrefix() { @@ -332,6 +339,7 @@ /** * le prefix pour indiquer que l'on souhaite une recherche sur fulltext * dans bow + * * @return */ public static String getFullTextSearchPrefix(ApplicationConfig config) { @@ -341,6 +349,7 @@ /** * le prefix pour indiquer que l'on souhaite une recherche sur les alias * prive et une rediection automatique vers cette page + * * @return */ public static String getAliasPrefix() { @@ -350,6 +359,7 @@ /** * le prefix pour indiquer que l'on souhaite une recherche sur les alias * prive et une rediection automatique vers cette page + * * @return */ public static String getAliasPrefix(ApplicationConfig config) { @@ -359,6 +369,7 @@ /** * le prefix pour indiquer que l'on souhaite une recherche sur le web * via le moteur de recherche configurer + * * @return */ public static String getWebSearchPrefix() { @@ -368,6 +379,7 @@ /** * le prefix pour indiquer que l'on souhaite une recherche sur le web * via le moteur de recherche configurer + * * @return */ public static String getWebSearchPrefix(ApplicationConfig config) { Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowConfigOption.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/BowConfigOption.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/BowConfigOption.java 2011-08-29 12:21:36 UTC (rev 324) @@ -27,9 +27,7 @@ import static org.nuiton.i18n.I18n._; -/** - * Bow option definition. - */ +/** Bow option definition. */ public enum BowConfigOption implements ApplicationConfig.OptionDef { CONFIG_FILE( @@ -95,14 +93,19 @@ "a", String.class, false, false); public String key; + public String description; + public String defaultValue; + public Class<?> type; + public boolean isTransient; + public boolean isFinal; BowConfigOption(String key, String description, String defaultValue, - Class<?> type, boolean isTransient, boolean isFinal) { + Class<?> type, boolean isTransient, boolean isFinal) { this.key = key; this.description = description; this.defaultValue = defaultValue; Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowMail.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/BowMail.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/BowMail.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,19 +23,17 @@ */ package org.chorem.bow; -import java.util.Properties; - import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.Transport; -import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; +import java.util.Properties; public class BowMail { - static public void sendMail(String sendToEmail, String mailSubject, String mailContent) throws AddressException, MessagingException { + public static void sendMail(String sendToEmail, String mailSubject, String mailContent) throws MessagingException { String smtpServer = BowConfig.getSmtpServer(); Properties properties = new Properties(); properties.put("mail.smtp.host", smtpServer); Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowMigration04To05.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/BowMigration04To05.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/BowMigration04To05.java 2011-08-29 12:21:36 UTC (rev 324) @@ -24,23 +24,24 @@ package org.chorem.bow; -import java.util.ArrayList; -import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.wikitty.WikittyProxy; import org.nuiton.wikitty.entities.Wikitty; import org.nuiton.wikitty.search.PagedResult; +import java.util.ArrayList; +import java.util.List; + /** * Migre les données depuis la version 0.4 vers la version 0.5. * On suppose que les données sont convenablement indexee. - * + * <p/> * <li> renomage de User -> BowUser (qui hérite de WikittyUser) * <li> renomage de Preference -> BowPreference * <li> renomage de Bookmark -> BowBookmark * <li> renomage de Import -> BowImport - * + * <p/> * <li> deplacement de User.email -> BowUser(WikittyUser).login * <li> deplacement de User.password -> BowUser(WikittyUser).password * <li> deplacement de Token.token -> BowUser.permanentToken @@ -48,37 +49,37 @@ * <li> deplacement de Bookmark.alias -> BowBookmark.privateAlias * <li> deplacement de Bookmark.tags -> BowBookmark(WikittyLabel).labels * <li> deplacement de Import.date -> BowImport(BowBookmark).importDate - * + * <p/> * <li> suppression de Token - * + * <p/> * <li> remplacement de Bookmark.email -> lien vers BowUser - * + * <p/> * <li> ajout sur BowBookmark d'un lien vers BowImport * <li> ajout sur BowImport d'un lien vers BowUser - * + * <p/> * Le nouvel objet BowAlias a ete ajoute, rien est a faire avec pour la * migration. * * @author poussin * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ + * <p/> + * Last update: $Date$ + * by : $Author$ */ public class BowMigration04To05 { /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(BowMigration04To05.class); + private static final Log log = LogFactory.getLog(BowMigration04To05.class); /** nombre d'objet a charger en 1 fois */ - final static public int MAX = 100; + public static final int MAX = 100; /** * Point d'entree de la migration * * @param proxy */ - static public void migrate(WikittyProxy proxy) { + public static void migrate(WikittyProxy proxy) { UserImpl userExample = new UserImpl(); int i = 0; PagedResult<UserImpl> pagedUser; @@ -91,7 +92,7 @@ } while (pagedUser.size() >= MAX); } - static public List<BowUser> migrateUser(WikittyProxy proxy, List<UserImpl> users) { + public static List<BowUser> migrateUser(WikittyProxy proxy, List<UserImpl> users) { List<BowUser> result = new ArrayList<BowUser>(users.size()); for (UserImpl user : users) { BowUser bowUser = new BowUserImpl(); @@ -121,7 +122,7 @@ int i = 0; PagedResult<BookmarkImpl> pagedBookmark; do { - pagedBookmark = proxy.findAllByExample(bookmarkExample, i, i+=MAX); + pagedBookmark = proxy.findAllByExample(bookmarkExample, i, i += MAX); List<BookmarkImpl> bookmarks = pagedBookmark.getAll(); List<BowBookmark> bowbookmarks = migrateBookmark(proxy, bowUser, bookmarks); @@ -132,8 +133,8 @@ return result; } - static public List<BowBookmark> migrateBookmark(WikittyProxy proxy, BowUser user, - List<BookmarkImpl> bookmarks) { + public static List<BowBookmark> migrateBookmark(WikittyProxy proxy, BowUser user, + List<BookmarkImpl> bookmarks) { List<BowBookmark> result = new ArrayList<BowBookmark>(bookmarks.size()); for (BookmarkImpl bookmark : bookmarks) { BowBookmark bowBookmark = new BowBookmarkImpl(); @@ -159,5 +160,5 @@ } return result; } - + } Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowMigration06To11.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/BowMigration06To11.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/BowMigration06To11.java 2011-08-29 12:21:36 UTC (rev 324) @@ -24,7 +24,6 @@ package org.chorem.bow; -import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.wikitty.WikittyProxy; @@ -39,47 +38,45 @@ import org.nuiton.wikitty.services.WikittyExtensionMigration; import org.nuiton.wikitty.services.WikittyExtensionMigrationRename; +import java.util.List; + /** * Migre les données depuis la version 0.6 vers la version 1.1. * On suppose que les données sont convenablement indexee. - * + * <p/> * <li> ajout du champs BowBookmark.authentificationInfo (rien a faire pour la migration) * <li> suppression de BowBookmark.bowUser * <li> BowBookmark depend de WikittyAuthorisation - * + * <p/> * la valeur de BowBookmark.bowUser est maintenant stockee dans * WikittyAuthorisation.owner et WikittyAuthorisation.reader * pour que par defaut seul le owner est les droits de lecture sur l'item * * @author poussin * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ + * <p/> + * Last update: $Date$ + * by : $Author$ */ public class BowMigration06To11 extends WikittyExtensionMigrationRename { /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(BowMigration06To11.class); + private static final Log log = LogFactory.getLog(BowMigration06To11.class); /** nombre d'objet a charger en 1 fois */ - final static public int MAX = 1000; + public static final int MAX = 1000; - /** - * Point d'entree de la migration - * - * @param proxy - */ + /** Point d'entree de la migration. */ @Override public Wikitty migrate(WikittyService service, Wikitty wikitty, - WikittyExtension oldExt, WikittyExtension newExt) { + WikittyExtension oldExt, WikittyExtension newExt) { // on laisse l'implantation par defaut migrer tout ce qu'il faut // nouvelle dependance, ... Wikitty result = super.migrate(service, wikitty, oldExt, newExt); // On met juste a jour les données avec le champs supprimer bowUser String bookId = wikitty.getId(); - String userId = (String)wikitty.getFqField( + String userId = (String) wikitty.getFqField( BowBookmark.EXT_BOWBOOKMARK + WikittyUtil.FQ_FIELD_NAME_SEPARATOR + "bowUser"); if (userId == null) { @@ -92,7 +89,7 @@ return result; } - static public void migrate(WikittyProxy proxy) { + public static void migrate(WikittyProxy proxy) { log.info("Migration 0.5 to 0.6 started"); // on enregistre la classe qui fera la migration des données WikittyExtensionMigration.migrationRegistry.put( @@ -118,7 +115,7 @@ // only here to simplify test and debug of migration, this permit to migrate // datas in developpement environnement directly without launch bow web app - public static void main(String ... args) { + public static void main(String... args) { BowProxy proxy = BowProxy.getInstance(null); migrate(proxy); } Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowProxy.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/BowProxy.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/BowProxy.java 2011-08-29 12:21:36 UTC (rev 324) @@ -37,13 +37,13 @@ * * @author poussin * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ + * <p/> + * Last update: $Date$ + * by : $Author$ */ public class BowProxy extends WikittyProxy { - static protected WikittyService ws = null; + static protected WikittyService ws; protected BowProxy(ApplicationConfig config, WikittyService ws) { super(config, ws); @@ -55,12 +55,12 @@ * @param token * @return */ - static public BowProxy getInstance(String token) { + public static BowProxy getInstance(String token) { ApplicationConfig config = BowConfig.getConfig(); WikittyService ws = getWikittyService(config); BowProxy result = new BowProxy(config, ws); result.setSecurityToken(token); - + return result; } @@ -72,8 +72,8 @@ */ static protected WikittyService getWikittyService(ApplicationConfig config) { if (ws == null) { - synchronized(BowProxy.class) { - if (ws == null) { + synchronized (BowProxy.class) { + if (ws == null) { List<WikittyExtension> extensions = new ArrayList<WikittyExtension>(); extensions.addAll(BowPreferenceImpl.extensions); // inherit BowUSer, WikittyUser extensions.addAll(BowImportImpl.extensions); // inherit BowBookmark, WikittyLabel @@ -85,5 +85,5 @@ } return ws; } - + } Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowSearchResult.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/BowSearchResult.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/BowSearchResult.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,20 +23,17 @@ */ package org.chorem.bow; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; import org.apache.commons.collections.CollectionUtils; - -import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.search.FacetTopic; import org.nuiton.wikitty.search.PagedResult; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + /** * Cette classe permet de stocker le resutlat d'une recherche * - la liste des tags qui ont servi pour la recherche @@ -46,19 +43,23 @@ * * @author poussin * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ + * <p/> + * Last update: $Date$ + * by : $Author$ */ public class BowSearchResult { private static final Log log = LogFactory.getLog(BowSearchResult.class); /** nombre total de bookmark trouve */ - protected int bookmarkCount = 0; + protected int bookmarkCount; + protected List<BowBookmark> bookmarks; + protected List<FacetTopic> tagsCloud; + protected int tmax = -1; + protected int tmin = -1; /** @@ -66,7 +67,8 @@ * la recherche * * @param session la session de l'utilisateur sur lequel on peut recuperer - * le proxy et les preferences + * le proxy et les preferences + * @param result * @param tagLine (optionel) le liste des tags a rechercher */ public BowSearchResult(PagedResult<BowBookmark> result, String tagLine) { @@ -74,7 +76,7 @@ bookmarkCount = result.getNumFound(); if (log.isDebugEnabled()) { log.debug(String.format("Find %s items, used %s", - bookmarkCount, result.size())); + bookmarkCount, result.size())); } setBookmarks(result.getAll()); @@ -82,7 +84,7 @@ List<FacetTopic> topics = result.getTopic(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS); if (log.isDebugEnabled()) { log.debug(String.format("There are %s tag in cloud", - CollectionUtils.isEmpty(topics)?0:topics.size())); + CollectionUtils.isEmpty(topics) ? 0 : topics.size())); } setTagCloud(topics, tagLine); } @@ -97,7 +99,7 @@ // on recupere les tags dans un set pour optimiser la recherche Set<String> tagsSearch = BowUtils.getWords(excludeTag); - for(Iterator<FacetTopic> i=tagsCloud.iterator(); i.hasNext();) { + for (Iterator<FacetTopic> i = tagsCloud.iterator(); i.hasNext(); ) { FacetTopic topic = i.next(); String name = topic.getTopicName(); if (tagsSearch.contains(name)) { @@ -119,7 +121,7 @@ tmin = value; } } - + } } Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowSession.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/BowSession.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/BowSession.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,52 +23,59 @@ */ package org.chorem.bow; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.io.Serializable; +import java.util.Map; + /** * Classe utilisee pour stocker les objets utils en session utilisateur * * @author poussin * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ + * <p/> + * Last update: $Date$ + * by : $Author$ */ -public class BowSession { +public class BowSession implements Serializable { /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(BowSession.class); + private static final Log log = LogFactory.getLog(BowSession.class); static final private String BOW_SESSION_KEY = BowSession.class.getSimpleName(); + private static final long serialVersionUID = 1L; + protected BowProxy proxy; + // user herite de preference, on ne stocke que user - protected BowUser user = null; - protected String temporaryToken = null; - protected boolean admin = false; + protected BowUser user; + protected String temporaryToken; + + protected boolean admin; + public BowSession() { proxy = BowProxy.getInstance(null); } - static public void invalidate(Map<String, Object> session) { + public static void invalidate(Map<String, Object> session) { session.remove(BOW_SESSION_KEY); } - static public BowSession getBowSession(HttpServletRequest request) { + public static BowSession getBowSession(HttpServletRequest request) { HttpSession session = request.getSession(); BowSession result = getBowSession(session); return result; } - static public BowSession getBowSession(HttpSession httpSession) { + public static BowSession getBowSession(HttpSession httpSession) { BowSession result = (BowSession) httpSession.getAttribute(BOW_SESSION_KEY); if (result == null) { result = new BowSession(); @@ -77,8 +84,8 @@ return result; } - static public BowSession getBowSession(Map<String, Object> session) { - BowSession result = (BowSession)session.get(BOW_SESSION_KEY); + public static BowSession getBowSession(Map<String, Object> session) { + BowSession result = (BowSession) session.get(BOW_SESSION_KEY); if (result == null) { result = new BowSession(); session.put(BOW_SESSION_KEY, result); @@ -101,9 +108,7 @@ boolean isAdmin = ArrayUtils.contains(admins, login); setAdmin(isAdmin); - if (user != null) { - checkPreference(user); - } + checkPreference(user); // si c'est le meme user, on ne regenere pas le temporaryToken if (!ObjectUtils.equals(this.user, user)) { @@ -114,7 +119,7 @@ this.user = user; } - protected void checkPreference(BowPreference preference) { + protected void checkPreference(BowPreference preference) { if (preference.getBookmarks() <= 0) { preference.setBookmarks(100); // set default to 100 } @@ -152,7 +157,7 @@ preference.setDefaultAction(BowConfig.getDefaultAction()); } } - + public String getPermanentToken() { return getUser().getPermanentToken(); } Modified: trunk/bow-ui/src/main/java/org/chorem/bow/BowUtils.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/BowUtils.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/BowUtils.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,28 +23,24 @@ */ package org.chorem.bow; -import java.util.Arrays; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - +import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.time.DateFormatUtils; import org.nuiton.util.StringUtil; import org.nuiton.wikitty.WikittyProxy; import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.search.Search; +import java.util.Arrays; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; import java.util.UUID; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.time.DateFormatUtils; -import org.nuiton.util.DateUtil; public class BowUtils { - final static public String BOW_DATE_SHORT_PATTERN = "yyyy/MM/dd"; - + public static final String BOW_DATE_SHORT_PATTERN = "yyyy/MM/dd"; + private BowUtils() { } @@ -55,7 +51,7 @@ * @param date null or valide date * @return date if date not null, or today date */ - static public Date normalizeDate(Date date) { + public static Date normalizeDate(Date date) { Date result = date; if (result == null) { result = new Date(); @@ -66,11 +62,11 @@ /** * Supprime les blancs de debut et de fin, et retourne une chaine vide si s * est null - * + * * @param s null or string * @return empty string or string without blank at begin and end */ - static public String normalizeString(String s) { + public static String normalizeString(String s) { String result = StringUtils.defaultIfBlank(s, ""); result = result.trim(); return result; @@ -88,7 +84,7 @@ String result = ""; if (StringUtils.isNotBlank(url)) { result = url.trim(); - if (! result.matches("[a-z]+://.+") ) { + if (!result.matches("[a-z]+://.+")) { result = "http://" + result; } } @@ -98,16 +94,16 @@ /** * Donne la liste des mots de la chaine passee en parametre. * Si tags est null ou vide, le 'set' retourne sera vide. - * + * <p/> * La liste retournee ne doit jamais contenir de chaine null ou vide. * * @param tags * @return */ - static public Set<String> getWords(String tags) { - String [] words = StringUtils.split(tags); + public static Set<String> getWords(String tags) { + String[] words = StringUtils.split(tags); words = ArrayUtils.nullToEmpty(words); - + Set<String> result = new HashSet<String>(Arrays.asList(words)); // on s'assure que la liste ne retourne jamais de chaine null ou vide. @@ -117,16 +113,17 @@ return result; } - static public String formatDate(Date date) { + public static String formatDate(Date date) { String result = DateFormatUtils.format(date, BOW_DATE_SHORT_PATTERN); return result; } + /** * Generates a random token - * + * * @return the generated token */ - static public String generateToken() { + public static String generateToken() { UUID uuid = UUID.randomUUID(); String tokenGenerated = uuid.toString(); tokenGenerated = StringUtil.encodeMD5(tokenGenerated); // encode the token in MD5 @@ -135,12 +132,12 @@ /** * Redirects the user either on the home page or on the search page - * - * @param tagLine search line + * + * @param tagLine search line * @param fullTextLine full text search * @return the page where the user will be redirected */ - static public String redirectTo(String tagLine, String fullTextLine) { + public static String redirectTo(String tagLine, String fullTextLine) { String result = "home.action"; boolean tagLineNotBlank = StringUtils.isNotBlank(tagLine); boolean fullTextLineNotBlank = StringUtils.isNotBlank(fullTextLine); @@ -154,20 +151,20 @@ result += "&"; } if (fullTextLineNotBlank) { - result += "fullTextLine=" + fullTextLine; + result += "fullTextLine=" + fullTextLine; } } return result; } - + /** * Retrieves the user by the temporary or the permanent token - * + * * @param session the session - * @param token either the temporary or the permanent token + * @param token either the temporary or the permanent token * @return the user if the token is valid, null if the token doesn't exist */ - static public BowUser checkToken(BowSession session, String token) { + public static BowUser checkToken(BowSession session, String token) { BowUser result = null; if (checkTemporaryToken(session, token) || checkPermanentToken(session, token)) { result = session.getUser(); @@ -179,7 +176,7 @@ * check if token exist, if true, put User associated with it, in BowSession * * @param session bow session - * @param token which contains the MD5 encoding token + * @param token which contains the MD5 encoding token * @return User the token owner, null if the token doesn't exist */ protected static boolean checkPermanentToken(BowSession session, String token) { @@ -201,7 +198,7 @@ * Check token with temporary token * * @param session bow session - * @param token which contains the MD5 encoding token + * @param token which contains the MD5 encoding token * @return user the token owner, null if the token doesn't exist */ protected static boolean checkTemporaryToken(BowSession session, String token) { Modified: trunk/bow-ui/src/main/java/org/chorem/bow/UserMigration.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/UserMigration.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/UserMigration.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,21 +23,19 @@ */ package org.chorem.bow; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; import org.nuiton.util.StringUtil; -import org.nuiton.wikitty.entities.Wikitty; import org.nuiton.wikitty.WikittyException; -import org.nuiton.wikitty.entities.WikittyExtension; -import org.nuiton.wikitty.services.WikittyExtensionMigration; import org.nuiton.wikitty.WikittyService; +import org.nuiton.wikitty.entities.Wikitty; +import org.nuiton.wikitty.entities.WikittyExtension; import org.nuiton.wikitty.entities.WikittyImpl; +import org.nuiton.wikitty.services.WikittyExtensionMigration; -/** - * - * @author sherkhan - */ +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** @author sherkhan */ public class UserMigration implements WikittyExtensionMigration { @Override Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/AliasAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/AliasAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/AliasAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -36,18 +36,21 @@ * * @author poussin * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ + * <p/> + * Last update: $Date$ + * by : $Author$ */ public class AliasAction extends BowBaseAction { /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(AliasAction.class); + private static final Log log = LogFactory.getLog(AliasAction.class); + private static final long serialVersionUID = 1L; protected String redirectTo = "/"; + protected String alias; + protected String bookmarkId; public String getRedirectTo() { @@ -71,10 +74,10 @@ try { if (StringUtils.isNotEmpty(alias)) { WikittyProxy proxy = getBowProxy(); - + Criteria criteria = Search.query().eq( BowBookmark.FQ_FIELD_BOWBOOKMARK_PUBLICALIAS, alias).criteria(); - + BowBookmark bookmark = proxy.findByCriteria(BowBookmark.class, criteria); if (bookmark == null) { bookmark = proxy.restore(BowBookmark.class, alias); @@ -112,7 +115,7 @@ addActionError(_("bow.alias.already.exists", alias)); log.error("A bookmark already exists with alias " + alias); result = ERROR; - + } else { bookmark = proxy.restore(BowBookmark.class, bookmarkId); if (bookmark != null) { Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/BowBaseAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/BowBaseAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/BowBaseAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,20 +23,21 @@ */ package org.chorem.bow.action; -import java.util.Arrays; -import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.util.Map; import org.apache.struts2.interceptor.SessionAware; import org.chorem.bow.BowConfig; import org.chorem.bow.BowProxy; import org.chorem.bow.BowSession; import org.nuiton.web.struts2.BaseAction; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + /** * Base class which must be extended by every action - * Overrides the Struts2 methods to render text in order to explicitly show + * Overrides the Struts2 methods to render text in order to explicitly show * the missing i18n translations * Allows access to the session and the proxy */ @@ -59,29 +60,26 @@ return possibleOrder; } - protected Map<String, Object> session; - /** - * Configuration, default null for lazy loading - */ - protected BowConfig config = null; - /** - * Les tags a recherche separer par un espace - */ + protected transient Map<String, Object> session; + + /** Configuration, default null for lazy loading */ + protected transient BowConfig config; + + /** Les tags a recherche separer par un espace */ protected String tagLine; - /** - * La ligne de recherche fulltext - */ + + /** La ligne de recherche fulltext */ protected String fullTextLine; - /** - * l'ordre d'affichage des resultats - */ + + /** l'ordre d'affichage des resultats */ protected String order; + /** * indice du 1er element a recuperer, on en recupere le nombre defini * dans les preferences utilisateur. Par defaut on prend a partir du 1er * donc l'indice 0. */ - protected int first = 0; + protected int first; public BowConfig getConfig() { if (config == null) { @@ -105,30 +103,22 @@ this.session = session; } - /** - * @return the tagLine - */ + /** @return the tagLine */ public String getTagLine() { return tagLine; } - /** - * @param tagLine the tagLine to set - */ + /** @param tagLine the tagLine to set */ public void setTagLine(String tagLine) { this.tagLine = tagLine; } - /** - * @return the fullTextLine - */ + /** @return the fullTextLine */ public String getFullTextLine() { return fullTextLine; } - /** - * @param fullTextLine the fullTextLine to set - */ + /** @param fullTextLine the fullTextLine to set */ public void setFullTextLine(String fullTextLine) { this.fullTextLine = fullTextLine; } @@ -148,5 +138,5 @@ public void setFirst(int first) { this.first = first; } - + } \ No newline at end of file Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/MigrateDataAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/MigrateDataAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/MigrateDataAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -39,17 +39,18 @@ * * @author poussin * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ + * <p/> + * Last update: $Date$ + * by : $Author$ */ public class MigrateDataAction extends BowBaseAction { /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(MigrateDataAction.class); + private static final Log log = LogFactory.getLog(MigrateDataAction.class); /** Version must be real version, like 0.4, 0.5 or 0.6 */ protected String versionFrom; + protected String versionTo; public void setVersionFrom(String versionFrom) { @@ -71,11 +72,11 @@ WikittyProxy proxy = getBowProxy(); if (VersionUtil.equals(versionFrom, "0.4") - && VersionUtil.equals(versionTo, "0.5")) { + && VersionUtil.equals(versionTo, "0.5")) { BowMigration04To05.migrate(proxy); addActionMessage(_("bow.admin.dataMigration.success")); } else if (VersionUtil.equals(versionFrom, "0.6") - && VersionUtil.equals(versionTo, "1.1")) { + && VersionUtil.equals(versionTo, "1.1")) { BowMigration06To11.migrate(proxy); addActionMessage(_("bow.admin.dataMigration.success")); } else { Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/ReIndexationAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/ReIndexationAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/admin/ReIndexationAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -29,7 +29,7 @@ /** * Lance la reindexation solr - * + * * @author poussin */ public class ReIndexationAction extends BowBaseAction { Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/AddOrUpdateAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/AddOrUpdateAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/AddOrUpdateAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -37,70 +37,65 @@ /** * Ajoute ou modifie un bookmark, soit par le formulaire, * soit par un appel javascript - * + * * @author poussin */ public class AddOrUpdateAction extends BowBaseAction { private static final long serialVersionUID = 3389170166034184139L; - + protected String bookmarkId; + protected String link; + protected String name; + protected String privateAlias; + protected String publicAlias; + protected String tags; + protected String nameAndTags; + protected String redirectTo; public String getBookmarkId() { return bookmarkId; } - + public void setBookmarkId(String bookmarkId) { this.bookmarkId = bookmarkId; } - - /** - * @return the link - */ + + /** @return the link */ public String getLink() { return link; } - /** - * @param link the link to set - */ + /** @param link the link to set */ public void setLink(String link) { this.link = link; } - /** - * @return the description - */ + /** @return the description */ public String getName() { return name; } - /** - * @param name the description to set - */ + /** @param name the description to set */ public void setName(String name) { this.name = name; } - /** - * @return the privateAlias - */ + /** @return the privateAlias */ public String getPrivateAlias() { return privateAlias; } - /** - * @param alias the privateAlias to set - */ - public void setPrivateAlias(String alias) { - this.privateAlias = alias; + /** @param privateAlias the privateAlias to set */ + public void setPrivateAlias(String privateAlias) { + this.privateAlias = privateAlias; } public String getPublicAlias() { @@ -111,37 +106,27 @@ this.publicAlias = publicAlias; } - /** - * @return the tags - */ + /** @return the tags */ public String getTags() { return tags; } - /** - * @param tags the tags to set - */ + /** @param tags the tags to set */ public void setTags(String tags) { this.tags = tags; } - /** - * @return the nameAndTags - */ + /** @return the nameAndTags */ public String getNameAndTags() { return nameAndTags; } - /** - * @param nameAndTags the nameAndTags to set - */ + /** @param nameAndTags the nameAndTags to set */ public void setNameAndTags(String nameAndTags) { this.nameAndTags = nameAndTags; } - /** - * @return the redirectTo - */ + /** @return the redirectTo */ public String getRedirectTo() { return redirectTo; } @@ -162,7 +147,7 @@ if (log.isDebugEnabled()) { log.debug("Change old wikitty: " + bookmarkToModify); } - + // gere le cas d'une mise a jour ou d'un ajout via le formulaire if (name != null) { // Si l'alias prive souhaite est deja utilise on ne l'accept pas @@ -180,10 +165,10 @@ publicAliasCriteria = Search.query() .eq(BowBookmark.FQ_FIELD_BOWBOOKMARK_PUBLICALIAS, publicAlias) .criteria().setEndIndex(0); - } + } PagedResult<String>[] aliasResult = proxy.findAllIdByCriteria( privateAliasCriteria, publicAliasCriteria); - + if (aliasResult[0] != null && aliasResult[0].getNumFound() > 0) { if (bookmarkToModify == null) { privateAlias = ""; @@ -198,7 +183,7 @@ publicAlias = bookmarkToModify.getPublicAlias(); } } - + if (bookmarkToModify == null) { bookmark = BookmarkUtils.createBookmark( link, name, tags, user, privateAlias, publicAlias, null); @@ -214,8 +199,8 @@ // si on a reussi a creer le bookmark, on regarde s'il ne faut pas // le fusionner avec un deja existant if (bookmark != null && !bookmark.getDescription().isEmpty() - && !bookmark.getOwner().isEmpty()) { - + && !bookmark.getOwner().isEmpty()) { + // looking for already bookmark with same url, to fusion them String link = bookmark.getLink(); Criteria criteria = Search.query() @@ -224,7 +209,7 @@ .criteria(); BowBookmark oldBookmark = proxy.findByCriteria(BowBookmark.class, criteria); - if(oldBookmark != null) { + if (oldBookmark != null) { // fusionne les descriptions et les tags // par contre on prend le dernier privateAlias prive choisi par // l'utilisateur s'il y en a un @@ -235,17 +220,17 @@ bookmark.getCreationDate()) + ": "; description += bookmark.getDescription(); } - + oldBookmark.setDescription(description); oldBookmark.addAllLabels(bookmark.getLabels()); String privateAlias = bookmark.getPrivateAlias(); if (!StringUtils.isEmpty(privateAlias)) { oldBookmark.setPrivateAlias(privateAlias); } - + bookmark = oldBookmark; } - + } if (bookmark != null || bookmarkToModify != null) { Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/DeleteSearchResultsAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/DeleteSearchResultsAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/DeleteSearchResultsAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,38 +23,37 @@ */ package org.chorem.bow.action.bookmark; -import java.util.List; import org.apache.commons.lang.StringUtils; - import org.chorem.bow.BookmarkUtils; import org.chorem.bow.BowUser; import org.chorem.bow.action.BowBaseAction; -import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.search.Criteria; +import java.util.List; + /** * Supprime des bookmarks qui satisfont le critere de recherche. * * @author poussin */ public class DeleteSearchResultsAction extends BowBaseAction { - + private static final long serialVersionUID = -3903724044644625507L; - /** - * Deletes the search results - */ + /** Deletes the search results */ public String execute() { try { if (StringUtils.isNotBlank(tagLine) - || StringUtils.isNotBlank(fullTextLine)) { + || StringUtils.isNotBlank(fullTextLine)) { BowUser user = getBowSession().getUser(); // FIXME poussin 20110817 ATTENTION, la recherche remonte // potentiellement des bookmarks qui ne nous appartiennent pas, // dans ce cas, ne faudrait-il pas seulement ce supprimer des // reader/write/admin ? + // FIXME tchemit 20110829 J'ai mis en dernier paramètre 0 car ça ne compilait pô mais je sais pas si c'est le bon!... Criteria criteria = BookmarkUtils.getBookmarkListCriteriaByUser( - user, tagLine, fullTextLine, null); + user, tagLine, fullTextLine, null, 0); WikittyProxy proxy = getBowProxy(); List<String> ids = proxy.findAllIdByCriteria(criteria).getAll(); Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/EditAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/EditAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/EditAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -40,6 +40,7 @@ private static final long serialVersionUID = 1L; protected String id; + protected BowBookmark bookmark; public String getId() { Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/HomeAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -30,7 +30,6 @@ import org.chorem.bow.BookmarkUtils; import org.chorem.bow.BowBookmark; import org.chorem.bow.BowProxy; - import org.chorem.bow.BowSearchResult; import org.chorem.bow.BowSession; import org.chorem.bow.BowUser; @@ -41,17 +40,18 @@ /** * Prepare l'affichage de la page d'accueil - * + * * @author poussin */ public class HomeAction extends BowBaseAction { private static final Log log = LogFactory.getLog(HomeAction.class); + private static final TimeLog timeLog = new TimeLog(HomeAction.class); private static final long serialVersionUID = -3735250067223062719L; - static public HomeAction getAction() { + public static HomeAction getAction() { Object action = ActionContext.getContext().get(CONTEXT_ACTION_KEY); return (HomeAction) action; } @@ -76,9 +76,7 @@ this.searchResult = searchResult; } - /** - * Load all data necessary form Home page - */ + /** Load all data necessary form Home page */ protected void load() { // on ajoute les tags qui doivent faire parti de ne nouvelle recherche // on restocke dans tagLine pour que la bonne info reapparaisse @@ -105,9 +103,7 @@ searchResult = new BowSearchResult(result, tagLine); } - /** - * Initializes everything before displaying the home page - */ + /** Initializes everything before displaying the home page */ @Override public String execute() { long start = TimeLog.getTime(); Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/RemoveAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/RemoveAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/bookmark/RemoveAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -38,32 +38,25 @@ private static final long serialVersionUID = 820566716695285561L; protected String bookmarkId; + protected String redirectTo; - /** - * @return the bookmarkId - */ + /** @return the bookmarkId */ public String getBookmarkId() { return bookmarkId; } - /** - * @param bookmarkId the bookmarkId to set - */ + /** @param bookmarkId the bookmarkId to set */ public void setBookmarkId(String bookmarkId) { this.bookmarkId = bookmarkId; } - /** - * @return the redirectTo - */ + /** @return the redirectTo */ public String getRedirectTo() { return redirectTo; } - /** - * Removes a bookmark - */ + /** Removes a bookmark */ @Override public String execute() { if (StringUtils.isNotEmpty(bookmarkId)) { Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/login/ForgotPasswordAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/login/ForgotPasswordAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/login/ForgotPasswordAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,19 +23,19 @@ */ package org.chorem.bow.action.login; -import javax.mail.MessagingException; -import javax.mail.internet.AddressException; - import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.StringUtils; import org.chorem.bow.BowMail; import org.chorem.bow.BowUser; import org.chorem.bow.action.BowBaseAction; import org.nuiton.util.StringUtil; -import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.search.Search; +import javax.mail.MessagingException; +import javax.mail.internet.AddressException; + /** * Genere un nouveau mot de passe pour l'utilisateur et lui envoie par mail * TODO poussin 20110211 il faudrait ajouter une securite pour eviter que @@ -48,25 +48,20 @@ */ public class ForgotPasswordAction extends BowBaseAction { private static final long serialVersionUID = -8207951465957204954L; + protected String email; - /** - * @return the email - */ + /** @return the email */ public String getEmail() { return email; } - /** - * @param email the email to set - */ + /** @param email the email to set */ public void setEmail(String email) { this.email = email; } - - /** - * Generates a new password and sends it to the user - */ + + /** Generates a new password and sends it to the user */ @Override public String execute() { String result = INPUT; @@ -80,8 +75,8 @@ BowUser user = proxy.findByCriteria(BowUser.class, criteria); if (user != null) { //If the email address exists - String password = ""; - String md5 = ""; + String password; + String md5; password = RandomStringUtils.randomAlphanumeric(20); md5 = StringUtil.encodeMD5(password); @@ -89,12 +84,12 @@ String mailContent; mailContent = _("bow.register.mailHi") + - ",\n\n" + _("bow.register.mailPwd") + ": " + - password + "\n\n" + _("bow.register.mailEmail") + - ": " + email + "\n\n"; + ",\n\n" + _("bow.register.mailPwd") + ": " + + password + "\n\n" + _("bow.register.mailEmail") + + ": " + email + "\n\n"; BowMail.sendMail(email, - _("bow.register.mailSubject"), - mailContent); + _("bow.register.mailSubject"), + mailContent); //The password is changed only if the mail has been sent user.setPassword(md5); @@ -103,16 +98,16 @@ //If the email address is invalid addActionError(_("bow.mail.badFormat")); log.error(String.format("Can't send message email to '%s'", - email), eee); + email), eee); } catch (MessagingException eee) { addActionError("bow.mail.sendError"); log.error(String.format("Can't send message email to '%s'", - email), eee); + email), eee); } result = SUCCESS; } else { //If the email is not associated with an account addFieldError("email", - _("bow.forgotPassword.emailDoesntExist")); + _("bow.forgotPassword.emailDoesntExist")); } } } catch (Exception eee) { Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LoginAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LoginAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LoginAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -25,14 +25,13 @@ package org.chorem.bow.action.login; import org.apache.commons.lang.StringUtils; - import org.chorem.bow.BowConfig; import org.chorem.bow.BowUser; import org.chorem.bow.BowUserImpl; import org.chorem.bow.action.BowBaseAction; import org.nuiton.util.StringUtil; -import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.search.Search; /** @@ -45,6 +44,7 @@ private static final long serialVersionUID = 6891064800288772246L; protected String email; + protected String password; public String getEmail() { @@ -65,13 +65,13 @@ /** * Check password in solr index, if fail try to check password admin in config file - * - * @param email non null et non vide email + * + * @param email non null et non vide email * @param password non null et non vide email * @return */ protected BowUser checkLogin(String email, String password) { - BowUser result = null; + BowUser result; WikittyProxy proxy = getBowProxy(); Criteria criteria = Search.query().eq(BowUser.FQ_FIELD_WIKITTYUSER_LOGIN, email). @@ -82,7 +82,7 @@ // failback: try to authenticate admin with config info String configPassword = BowConfig.getAdminPassword(email); log.info(String.format("failback password: '%s' configPassword: '%s'", - password, configPassword)); + password, configPassword)); if (password.equals(configPassword)) { // admin authenticate with config, this is possible when // solr index is corrupted or missed. Admin must go to admin @@ -99,9 +99,7 @@ return result; } - /** - * Authenticates the user if his email and password are valid - */ + /** Authenticates the user if his email and password are valid */ @Override public String execute() { String result = INPUT; Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LogoutAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LogoutAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/login/LogoutAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -28,7 +28,7 @@ /** * Invalide la session courante et donc de-authentifie l'utilisateur - * + * * @author poussin */ public class LogoutAction extends BowBaseAction { Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/login/RegisterAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/login/RegisterAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/login/RegisterAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,20 +23,20 @@ */ package org.chorem.bow.action.login; -import javax.mail.MessagingException; -import javax.mail.internet.AddressException; import org.apache.commons.lang.StringUtils; - import org.chorem.bow.BowMail; import org.chorem.bow.BowUser; import org.chorem.bow.BowUserImpl; import org.chorem.bow.BowUtils; import org.chorem.bow.action.BowBaseAction; import org.nuiton.util.StringUtil; -import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.search.Search; +import javax.mail.MessagingException; +import javax.mail.internet.AddressException; + /** * Enregistre un nouvel utilisateur * @@ -47,62 +47,51 @@ private static final long serialVersionUID = 2204772861770399542L; protected String email; + protected String password; + protected String repeatPassword; - - /** - * @return the email - */ + + /** @return the email */ public String getEmail() { return email; } - /** - * @param email the email to set - */ + /** @param email the email to set */ public void setEmail(String email) { this.email = email; } - /** - * @return the password - */ + /** @return the password */ public String getPassword() { return password; } - /** - * @param password the password to set - */ + /** @param password the password to set */ public void setPassword(String password) { this.password = password; } - /** - * @return the repeatPassword - */ + /** @return the repeatPassword */ public String getRepeatPassword() { return repeatPassword; } - /** - * @param repeatPassword the repeatPassword to set - */ + /** @param repeatPassword the repeatPassword to set */ public void setRepeatPassword(String repeatPassword) { this.repeatPassword = repeatPassword; } /** - * * @param email non null and non blank email * @return false if the email address isn't already registered, true - * otherwise + * otherwise */ protected boolean alreadyRegistered(String email) { - boolean result = true; + boolean result; WikittyProxy proxy = getBowProxy(); - //Retrieves user by user name (email) + //Retrieves user by user name (email) Criteria criteria = Search.query() .eq(BowUser.FQ_FIELD_WIKITTYUSER_LOGIN, email).criteria(); @@ -115,9 +104,7 @@ return result; } - /** - * Registers the new user and sends an email to confirm registration - */ + /** Registers the new user and sends an email to confirm registration */ @Override public String execute() { String result = INPUT; @@ -158,11 +145,11 @@ //If the email address is invalid addActionError(_("bow.mail.badFormat")); log.error(String.format("Can't send message email to '%s'", - email), eee); + email), eee); } catch (MessagingException eee) { addActionError("bow.mail.sendError"); log.error(String.format("Can't send message email to '%s'", - email), eee); + email), eee); } result = SUCCESS; } Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchBaseAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchBaseAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchBaseAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -32,7 +32,7 @@ /** * Traite toutes les demandes faite via l'opensearch * a:, :, t:, ... - * + * <p/> * Cette classe recherche le prefix et redirige vers la bonne methode execute. * Les classes filles n'ont plus qu'a implanter les methodes * @@ -41,15 +41,16 @@ abstract public class OpenSearchBaseAction extends BowBaseAction { /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(OpenSearchBaseAction.class); + private static final Log log = LogFactory.getLog(OpenSearchBaseAction.class); private static final long serialVersionUID = 1L; /** [in] le token d'identification */ protected String token; + /** [in] la ligne de recherche soumise par l'utilisateur */ protected String searchLine; - + /** * [out] le prefix trouve ou calculer par rapport a searchLine * avoir acces a cette valeur, peut-etre utile dans certaine implantation @@ -64,17 +65,13 @@ public void setSearchLine(String searchLine) { this.searchLine = searchLine; } - - /** - * @return the token - */ + + /** @return the token */ public String getToken() { return token; } - /** - * @param token the token to set - */ + /** @param token the token to set */ public void setToken(String token) { this.token = token; } @@ -103,7 +100,7 @@ if (log.isDebugEnabled()) { log.debug(String.format("Cut '%s' with '%s' result is '%s' and '%s'", - searchLine, prefixSeparator, prefix, query)); + searchLine, prefixSeparator, prefix, query)); } if (StringUtils.isEmpty(prefix)) { @@ -117,10 +114,10 @@ if (log.isDebugEnabled()) { log.debug(String.format("Prefix is '%s' and query '%s'", - prefix, query)); + prefix, query)); } - String result = SUCCESS; + String result; if (StringUtils.equals(prefix, user.getTagSearchPrefix())) { result = executeTagSearchAction(query); } else if (StringUtils.equals(prefix, user.getFullTextSearchPrefix())) { Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchResultAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchResultAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchResultAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,20 +23,20 @@ */ package org.chorem.bow.action.opensearch; -import javax.servlet.http.HttpServletResponse; - import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.interceptor.ServletResponseAware; import org.chorem.bow.BowBookmark; import org.chorem.bow.BowConfig; +import org.chorem.bow.BowUser; import org.chorem.bow.BowUtils; -import org.chorem.bow.BowUser; +import org.nuiton.wikitty.WikittyProxy; import org.nuiton.wikitty.search.Criteria; -import org.nuiton.wikitty.WikittyProxy; import org.nuiton.wikitty.search.Search; +import javax.servlet.http.HttpServletResponse; + /** * Traite toutes les demandes faite via l'opensearch * a:, :, t:, ... @@ -45,16 +45,16 @@ */ public class OpenSearchResultAction extends OpenSearchBaseAction implements ServletResponseAware { /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(OpenSearchResultAction.class); + private static final Log log = + LogFactory.getLog(OpenSearchResultAction.class); private static final long serialVersionUID = 1L; protected String redirectTo; - protected HttpServletResponse response; - /** - * @return the redirectTo - */ + protected transient HttpServletResponse response; + + /** @return the redirectTo */ public String getRedirectTo() { return redirectTo; } Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchSuggestionAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchSuggestionAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/opensearch/OpenSearchSuggestionAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -49,7 +49,7 @@ /** * Retourne les suggestions pour l'opensearch en fonction de ce qui a ete deja * saisi - * + * * @author poussin */ public class OpenSearchSuggestionAction extends OpenSearchBaseAction { @@ -57,10 +57,10 @@ /** Logger. */ private static final Log log = LogFactory.getLog(OpenSearchSuggestionAction.class); - + private static final long serialVersionUID = 1L; - static public OpenSearchSuggestionAction getAction() { + public static OpenSearchSuggestionAction getAction() { Object action = ActionContext.getContext().get(CONTEXT_ACTION_KEY); return (OpenSearchSuggestionAction) action; } @@ -111,14 +111,14 @@ search.exteq(BowBookmark.EXT_WIKITTYLABEL); search.contains(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS, searchLineList); - Criteria criteria= search + Criteria criteria = search .criteria() .setEndIndex(0) // on ne veut aucun resultat, c'est la facet dont on a besoin .setFacetMinCount(1) // on demande meme les labels avec 1 seul item .setFacetLimit(Integer.MAX_VALUE) // ne ne met pas -1 pour qu'il soit trie par ordre de count .addFacetField(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS); - PagedResult<Wikitty> result = proxy.findAllByCriteria(criteria); + PagedResult<Wikitty> result = proxy.findAllByCriteria(criteria); // lorsqu'on demande tout (facetLimit(-1)), les topics sont trie // alphabetiquement pas besoin de les retrier List<FacetTopic> topics = result.getTopic(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS); @@ -129,14 +129,14 @@ // on en retourne un suggestion que le meme nombre de tag qu'il souhaite // voir affiche int count = user.getTags(); - for(FacetTopic t : topics) { + for (FacetTopic t : topics) { // on ne met que les topics qui qui commence par lastTag String completion = t.getTopicName(); if (log.isTraceEnabled()) { log.trace(String.format("'%s' startsWith '%s' ? ", completion, lastTag)); } if (completion.startsWith(lastTag)) { - String description = _("%s results",t.getCount()); + String description = _("%s results", t.getCount()); String tags = query + StringUtils.removeStart(completion, lastTag); getConfig(); String queryUrl = BowConfig.getBowUrl() + BowUtils.redirectTo(tags, null); @@ -156,7 +156,7 @@ if (log.isDebugEnabled()) { log.debug(String.format("opensearch suggest result: %s", json)); } - inputStream = new ReaderInputStream(new StringReader(json.toString())); + inputStream = new ReaderInputStream(new StringReader(json.toString())); return SUCCESS; } @@ -199,16 +199,16 @@ Search search = BookmarkUtils.addEqUser(Search.query(), user.getWikittyId()); search.eq(BowBookmark.FQ_FIELD_BOWBOOKMARK_PRIVATEALIAS, privateAliasStar); - Criteria criteria= search.criteria() + Criteria criteria = search.criteria() .setEndIndex(15); // on recupere que les 15 premiers resultats - PagedResult<BowBookmark> result = proxy.findAllByCriteria(BowBookmark.class, criteria); + PagedResult<BowBookmark> result = proxy.findAllByCriteria(BowBookmark.class, criteria); - for(BowBookmark b: result) { + for (BowBookmark b : result) { String completion = b.getPrivateAlias(); String description = b.getDescription(); String queryUrl = String.format("%s%s?token=%s", - getConfig().getAliasUrl(), completion, token); + BowConfig.getAliasUrl(), completion, token); completions.add("'" + completion + "'"); descriptions.add("'" + description + "'"); queryUrls.add("'" + queryUrl + "'"); @@ -218,20 +218,20 @@ if (log.isDebugEnabled()) { log.debug(String.format("opensearch alias suggest result: %s", json)); } - inputStream = new ReaderInputStream(new StringReader(json.toString())); + inputStream = new ReaderInputStream(new StringReader(json.toString())); return SUCCESS; } /** * On ne renvoie aucune suggestion - * + * * @param query * @return */ @Override protected String executeNotSupportedPrefixAction(String query) { String result = String.format("['%s', [], [], []]", query); - inputStream = new ReaderInputStream(new StringReader(result)); + inputStream = new ReaderInputStream(new StringReader(result)); return SUCCESS; } Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/AdminTagAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/AdminTagAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/AdminTagAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -1,10 +1,5 @@ package org.chorem.bow.action.preference; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -16,23 +11,29 @@ import org.nuiton.wikitty.search.PagedResult; import org.nuiton.wikitty.search.Search; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + /** - * * @author poussin * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ + * <p/> + * Last update: $Date$ + * by : $Author$ */ public class AdminTagAction extends PreferenceBaseAction { /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(AdminTagAction.class); + private static final Log log = LogFactory.getLog(AdminTagAction.class); + private static final long serialVersionUID = 1L; /** * ACTION STRUTS - * + * <p/> * Fait les modification demandé par l'utilisateur dans l'interface de * preference: renome ou supprime des labels. Si l'utilisateur demande le * remplacement de label on indiquant pas de nouveau label, alors la chaine Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/DeleteImportAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/DeleteImportAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/DeleteImportAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,16 +23,16 @@ */ package org.chorem.bow.action.preference; -import java.util.List; - import org.chorem.bow.BowBookmark; import org.chorem.bow.BowImport; import org.chorem.bow.BowUser; -import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.search.Search; +import java.util.List; + /** * Supprime un import de bookmark * @@ -40,37 +40,33 @@ */ public class DeleteImportAction extends PreferenceBaseAction { private static final long serialVersionUID = 8714394293884265516L; + protected String date; - - /** - * @return the date - */ + + /** @return the date */ public String getDate() { return date; } - /** - * @param date the date to set - */ + + /** @param date the date to set */ public void setDate(String date) { this.date = date; } - - /** - * Deletes a bookmark import - */ + + /** Deletes a bookmark import */ public String execute() { String result = SUCCESS; try { if (date != null && - // XXX poussin 20110818 y'a-t-il vraiment une utilite a checker - // que la date verifie le pattern ? - // car on pire on ne retrouve rien et donc on ne supprime rien - date.matches("[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{1,3}Z")) { + // XXX poussin 20110818 y'a-t-il vraiment une utilite a checker + // que la date verifie le pattern ? + // car on pire on ne retrouve rien et donc on ne supprime rien + date.matches("[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{1,3}Z")) { WikittyProxy proxy = getBowProxy(); BowUser user = getBowSession().getUser(); Criteria criteria = Search.query() - .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, user.getWikittyId()) - .eq(BowImport.FQ_FIELD_BOWIMPORT_IMPORTDATE, date).criteria(); + .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, user.getWikittyId()) + .eq(BowImport.FQ_FIELD_BOWIMPORT_IMPORTDATE, date).criteria(); List<BowImport> bookmarks = proxy.findAllByCriteria(BowImport.class, criteria).getAll(); if (log.isDebugEnabled()) { Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ExportBookmarksAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ExportBookmarksAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ExportBookmarksAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,6 +23,15 @@ */ package org.chorem.bow.action.preference; +import org.apache.commons.io.IOUtils; +import org.chorem.bow.BookmarkUtils; +import org.chorem.bow.BowBookmark; +import org.chorem.bow.BowUser; +import org.chorem.bow.action.BowBaseAction; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.Search; + import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; @@ -34,16 +43,6 @@ import java.util.List; import java.util.Set; - -import org.apache.commons.io.IOUtils; -import org.chorem.bow.BowBookmark; -import org.chorem.bow.BookmarkUtils; -import org.chorem.bow.BowUser; -import org.chorem.bow.action.BowBaseAction; -import org.nuiton.wikitty.search.Criteria; -import org.nuiton.wikitty.WikittyProxy; -import org.nuiton.wikitty.search.Search; - /** * Export son bookmark au format HTML * @@ -51,24 +50,25 @@ */ public class ExportBookmarksAction extends BowBaseAction { private static final long serialVersionUID = 45880214686011946L; - - protected InputStream inputStream; + protected transient InputStream inputStream; + public InputStream getInputStream() { return inputStream; } - + /** * Export tous les bookmarks au format HTML tel que le fait les navigateurs * * @param bookmarks List<Bookmarks> bookmarks - * @param out le flux dans lequel il faut ecrire l'export + * @param out le flux dans lequel il faut ecrire l'export * @return String the html file + * @throws IOException */ protected void generateExportHtmlBookmark(List<BowBookmark> bookmarks, Writer out) throws IOException { out.write("<!DOCTYPE NETSCAPE-Bookmark-file-1>\n" - + "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">\n" - + "<DL><p>\n"); + + "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">\n" + + "<DL><p>\n"); if (bookmarks != null) { for (BowBookmark bookmark : bookmarks) { if (bookmark != null) { @@ -84,7 +84,7 @@ Set<String> tags = bookmark.getLabels(); if (tags != null && !tags.isEmpty()) { out.write("SHORTCUTURL=\"" - + BookmarkUtils.getBookmarkTagsString(bookmark) + "\""); + + BookmarkUtils.getBookmarkTagsString(bookmark) + "\""); } out.write(">" + bookmark.getDescription() + "</A>\n"); } @@ -93,9 +93,7 @@ out.write("</DL><p>"); } - /** - * Exports the bookmarks in HTML format - */ + /** Exports the bookmarks in HTML format */ @Override public String execute() { WikittyProxy proxy = getBowProxy(); @@ -110,18 +108,18 @@ // Export all BufferedWriter out = null; - + try { // Write result in temp file File tmp = File.createTempFile("bookmarks", ".tmp.html"); - + tmp.deleteOnExit(); out = new BufferedWriter(new FileWriter(tmp)); generateExportHtmlBookmark(bookmarks, out); out.close(); - - inputStream = new FileInputStream(tmp); + + inputStream = new FileInputStream(tmp); } catch (IOException eee) { log.error("Error when exporting bookmarks to HTML : ", eee); } finally { Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/GenerateTokenAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/GenerateTokenAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/GenerateTokenAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -7,17 +7,17 @@ import org.chorem.bow.BowUtils; /** - * * @author poussin * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ + * <p/> + * Last update: $Date$ + * by : $Author$ */ public class GenerateTokenAction extends PreferenceBaseAction { /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(GenerateTokenAction.class); + private static final Log log = LogFactory.getLog(GenerateTokenAction.class); + private static final long serialVersionUID = 1L; @Override @@ -40,7 +40,7 @@ // on recharge les data apres l'action pour l'affichage load(); } - return SUCCESS; + return SUCCESS; } } Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ImportBookmarksAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ImportBookmarksAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/ImportBookmarksAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,18 +23,7 @@ */ package org.chorem.bow.action.preference; -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.apache.commons.lang.StringUtils; - import org.chorem.bow.BookmarkUtils; import org.chorem.bow.BowBookmark; import org.chorem.bow.BowImportHelper; @@ -47,9 +36,20 @@ import org.nuiton.wikitty.WikittyProxy; import org.nuiton.wikitty.entities.Wikitty; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** * Import un bookmark HTML - * + * * @author poussin */ public class ImportBookmarksAction extends PreferenceBaseAction { @@ -57,70 +57,63 @@ private static final long serialVersionUID = -5962680416570797028L; protected File upfile; + protected String upfileContentType; + protected String upfileFileName; - /** - * @return the upfile - */ + /** @return the upfile */ public File getUpfile() { return upfile; } - /** - * @param upfile - * the upfile to set - */ + /** @param upfile the upfile to set */ public void setUpfile(File upfile) { this.upfile = upfile; } - /** - * @return the upfileContentType - */ + /** @return the upfileContentType */ public String getUpfileContentType() { return upfileContentType; } - /** - * @param upfileContentType - * the upfileContentType to set - */ + /** @param upfileContentType the upfileContentType to set */ public void setUpfileContentType(String upfileContentType) { this.upfileContentType = upfileContentType; } - /** - * @return the upfileFileName - */ + /** @return the upfileFileName */ public String getUpfileFileName() { return upfileFileName; } - /** - * @param upfileFileName - * the upfileFileName to set - */ + /** @param upfileFileName the upfileFileName to set */ public void setUpfileFileName(String upfileFileName) { this.upfileFileName = upfileFileName; } /** - * @param html String html - * @param name String name - * @param user User user + * @param html String html + * @param name String name + * @param user User user * @return Bookmark the bookmark filled */ protected BowBookmark createBookmarkFromHtml(String html, String name, BowUser user) { String link = getUrlFromHtml(html); String tags = getTagsFromHtml(html); Date date = getDateFromHtml(html); - BowBookmark bookmark = BookmarkUtils.createBookmark(link, name, tags, user, null, null, date); + BowBookmark bookmark = BookmarkUtils.createBookmark(link, + name, + tags, + user, + null, + null, + date); return bookmark; } /** - * @param html String html + * @param html String html * @return Date from the html */ protected Date getDateFromHtml(String html) { @@ -140,7 +133,7 @@ } /** - * @param html String html + * @param html String html * @return url */ protected String getUrlFromHtml(String html) { @@ -167,8 +160,11 @@ return tags; } - protected void parseHtmlToBookmarks(NodeList list, BowUser user, Date date, - List<BowBookmark> bookmarks, Set<String> tagList) + protected void parseHtmlToBookmarks(NodeList list, + BowUser user, + Date date, + List<BowBookmark> bookmarks, + Set<String> tagList) throws ParserException { SimpleNodeIterator it = list.elements(); @@ -176,24 +172,24 @@ while (it.hasMoreNodes()) { Node node = it.nextNode(); String plainText = node.toPlainTextString(); // The text between - // two heads ==> - // <toto>plainText</toto> + // two heads ==> + // <toto>plainText</toto> String text = node.getText(); // The text in the head ==> - // <text></toto> + // <text></toto> if (StringUtils.startsWithIgnoreCase(text, "h3")) { // H3 = folder if (StringUtils.isNotBlank(plainText)) { tagList.add(plainText); // Adds the folder name to the - // tagList + // tagList } } else if (StringUtils.startsWithIgnoreCase(text, "a href")) { // HREF - // = new - // bookmarks + // = new + // bookmarks BowBookmark bookmark = createBookmarkFromHtml(text, plainText, user); Wikitty w = getBowProxy().getWikitty(bookmark); BowImportHelper.addExtension(w); BowImportHelper.setImportDate(w, date); - + bookmark.addAllLabels(tagList); bookmarks.add(bookmark); @@ -202,10 +198,10 @@ if (children != null) { parseHtmlToBookmarks(children, user, date, bookmarks, - // On utilise une nouvelle liste pour les enfants - // pour eviter que les tags de tous les enfants se - // retrouve ensemble - new HashSet<String>(tagList)); // If there is an under node = recursion + // On utilise une nouvelle liste pour les enfants + // pour eviter que les tags de tous les enfants se + // retrouve ensemble + new HashSet<String>(tagList)); // If there is an under node = recursion } } } @@ -228,19 +224,19 @@ List<BowBookmark> bookmarks = new ArrayList<BowBookmark>(); parseHtmlToBookmarks(list, user, new Date(), bookmarks, - new HashSet<String>()); + new HashSet<String>()); proxy.store(bookmarks); addActionMessage(_("bow.bookmark.import.successful")); } catch (ParserException eee) { result = ERROR; log.error(String.format("Can't parse imported file '%s'", - getUpfileFileName()), eee); + getUpfileFileName()), eee); addActionError(_("bow.bookmark.badFileFormat")); } catch (IOException eee) { result = ERROR; log.error(String.format("Can't read imported file '%s'", - getUpfileFileName()), eee); + getUpfileFileName()), eee); addActionError(_("bow.error.internal")); } } else { Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/PreferenceBaseAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/PreferenceBaseAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/PreferenceBaseAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,21 +23,14 @@ */ package org.chorem.bow.action.preference; -import org.chorem.bow.BowBookmark; -import org.chorem.bow.BowProxy; -import org.chorem.bow.BowUser; import com.opensymphony.xwork2.ActionContext; -import java.text.ParseException; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import org.apache.commons.lang.StringUtils; - +import org.chorem.bow.BowBookmark; import org.chorem.bow.BowImport; +import org.chorem.bow.BowProxy; import org.chorem.bow.BowSession; +import org.chorem.bow.BowUser; import org.chorem.bow.action.BowBaseAction; - import org.nuiton.wikitty.WikittyUtil; import org.nuiton.wikitty.entities.Wikitty; import org.nuiton.wikitty.search.Criteria; @@ -45,49 +38,77 @@ import org.nuiton.wikitty.search.PagedResult; import org.nuiton.wikitty.search.Search; +import java.text.ParseException; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * Change les preferences de l'utilisateur (couleur, password, email, ...) - * + * * @author poussin */ public class PreferenceBaseAction extends BowBaseAction { + private static final long serialVersionUID = -58341106356599721L; - - static public PreferenceBaseAction getAction() { + + public static PreferenceBaseAction getAction() { Object action = ActionContext.getContext().get(CONTEXT_ACTION_KEY); return (PreferenceBaseAction) action; } - public static enum DefaultPrefix {TAG, FULLTEXT, WEB, ALIAS}; - + public enum DefaultPrefix {TAG, FULLTEXT, WEB, ALIAS} + /** la liste des differentes data que l'on peut charger */ - protected static enum PreferenceType{USER_PREF, SITE_PREF, LABELS, IMPORTS}; + protected enum PreferenceType { + USER_PREF, SITE_PREF, LABELS, IMPORTS + } protected String email; + protected String newPassword; + protected String currentPassword; + protected String confirmNewPassword; protected String colors; + protected String tagsNb; + protected String bookmarksHomePage; + protected String searchEngineUrlSuggestions; + protected String searchEngineUrlResults; + protected String separator; + protected String tagPrefix; + protected String fulltextPrefix; + protected String webPrefix; + protected String aliasPrefix; + protected DefaultPrefix defaultPrefix; + protected DefaultPrefix defaultAction; protected List<FacetTopic> labels; + protected String[] selectedLabels; + protected String rename; + protected String delete; + protected String newLabel; protected String update; + protected Map<String, Integer> bookmarksImportDate; public String getNewLabel() { @@ -97,7 +118,7 @@ public void setNewLabel(String newLabel) { this.newLabel = newLabel; } - + public void setRename(String rename) { this.rename = rename; } @@ -113,73 +134,53 @@ public String getDelete() { return delete; } - - /** - * @return the colors - */ + + /** @return the colors */ public String getColors() { return colors; } - /** - * @param colors the colors to set - */ + /** @param colors the colors to set */ public void setColors(String colors) { this.colors = colors; } - /** - * @return the tagsNb - */ + /** @return the tagsNb */ public String getTagsNb() { return tagsNb; } - /** - * @param tagsNb the tagsNb to set - */ + /** @param tagsNb the tagsNb to set */ public void setTagsNb(String tagsNb) { this.tagsNb = tagsNb; } - /** - * @return the bookmarksHomePage - */ + /** @return the bookmarksHomePage */ public String getBookmarksHomePage() { return bookmarksHomePage; } - /** - * @param bookmarksHomePage the bookmarksHomePage to set - */ + /** @param bookmarksHomePage the bookmarksHomePage to set */ public void setBookmarksHomePage(String bookmarksHomePage) { this.bookmarksHomePage = bookmarksHomePage; } - /** - * @return the searchEngineUrlSuggestions - */ + /** @return the searchEngineUrlSuggestions */ public String getSearchEngineUrlSuggestions() { return searchEngineUrlSuggestions; } - /** - * @param searchEngineUrlSuggestions the searchEngineUrlSuggestions to set - */ + /** @param searchEngineUrlSuggestions the searchEngineUrlSuggestions to set */ public void setSearchEngineUrlSuggestions(String searchEngineUrlSuggestions) { this.searchEngineUrlSuggestions = searchEngineUrlSuggestions; } - /** - * @return the searchEngineUrlResults - */ + /** @return the searchEngineUrlResults */ public String getSearchEngineUrlResults() { return searchEngineUrlResults; } - /** - * @param searchEngineUrlResults the searchEngineUrlResults to set - */ + /** @param searchEngineUrlResults the searchEngineUrlResults to set */ public void setSearchEngineUrlResults(String searchEngineUrlResults) { this.searchEngineUrlResults = searchEngineUrlResults; } @@ -240,86 +241,62 @@ this.defaultAction = DefaultPrefix.valueOf(defaultAction); } - /** - * @return the email - */ + /** @return the email */ public String getEmail() { return email; } - /** - * @param email the email to set - */ + /** @param email the email to set */ public void setEmail(String email) { this.email = email; } - /** - * @return the newPassword - */ + /** @return the newPassword */ public String getNewPassword() { return newPassword; } - /** - * @param newPassword the newPassword to set - */ + /** @param newPassword the newPassword to set */ public void setNewPassword(String newPassword) { this.newPassword = newPassword; } - /** - * @return the currentPassword - */ + /** @return the currentPassword */ public String getCurrentPassword() { return currentPassword; } - /** - * @param currentPassword the currentPassword to set - */ + /** @param currentPassword the currentPassword to set */ public void setCurrentPassword(String currentPassword) { this.currentPassword = currentPassword; } - /** - * @return the confirmNewPassword - */ + /** @return the confirmNewPassword */ public String getConfirmNewPassword() { return confirmNewPassword; } - /** - * @param confirmNewPassword the confirmNewPassword to set - */ + /** @param confirmNewPassword the confirmNewPassword to set */ public void setConfirmNewPassword(String confirmNewPassword) { this.confirmNewPassword = confirmNewPassword; } - /** - * @return the update - */ + /** @return the update */ public String getUpdate() { return update; } - /** - * @param update the update to set - */ + /** @param update the update to set */ public void setUpdate(String update) { this.update = update; } - /** - * @return the bookmarksImportDate - */ + /** @return the bookmarksImportDate */ public Map<String, Integer> getBookmarksImportDate() { return bookmarksImportDate; } - /** - * @param bookmarksImportDate the bookmarksImportDate to set - */ + /** @param bookmarksImportDate the bookmarksImportDate to set */ public void setBookmarksImportDate(Map<String, Integer> bookmarksImportDate) { this.bookmarksImportDate = bookmarksImportDate; } @@ -341,8 +318,11 @@ * Elle est de la forme '2011-08-18T00:25:16.028Z' * qui n'est pas presentable a l'utilisateur * On la remet sous une vrai forme date - * + * <p/> * Cette methode est utilise dans la JSP de rendu + * + * @param date + * @return */ public Date stringToDate(String date) { try { @@ -355,9 +335,10 @@ /** * Load les données sauf celle que l'on demande d'exclure du load + * * @param exclude */ - protected void load(PreferenceType ... exclude) { + protected void load(PreferenceType... exclude) { PreferenceType[] list = PreferenceType.values(); for (PreferenceType type : exclude) { list[type.ordinal()] = null; @@ -365,7 +346,7 @@ for (PreferenceType type : list) { if (type != null) { - switch(type) { + switch (type) { case USER_PREF: loadUserPref(); break; @@ -386,9 +367,7 @@ } } - /** - * charge les info de l'utilisateur qu'il peut modifier - */ + /** charge les info de l'utilisateur qu'il peut modifier */ protected void loadUserPref() { BowSession session = getBowSession(); BowUser user = session.getUser(); @@ -396,14 +375,12 @@ setEmail(user.getLogin()); } - /** - * Charge les preferences utilisateur pour le site - */ + /** Charge les preferences utilisateur pour le site */ protected void loadSitePref() { BowSession session = getBowSession(); BowUser user = session.getUser(); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Load site pref for " + user); } @@ -426,7 +403,7 @@ protected String getDefaultValue(BowUser user, DefaultPrefix constValue) { String result = user.getAliasPrefix(); - switch(constValue) { + switch (constValue) { case TAG: result = user.getTagSearchPrefix(); break; @@ -459,9 +436,7 @@ return result; } - /** - * Charge la liste des imports que l'utilisateur a fait - */ + /** Charge la liste des imports que l'utilisateur a fait */ protected void loadImport() { BowSession session = getBowSession(); BowProxy proxy = session.getProxy(); @@ -475,7 +450,7 @@ List<FacetTopic> bookmarksImportDate = proxy.findAllByCriteria(BowImport.class, criteria) - .getTopic(BowImport.FQ_FIELD_BOWIMPORT_IMPORTDATE); + .getTopic(BowImport.FQ_FIELD_BOWIMPORT_IMPORTDATE); // Extract imports Map<String, Integer> result = new HashMap<String, Integer>(); @@ -487,21 +462,18 @@ if (log.isDebugEnabled()) { log.debug("bookmarksByImportDate found : " - + (result == null ? "null" : result.size())); + + result.size()); } setBookmarksImportDate(result.isEmpty() ? null : result); } - /** - * Charge dans la variable labels tous les labels de l'utilisateur - * @param proxy - */ + /** Charge dans la variable labels tous les labels de l'utilisateur. */ protected void loadLabels() { BowSession session = getBowSession(); BowProxy proxy = session.getProxy(); BowUser user = session.getUser(); String userId = user.getWikittyId(); - + Criteria c = Search.query() .exteq(BowBookmark.EXT_WIKITTYLABEL) .eq(BowBookmark.FQ_FIELD_WIKITTYAUTHORISATION_OWNER, userId) @@ -509,22 +481,22 @@ .setFacetMinCount(1) // on demande meme les labels avec 1 seul item .setFacetLimit(-1) // on demande tous les labels .addFacetField(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS); - PagedResult<Wikitty> result = proxy.findAllByCriteria(c); + PagedResult<Wikitty> result = proxy.findAllByCriteria(c); // lorsqu'on demande tout (facetLimit(-1)), les topics sont trie // alphabetiquement pas besoin de les retrier labels = result.getTopic(BowBookmark.FQ_FIELD_WIKITTYLABEL_LABELS); } - + /** * ACTION STRUTS - * + * <p/> * Action executer lorsque l'utilisateur demande la page. Prepare toutes * les données pour la page JSP */ @Override public String input() { String result = SUCCESS; - + try { // load all data load(); Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateSiteAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateSiteAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateSiteAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -8,22 +8,22 @@ import org.chorem.bow.BowUser; /** - * * @author poussin * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ + * <p/> + * Last update: $Date$ + * by : $Author$ */ public class UpdateSiteAction extends PreferenceBaseAction { /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(UpdateSiteAction.class); + private static final Log log = LogFactory.getLog(UpdateSiteAction.class); + private static final long serialVersionUID = 1L; /** * ACTION STRUTS - * + * <p/> * Action executer lorsque l'utilisateur demande la page */ @Override @@ -46,7 +46,7 @@ preference.setSearchEngineUrlResults(searchEngineUrlResults); preference.setPrefixSeparator(separator); - + preference.setTagSearchPrefix(tagPrefix); preference.setFullTextSearchPrefix(fulltextPrefix); preference.setWebSearchPrefix(webPrefix); Modified: trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateUserAction.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateUserAction.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateUserAction.java 2011-08-29 12:21:36 UTC (rev 324) @@ -11,27 +11,26 @@ import org.nuiton.wikitty.search.Search; /** - * * @author poussin * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ + * <p/> + * Last update: $Date$ + * by : $Author$ */ public class UpdateUserAction extends PreferenceBaseAction { /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(UpdateUserAction.class); + private static final Log log = LogFactory.getLog(UpdateUserAction.class); + private static final long serialVersionUID = 1L; /** * ACTION STRUTS - * + * <p/> * Modifie l'email et le password si necessaire. Si la modif est impossible * email deja utilise, ou mauvais password, alors la methode return ERROR * Si tout ce passe bien, la methode retourne SUCCES * - * @param user * @return */ @Override @@ -66,10 +65,10 @@ } } - if (result == SUCCESS - && StringUtils.isNotBlank(newPassword) - && StringUtils.isNotBlank(confirmNewPassword) - && StringUtils.isNotBlank(currentPassword)) { + if (SUCCESS.equals(result) + && StringUtils.isNotBlank(newPassword) + && StringUtils.isNotBlank(confirmNewPassword) + && StringUtils.isNotBlank(currentPassword)) { if (newPassword.equals(confirmNewPassword)) { currentPassword = StringUtil.encodeMD5(currentPassword); if (currentPassword.equals(user.getPassword())) { @@ -83,7 +82,7 @@ } } } - if (result == SUCCESS) { + if (SUCCESS.equals(result)) { user = proxy.store(user); getBowSession().setUser(user); addActionMessage(_("bow.preferences.update.successful")); Modified: trunk/bow-ui/src/main/java/org/chorem/bow/interceptor/LoginInterceptor.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/interceptor/LoginInterceptor.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/interceptor/LoginInterceptor.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,28 +23,26 @@ */ package org.chorem.bow.interceptor; -import java.util.Map; - -import org.apache.struts2.ServletActionContext; -import org.chorem.bow.BowUtils; -import org.chorem.bow.BowUser; - import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.AbstractInterceptor; +import org.apache.struts2.ServletActionContext; import org.chorem.bow.BowSession; +import org.chorem.bow.BowUser; +import org.chorem.bow.BowUtils; +import java.util.Map; + /** - * Interceptor used to redirect a non-logged user if he tries to access a page + * Interceptor used to redirect a non-logged user if he tries to access a page * where logging is mandatory */ public class LoginInterceptor extends AbstractInterceptor { private static final long serialVersionUID = -7520186185205372272L; + protected String redirect; - /** - * @param redirect the redirect to set - */ + /** @param redirect the redirect to set */ public void setRedirect(String redirect) { this.redirect = redirect; } @@ -56,7 +54,7 @@ BowSession bowSession = BowSession.getBowSession(session); BowUser user = bowSession.getUser(); String result = null; - + //If the user isn't logged in if (user == null) { Map<String, Object> params = ActionContext.getContext().getParameters(); Modified: trunk/bow-ui/src/main/java/org/chorem/bow/interceptor/LogoutInterceptor.java =================================================================== --- trunk/bow-ui/src/main/java/org/chorem/bow/interceptor/LogoutInterceptor.java 2011-08-29 11:54:58 UTC (rev 323) +++ trunk/bow-ui/src/main/java/org/chorem/bow/interceptor/LogoutInterceptor.java 2011-08-29 12:21:36 UTC (rev 324) @@ -23,16 +23,14 @@ */ package org.chorem.bow.interceptor; -import java.util.Map; - import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.AbstractInterceptor; import org.chorem.bow.BowSession; -/** - * Interceptor used to remove all trace of user in session. Used for login page - */ +import java.util.Map; + +/** Interceptor used to remove all trace of user in session. Used for login page */ public class LogoutInterceptor extends AbstractInterceptor { private static final long serialVersionUID = -7520186185205372272L;
participants (1)
-
tchemit@users.chorem.org