You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(233) |
Sep
(199) |
Oct
(206) |
Nov
(185) |
Dec
(270) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(232) |
Feb
(426) |
Mar
(623) |
Apr
(592) |
May
(506) |
Jun
(389) |
Jul
(160) |
Aug
(3) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
(5) |
2007 |
Jan
(1) |
Feb
(1) |
Mar
(2) |
Apr
(2) |
May
(4) |
Jun
(2) |
Jul
|
Aug
(3) |
Sep
(5) |
Oct
(9) |
Nov
(6) |
Dec
(6) |
2008 |
Jan
(3) |
Feb
|
Mar
(1) |
Apr
(3) |
May
(3) |
Jun
(5) |
Jul
(10) |
Aug
(2) |
Sep
(12) |
Oct
(10) |
Nov
(54) |
Dec
(49) |
2009 |
Jan
(19) |
Feb
(13) |
Mar
(20) |
Apr
(24) |
May
(44) |
Jun
(29) |
Jul
(32) |
Aug
(10) |
Sep
(7) |
Oct
(10) |
Nov
(4) |
Dec
(17) |
2010 |
Jan
(14) |
Feb
(5) |
Mar
(23) |
Apr
(50) |
May
(31) |
Jun
(9) |
Jul
(5) |
Aug
(4) |
Sep
(7) |
Oct
(5) |
Nov
(2) |
Dec
(3) |
2011 |
Jan
(12) |
Feb
(5) |
Mar
(5) |
Apr
(3) |
May
(4) |
Jun
(3) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2012 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(4) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2015 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jbo...@li...> - 2005-11-16 22:44:54
|
Author: szimano Date: 2005-11-16 17:44:49 -0500 (Wed, 16 Nov 2005) New Revision: 1581 Modified: trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java Log: if directory exists for not exisiting page, it doesn't fail. http://jira.jboss.com/jira/browse/JBWIKI-67 Modified: trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java =================================================================== --- trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java 2005-11-16 22:21:08 UTC (rev 1580) +++ trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java 2005-11-16 22:44:49 UTC (rev 1581) @@ -379,8 +379,16 @@ // TODO Auto-generated catch block e2.printStackTrace(); } catch (ResourceAlreadyExists e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); + try { + pageDir = pagesManager.getDirectory("").getDirectory( + "OLD/" + uid); + } catch (RepositoryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceDoesNotExist e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } catch (ResourceDoesNotExist e2) { // TODO Auto-generated catch block e2.printStackTrace(); |
Author: szimano Date: 2005-11-16 17:21:08 -0500 (Wed, 16 Nov 2005) New Revision: 1580 Added: trunk/forge/portal-extensions/jbosswiki/wiki-common/src/test/java/org/jboss/wiki/test/CheckContentTest.java Modified: trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/plugins/AttachementInfoPlugin.java Log: shotoku, jboss wiki test http://jira.jboss.com/jira/browse/JBWIKI-69 http://jira.jboss.com/jira/browse/JBWIKI-67 Modified: trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java =================================================================== --- trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java 2005-11-16 21:58:49 UTC (rev 1579) +++ trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java 2005-11-16 22:21:08 UTC (rev 1580) @@ -66,11 +66,11 @@ private static final String propModFileName = "fileMod.properties"; private static final String dictionaryPropertiesFileName = "dictionary.properties"; - + private String pagesPrefix; private String attPrefix; - + public String pathToMediaTrash; public String pathToAttTrash; @@ -113,9 +113,9 @@ + propFileName)); pagesPrefix = shotokuDSProps.getProperty("pagesPrefix"); - + attPrefix = shotokuDSProps.getProperty("attPrefix"); - + pagesManager = ContentManager.getContentManager(pagesPrefix); attManager = ContentManager.getContentManager(attPrefix); @@ -139,7 +139,18 @@ try { modFile = pagesManager.getNode(propModFileName); } catch (ResourceDoesNotExist e) { - modFile = pagesManager.getDirectory("").newNode(propFileName); + try { + modFile = pagesManager.getDirectory("").newNode(propFileName); + } catch (RepositoryException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceAlreadyExists e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceDoesNotExist e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } } InputStream is = null; try { @@ -161,8 +172,19 @@ try { pagesManager.getDirectory(MediaDataSource.mediaTrashName); } catch (ResourceDoesNotExist e) { - pagesManager.getDirectory("").newDirectory( - MediaDataSource.mediaTrashName); + try { + pagesManager.getDirectory("").newDirectory( + MediaDataSource.mediaTrashName); + } catch (RepositoryException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceAlreadyExists e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceDoesNotExist e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } } // create trash directory for deleted attachments if it doesn't exists @@ -170,8 +192,19 @@ try { attManager.getDirectory(AttachmentDataSource.attTrashName); } catch (ResourceDoesNotExist e) { - attManager.getDirectory("").newDirectory( - AttachmentDataSource.attTrashName); + try { + attManager.getDirectory("").newDirectory( + AttachmentDataSource.attTrashName); + } catch (RepositoryException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceAlreadyExists e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceDoesNotExist e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } } // load dictionary props @@ -182,8 +215,19 @@ pageDictionaryFile = pagesManager .getNode(dictionaryPropertiesFileName); } catch (ResourceDoesNotExist e) { - pageDictionaryFile = pagesManager.getDirectory("").newNode( - dictionaryPropertiesFileName); + try { + pageDictionaryFile = pagesManager.getDirectory("").newNode( + dictionaryPropertiesFileName); + } catch (RepositoryException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceAlreadyExists e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceDoesNotExist e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } } // there is dictionary file. Load props from it @@ -215,7 +259,6 @@ return true; } - public boolean savePage(String uid, WikiPage page, String languageCode) { // TODO Languages @@ -225,7 +268,7 @@ // harddisk - add new // version Node propsNode = getPropsNode(uid); - + Properties pageProps = getPageProps(uid, propsNode); pageProps.setProperty(page.getLastVersion() + ".author", page @@ -248,17 +291,37 @@ } savePageProps(uid, propsNode); - + log.info("Opening files"); // File pageFile = new File(pathToMedia + "/OLD/" + uid + "/" + // (page.getLastVersion() - 1) + ".txt"); // File pageOldFile = new File(pathToMedia + "/" + uid + ".txt"); - Node pageFile = pagesManager.getDirectory("").newNode( - "OLD/" + uid + "/" + (page.getLastVersion() - 1) + ".txt"); - Node pageOldFile = pagesManager.getNode( - uid + ".txt"); + Node pageFile = null; + try { + pageFile = pagesManager.getDirectory("").newNode( + "OLD/" + uid + "/" + (page.getLastVersion() - 1) + ".txt"); + } catch (RepositoryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceAlreadyExists e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceDoesNotExist e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + Node pageOldFile = null; + try { + pageOldFile = pagesManager.getNode(uid + ".txt"); + } catch (RepositoryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceDoesNotExist e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } OutputStream pageFileWriter; InputStream pageFileReader; @@ -288,17 +351,19 @@ pageFileWriter.close(); status = true; - - pageOldFile.save("Adding version "+page.getLastVersion()+" of page "+uid); - pageFile.save("Adding version "+page.getLastVersion()+" of page "+uid); - + + pageOldFile.save("Adding version " + page.getLastVersion() + + " of page " + uid); + pageFile.save("Adding version " + page.getLastVersion() + + " of page " + uid); + } catch (IOException ioe) { log.error("[ShotokuDataSource]: Cannot save page: ", ioe); } } else { // there is no page on disk. We have to create new one. - try { + try { // create needed dirs // File newPageFile = new File(pathToMedia + "/OLD/" + uid); @@ -306,14 +371,40 @@ // pagesManager.getDirectory("").newDirectory("OLD/" + uid); - Node newPageFile = pagesManager.getDirectory("").newDirectory( - "OLD/" + uid).newNode("page.properties"); + Directory pageDir = null; + try { + pageDir = pagesManager.getDirectory("").newDirectory( + "OLD/" + uid); + } catch (RepositoryException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } catch (ResourceAlreadyExists e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } catch (ResourceDoesNotExist e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + pageDir.save("Adding version " + page.getLastVersion() + + " of page " + uid); + + Node newPagePropsFile = null; + try { + newPagePropsFile = pageDir.newNode("page.properties"); + } catch (RepositoryException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } catch (ResourceAlreadyExists e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // write the page // newPageFile = new File(pathToMedia + "/OLD/" + uid // + "/page.properties"); - OutputStream pageWriter = newPageFile.getOutputStream(); + OutputStream pageWriter = newPagePropsFile.getOutputStream(); Properties properties = new Properties(); properties.setProperty(page.getLastVersion() + ".author", page @@ -327,16 +418,44 @@ String[] pageNames = uid.split("/"); for (int i = 0; i < pageNames.length - 1; i++) { - pageDirName += "/" + pageNames[i]; + pageDirName += ((i != 0) ? "/" : "") + pageNames[i]; } - pagesManager.getDirectory("").newDirectory(pageDirName); - - Node pageFile = pagesManager.getRootDirectory().newNode(uid + ".txt"); - pageWriter = pageFile - .getOutputStream(); + try { + pageDir = pagesManager.getRootDirectory().getDirectory(pageDirName); + } catch (RepositoryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceDoesNotExist e) { + try { + pageDir = pagesManager.getRootDirectory().newDirectory(pageDirName); + } catch (RepositoryException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceAlreadyExists e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + + pageDir.save("Adding version " + page.getLastVersion() + " of page " + + uid); + Node pageFile = null; + try { + pageFile = pagesManager.getRootDirectory().newNode(uid + ".txt"); + } catch (RepositoryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceAlreadyExists e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + pageWriter = pageFile.getOutputStream(); + String pageContent = page.getContent(); for (int i = 0; i < pageContent.length(); i++) { @@ -346,14 +465,16 @@ pageWriter.close(); status = true; - - newPageFile.save("Adding version "+page.getLastVersion()+" of page "+uid); - pageFile.save("Adding version "+page.getLastVersion()+" of page "+uid); - - } catch (Exception e) { - log.error("Cannot write new page: ", e); - status = false; - } + + newPagePropsFile.save("Adding version " + page.getLastVersion() + + " of page " + uid); + pageFile.save("Adding version " + page.getLastVersion() + + " of page " + uid); + + + } catch (IOException e) { log.error("Cannot write new page: ", e); + status = false; } + } return status; } @@ -367,26 +488,19 @@ } public void savePageProps(String pageName, Node pagePropsNode) { - try { - pagePropsNode.save("Saving page props for page: "+pageName); - } catch (ResourceDoesNotExist e) { - // There is no prop file for some reson - create one. + pagePropsNode.save("Saving page props for page: " + pageName); + } - getPageProps(pageName, pagePropsNode); - } - } - private Node getPropsNode(String pageName) { try { - return pagesManager.getNode( - "OLD/" + pageName + "/page.properties"); + return pagesManager.getNode("OLD/" + pageName + "/page.properties"); } catch (ResourceDoesNotExist e) { return null; } catch (RepositoryException e) { return null; } } - + public Properties getPageProps(String pageName, Node pageNode) { Properties pageProps = new Properties(); @@ -397,8 +511,20 @@ } catch (Exception ioe) { // There is no prop file for some reson - create one. - Node pagePropsFile = pagesManager.getDirectory("").newDirectory( - "OLD/" + pageName).newNode("page.properties"); + Node pagePropsFile = null; + try { + pagePropsFile = pagesManager.getDirectory("").newDirectory( + "OLD/" + pageName).newNode("page.properties"); + } catch (RepositoryException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceAlreadyExists e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceDoesNotExist e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } try { if (pageExists(pageName)) { @@ -409,7 +535,8 @@ pageProps.setProperty("1.author", "unknown"); pageProps.store(fpo, SAVE_COMMENT); fpo.close(); - pagePropsFile.save("genarating page props for page: "+pageName); + pagePropsFile.save("genarating page props for page: " + + pageName); } } catch (IOException e) { @@ -423,52 +550,78 @@ return pageProps; } - public Properties getAttProps(String pageName, String attName, - boolean createProps) { - Properties attProps = new Properties(); + private Node getAttPropsNode(String pageName, String attName, boolean createProps) { + Node propNode = null; - Node propFile; - try { - propFile = attManager.getNode(pageName - + "-att/" + attName + "-dir/attachment.properties"); + propNode = attManager.getNode(pageName + "-att/" + attName + + "-dir/attachment.properties"); } catch (ResourceDoesNotExist e) { if (createProps) { // create dirs for this property file - propFile = attManager.getDirectory("").newDirectory( - pageName + "-att/" + attName - + "-dir").newNode("attachment.properties"); + Directory pageDir = null; + try { + pageDir = attManager.getDirectory("").newDirectory( + pageName + "-att/" + attName + "-dir"); + } catch (RepositoryException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceAlreadyExists e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceDoesNotExist e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + pageDir.save("adding "+attName+" directory for page: "+pageName); + + try { + propNode = pageDir.newNode( + "attachment.properties"); + } catch (RepositoryException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceAlreadyExists e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } } else { return null; } } + + return propNode; + } + + public Properties getAttProps(Node propsNode, String attName) { + + // if there is no attachment node return null + if (propsNode == null) + return null; + + Properties attProps = new Properties(); try { - attProps.load(propFile.getContentInputStream()); + attProps.load(propsNode.getContentInputStream()); } catch (IOException ioe) { log.error("Cannot read attachment.properties for attachement: " - + pageName + "-att/" + attName - + "-dir/attachment.properties\n", ioe); + + propsNode.getFullName(), ioe); } return attProps; } - public void saveAttProps(Properties props, String pageName, String attName) { + public void saveAttProps(Node propsNode, Properties props) { try { - props.store(attManager - .getNode( - pageName + "-att/" + attName - + "-dir/attachment.properties") - .getOutputStream(), SAVE_COMMENT); + props.store(propsNode.getOutputStream(), SAVE_COMMENT); } catch (Exception ioe) { log.error("Cannot store attchement.properties for attachement: " - + pageName + "-att/" + attName - + "-dir/attachments.properties\n", ioe); + + propsNode.getFullName(), ioe); } + propsNode.save("Saving props for attachment "+propsNode.getFullName()); } public WikiPage getPage(String pageName) { @@ -479,7 +632,8 @@ try { Node pageFile = pagesManager.getNode(pageName + ".txt"); - Properties pageProps = getPageProps(pageName, getPropsNode(pageName)); + Properties pageProps = getPageProps(pageName, + getPropsNode(pageName)); if (pageProps != null) { @@ -593,8 +747,17 @@ int version) { StringBuilder ret = null; - Node pageFile = pagesManager.getNode("OLD/" + page.getName() + "/" - + version + ".txt"); + Node pageFile = null; + try { + pageFile = pagesManager.getNode("OLD/" + page.getName() + "/" + + version + ".txt"); + } catch (RepositoryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceDoesNotExist e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } if (loadContent) { try { @@ -625,8 +788,17 @@ public Date getDateAtVersion(String pageName, int version) { Date ret = null; - Node pageFile = pagesManager.getNode("OLD/" + pageName + "/" + version - + ".txt"); + Node pageFile = null; + try { + pageFile = pagesManager.getNode("OLD/" + pageName + "/" + version + + ".txt"); + } catch (RepositoryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceDoesNotExist e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } ret = new Date(pageFile.getLastModification()); @@ -634,8 +806,8 @@ } public Credentials getAuthorAtVersion(String pageName, int version) { - return new SimpleCredentials(getPageProps(pageName, getPropsNode(pageName)).getProperty( - version + ".author")); + return new SimpleCredentials(getPageProps(pageName, + getPropsNode(pageName)).getProperty(version + ".author")); } public boolean pageExists(String pageName) { @@ -651,7 +823,10 @@ public void addAttachment(InputStream attFile, String attName, WikiPage page, String user) { String pageName = page.getName(); - Properties attProps = getAttProps(pageName, attName, true); + + Node propsNode = getAttPropsNode(pageName, attName, true); + + Properties attProps = getAttProps(propsNode, attName); int lastVersion = 1; @@ -675,8 +850,20 @@ InputStream oldFile = null; OutputStream newFile = null; - newFile = attManager.getDirectory("").newNode(fileName) - .getOutputStream(); + Node newFileNode = null; + try { + newFileNode = attManager.getDirectory("").newNode(fileName); + } catch (RepositoryException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceAlreadyExists e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceDoesNotExist e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + newFile = newFileNode.getOutputStream(); oldFile = attFile; // writing old file to new one @@ -699,7 +886,9 @@ attProps.setProperty(lastVersion + ".author", user); - saveAttProps(attProps, pageName, attName); + saveAttProps(propsNode, attProps); + + newFileNode.save("Adding attachment: "+attName+" for page: "+page.getName()); } public Set<String> getAttachmentsSet(WikiPage page) { @@ -740,7 +929,16 @@ } private void getPageNamesFor(String directory, Set<String> attSet) { - Directory attDir = pagesManager.getDirectory(directory); + Directory attDir = null; + try { + attDir = pagesManager.getDirectory(directory); + } catch (RepositoryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceDoesNotExist e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } List<Node> pageFiles = attDir.getNodes().toList(); @@ -757,7 +955,7 @@ List<Directory> pageDirs = attDir.getDirectories(); - //TODO make "special" directories work better + // TODO make "special" directories work better for (Directory dir : pageDirs) { if ((!dir.getName().endsWith("-att"))) { // do not take dirs from OLD, .svn and trash folders @@ -768,8 +966,7 @@ && (!dir.getName().equals( AttachmentDataSource.attTrashName))) { // get names for subpages - getPageNamesFor( - directory + "/" + dir.getName(), attSet); + getPageNamesFor(directory + "/" + dir.getName(), attSet); } } } @@ -785,7 +982,7 @@ String[] tokens = attachementName.split("\\."); - Properties props = getAttProps(pageName, attachementName, false); + Properties props = getAttProps(getAttPropsNode(pageName, attachementName, false), attachementName); if (props == null) { return null; @@ -793,23 +990,33 @@ String user = props.getProperty(version + ".author"); - Node file = attManager - .getNode(pageName - + "-att/" - + attachementName - + "-dir/" - + version - + "." - + ((attachementName.indexOf(".") != -1) ? tokens[tokens.length - 1] - : "bin")); + Node file = null; + try { + file = attManager + .getNode(pageName + + "-att/" + + attachementName + + "-dir/" + + version + + "." + + ((attachementName.indexOf(".") != -1) ? tokens[tokens.length - 1] + : "bin")); + } catch (RepositoryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceDoesNotExist e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } return new WikiAttachment(attachementName, new Date(file - .getLastModification()), user, file.getLength(), file.getContentInputStream(), version); + .getLastModification()), user, file.getLength(), file + .getContentInputStream(), version); } public int getLastAttachmentVersion(String pageName, String attachementName) { - Properties props = getAttProps(pageName, attachementName, false); + Properties props = getAttProps(getAttPropsNode(pageName, attachementName, false),attachementName); if (props == null) return -1; @@ -828,15 +1035,24 @@ int version) { String[] tokens = attachementName.split("\\."); - Node file = attManager - .getNode(pageName - + "-att/" - + attachementName - + "-dir/" - + version - + "." - + ((attachementName.indexOf(".") != -1) ? tokens[tokens.length - 1] - : "bin")); + Node file = null; + try { + file = attManager + .getNode(pageName + + "-att/" + + attachementName + + "-dir/" + + version + + "." + + ((attachementName.indexOf(".") != -1) ? tokens[tokens.length - 1] + : "bin")); + } catch (RepositoryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceDoesNotExist e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } return file.getLength(); } @@ -907,7 +1123,16 @@ String pageFileTrashNameBase = pageName + ".txt"; String pageFileTrashName = pageFileTrashNameBase; - Node pageFile = pagesManager.getNode(pageFileName); + Node pageFile = null; + try { + pageFile = pagesManager.getNode(pageFileName); + } catch (RepositoryException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceDoesNotExist e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } Node pageTrashFile; try { @@ -930,9 +1155,21 @@ foundPage = true; } catch (ResourceAlreadyExists ee) { // page exists - continue looking + } catch (RepositoryException ee) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceDoesNotExist ee) { + // TODO Auto-generated catch block + e.printStackTrace(); } } + } catch (RepositoryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceDoesNotExist e) { + // TODO Auto-generated catch block + e.printStackTrace(); } Directory trashFileDir; @@ -941,8 +1178,19 @@ trashFileDir = pagesManager.getDirectory(pathToMediaTrash + "/" + pageName); } catch (ResourceDoesNotExist e) { - trashFileDir = pagesManager.getDirectory("").newDirectory( - pathToMediaTrash + "/" + pageName); + try { + trashFileDir = pagesManager.getDirectory("").newDirectory( + pathToMediaTrash + "/" + pageName); + } catch (RepositoryException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceAlreadyExists e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceDoesNotExist e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } } // TODO svn mv @@ -967,7 +1215,15 @@ * trashFileDir = new File(pathToMediaTrash + "/OLD/" + pageName); * if (!trashFileDir.exists()) { trashFileDir.mkdirs(); } */ - pageFile = pagesManager.getNode(historyDirName); + try { + pageFile = pagesManager.getNode(historyDirName); + } catch (RepositoryException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceDoesNotExist e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } try { pageTrashFile = pagesManager.getDirectory("").newNode( @@ -986,8 +1242,20 @@ historyFound = true; } catch (ResourceAlreadyExists ee) { // continue looking + } catch (RepositoryException ee) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceDoesNotExist ee) { + // TODO Auto-generated catch block + e.printStackTrace(); } } + } catch (RepositoryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ResourceDoesNotExist e) { + // TODO Auto-generated catch block + e.printStackTrace(); } // TODO move page ! @@ -1029,8 +1297,19 @@ try { trashFileDir = attManager.getDirectory(pageName + "-att/"); } catch (ResourceDoesNotExist e) { - trashFileDir = attManager.getDirectory("").newDirectory( - pageName + "-att/"); + try { + trashFileDir = attManager.getDirectory("").newDirectory( + pageName + "-att/"); + } catch (RepositoryException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceAlreadyExists e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceDoesNotExist e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } } // moving file directory @@ -1087,7 +1366,18 @@ try { trashFileDir = attManager.getDirectory(pageName); } catch (ResourceDoesNotExist e) { - trashFileDir = attManager.getDirectory("").newDirectory(pageName); + try { + trashFileDir = attManager.getDirectory("").newDirectory(pageName); + } catch (RepositoryException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceAlreadyExists e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ResourceDoesNotExist e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } } // moving file directory Modified: trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/plugins/AttachementInfoPlugin.java =================================================================== --- trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/plugins/AttachementInfoPlugin.java 2005-11-16 21:58:49 UTC (rev 1579) +++ trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/plugins/AttachementInfoPlugin.java 2005-11-16 22:21:08 UTC (rev 1580) @@ -49,7 +49,7 @@ Integer.valueOf((String) rollbackToVer)); wikiEngine.addAttachment( wikiAttachment.getInputStream(), attachementName, wikiPage, - (String) wikiSession.getAttribute("user")); + ((Credentials) wikiSession.getAttribute("credentials")).getName()); } history.append("<h3>History of file: ").append(attachementName).append( Added: trunk/forge/portal-extensions/jbosswiki/wiki-common/src/test/java/org/jboss/wiki/test/CheckContentTest.java =================================================================== --- trunk/forge/portal-extensions/jbosswiki/wiki-common/src/test/java/org/jboss/wiki/test/CheckContentTest.java 2005-11-16 21:58:49 UTC (rev 1579) +++ trunk/forge/portal-extensions/jbosswiki/wiki-common/src/test/java/org/jboss/wiki/test/CheckContentTest.java 2005-11-16 22:21:08 UTC (rev 1580) @@ -0,0 +1,35 @@ +package org.jboss.wiki.test; + +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.jboss.wiki.WikiContext; +import org.jboss.wiki.WikiPage; + + +public class CheckContentTest extends WikiTest { + + private static final String PATTERN = "<i>INSIDE PLUGIN ERROR:.*</i>"; + + public void testNotExisitngInsidePlugins() { + // this test doesn't fail but only generates list of pages that use improper INSIDE PLUGINS + + Set<String> pageNames = wikiEngine.getAllPageNames(); + + WikiContext context = new WikiContext(plainUser, wikiEngine.getWikiType("html"),testWikiSession); + + for (String pageName : pageNames) { + WikiPage page = wikiEngine.getByName(pageName, context); + Matcher matcher = Pattern.compile(PATTERN).matcher(page.getContent()); + + while (matcher.find()) { + String reason = page.getContent().substring(matcher.start(), matcher.end()); + + reason.substring("<i>".length(), reason.length() - "</i>".length()); + + System.out.println("Found insidePlugin bug in page: "+pageName+" reason: "+reason); + } + } + } +} |
Author: adamw Date: 2005-11-16 16:58:49 -0500 (Wed, 16 Nov 2005) New Revision: 1579 Added: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/LastModificationTest.java Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn-service/src/java/org/jboss/shotoku/svn/service/SvnRepository.java Log: Last mod fix and test Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn-service/src/java/org/jboss/shotoku/svn/service/SvnRepository.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn-service/src/java/org/jboss/shotoku/svn/service/SvnRepository.java 2005-11-16 21:32:28 UTC (rev 1578) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn-service/src/java/org/jboss/shotoku/svn/service/SvnRepository.java 2005-11-16 21:58:49 UTC (rev 1579) @@ -313,18 +313,22 @@ public long getLastModification(String path) throws SvnOperationFailed { + File file = new File(getFileSystemPath(path)); + try { - File file = new File(getFileSystemPath(path)); - if (ourClientManager.getStatusClient().doStatus( file, false).getContentsStatus() != SVNStatusType.STATUS_NORMAL) return file.lastModified(); - else - return ourClientManager.getWCClient().doInfo(file, + } catch (SVNException e) { + return file.lastModified(); + } + + try { + return ourClientManager.getWCClient().doInfo(file, SVNRevision.WORKING).getCommittedDate().getTime(); } catch (SVNException e) { - throw new SvnOperationFailed(e); + return file.lastModified(); } } } Added: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/LastModificationTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/LastModificationTest.java 2005-11-16 21:32:28 UTC (rev 1578) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/LastModificationTest.java 2005-11-16 21:58:49 UTC (rev 1579) @@ -0,0 +1,56 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.shotoku.test; + +import org.jboss.shotoku.Directory; +import org.jboss.shotoku.Node; + +/** + * + * @author adamw + */ +public class LastModificationTest extends ShotokuTest { + private final static String TEST_DIR = "last-mod-test"; + @Override + protected void setUp() throws Exception { + Directory d = cm.getRootDirectory().newDirectory(TEST_DIR); + d.save(TEST_DIR); + } + + public void testLastModInNewDir() throws Exception { + // Creating a new directory. + Directory newDir = cm.getRootDirectory().getDirectory(TEST_DIR).newDirectory("test"); + newDir.save(""); + + // Creating a new node. + Node newNode = cm.getRootDirectory().getDirectory(TEST_DIR).getDirectory("test").newNode("testn"); + newNode.save(""); + + // Invoking getting of last modification. + cm.getRootDirectory().getDirectory(TEST_DIR).getDirectory("test").getNode("testn").getLastModification(); + } + + @Override + protected void tearDown() throws Exception { + cm.getDirectory(TEST_DIR).delete(); + } +} |
Author: adamw Date: 2005-11-16 16:32:28 -0500 (Wed, 16 Nov 2005) New Revision: 1578 Modified: trunk/forge/portal-extensions/forge-ads/src/java/org/jbosslabs/portlet/ads/AdsPortlet.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/FilesFromRepoFilter.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/portlet/ContentPortlet.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/XmlInputFactory.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/service/ResourceWatcher.java trunk/forge/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConServer.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/exceptions/ResourceAlreadyExists.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/exceptions/ResourceDoesNotExist.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/DirectoryIncludeParameter.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/HistoryIncludeParameter.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/Search.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/SearchParameter.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/velocity/ShotokuResourceLoader.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnDirectory.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHeadNode.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewDirectoryHelper.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNodeHelper.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewResourceHelper.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/AddDeleteTest.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ContentSettingTest.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/HistoryTest.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/LogMessageTest.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ModifyContentTest.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ParentTest.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/PropertiesTest.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ResourceInjectTest.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SimpleDirectoryTest.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/servlet/ShotokuServlet.java Log: Shotoku exceptions runtime --> normal. Modified: trunk/forge/portal-extensions/forge-ads/src/java/org/jbosslabs/portlet/ads/AdsPortlet.java =================================================================== --- trunk/forge/portal-extensions/forge-ads/src/java/org/jbosslabs/portlet/ads/AdsPortlet.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/forge-ads/src/java/org/jbosslabs/portlet/ads/AdsPortlet.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -27,6 +27,8 @@ import org.jboss.forge.common.portlet.ContentPortlet; import org.jboss.portal.core.servlet.jsp.PortalJsp; import org.jboss.portal.common.context.DelegateContext; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; + import java.io.IOException; import javax.portlet.*; @@ -46,7 +48,12 @@ protected Object generateContent(JBossRenderRequest rReq, String portalName) throws IOException { - String content = readFile(portalName+"/ads/ads.txt"); + String content; + try { + content = readFile(portalName+"/ads/ads.txt"); + } catch (ResourceDoesNotExist e) { + content = "Error reading node."; + } //System.out.println("ADS.TXT content "+ content); String[] data = parse(content); DelegateContext root = new DelegateContext(); Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/FilesFromRepoFilter.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/FilesFromRepoFilter.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/FilesFromRepoFilter.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -30,6 +30,7 @@ import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.Node; import org.jboss.shotoku.aop.Inject; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * A filter for reading JSP (and html, text etc) files from a file repository @@ -89,7 +90,12 @@ .indexOf(ForgeHelper.REPO_ACCESS_DIR) + repoAccessDirLength + 1); - Node requestedNode = contentManager.getNode(requestedFile); + Node requestedNode; + try { + requestedNode = contentManager.getNode(requestedFile); + } catch (ResourceDoesNotExist e) { + throw new ServletException(e); + } if (requestedFile.toLowerCase().endsWith("jsp")) { // If the requested page is a jsp, then we copy it and dispatch // a request for it Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/portlet/ContentPortlet.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/portlet/ContentPortlet.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/portlet/ContentPortlet.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -28,6 +28,7 @@ import org.jboss.portlet.JBossRenderRequest; import org.jboss.portlet.JBossRenderResponse; import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; import javax.portlet.*; @@ -172,8 +173,10 @@ * Name of the file to read. * @return Content of the demanded file. * @throws IOException + * @throws ResourceDoesNotExist + * @throws */ - public String readFile(String filename) throws IOException { + public String readFile(String filename) throws IOException, ResourceDoesNotExist { return cm.getNode(filename).getContent(); } Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -35,6 +35,7 @@ import org.jboss.forge.common.XmlTools; import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.Directory; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -151,7 +152,13 @@ Map<String,org.jboss.shotoku.Node> nodes = new Hashtable<String,org.jboss.shotoku.Node>(); // Getting the members dir. - Directory membersDir = contentManager.getDirectory(portalName+File.separator+ProjectsHelper.MEMBERS_DIR); + Directory membersDir; + try { + membersDir = contentManager.getDirectory(portalName+File.separator+ProjectsHelper.MEMBERS_DIR); + } catch (ResourceDoesNotExist e) { + // TODO + return null; + } // Getting all projects dirs in members directory. List<Directory> membersProjectDirs = membersDir.getDirectories(); @@ -160,7 +167,13 @@ for (org.jboss.shotoku.Node n:projectDir.getNodes().toList()) { // Checking if node is a node containing download counter descriptor. if (n.getName().compareTo(ProjectsHelper.DOWNLOADCOUNTER_DESC)==0) { - org.jboss.shotoku.Node counter = projectDir.getNode(ProjectsHelper.DOWNLOADCOUNTER_DESC); + org.jboss.shotoku.Node counter; + try { + counter = projectDir.getNode(ProjectsHelper.DOWNLOADCOUNTER_DESC); + } catch (ResourceDoesNotExist e) { + // TODO + return null; + } String projectId = projectDir.getName(); nodes.put(projectId,counter); break; Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/XmlInputFactory.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/XmlInputFactory.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/XmlInputFactory.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -85,7 +85,11 @@ * @return Length of the given resource. */ public long getLength(String identifier) { - return cm.getNode(identifier).getLength(); + try { + return cm.getNode(identifier).getLength(); + } catch (ResourceDoesNotExist e) { + return 0; + } } /** @@ -97,7 +101,11 @@ * @return Last modification time of the given resource. */ public long getLastModification(String identifier) { - return cm.getNode(identifier).getLastModification(); + try { + return cm.getNode(identifier).getLastModification(); + } catch (ResourceDoesNotExist e) { + return 0; + } } public static XmlInputFactory getContentReadingInstance(ContentManager cm) { Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/service/ResourceWatcher.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/service/ResourceWatcher.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/service/ResourceWatcher.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -25,6 +25,7 @@ import java.util.Map; import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * @author adamw @@ -46,7 +47,11 @@ * @param name Name of the resouce to add. */ public void watchResource(String name) { - lastUpdates.put(name, cm.getNode(name).getLastModification()); + try { + lastUpdates.put(name, cm.getNode(name).getLastModification()); + } catch (ResourceDoesNotExist e) { + // Just not adding. + } } /** @@ -57,7 +62,14 @@ public boolean checkResources() { boolean ret = false; for (String name : lastUpdates.keySet()) { - long lastModification = cm.getNode(name).getLastModification(); + long lastModification; + try { + lastModification = cm.getNode(name).getLastModification(); + } catch (ResourceDoesNotExist e) { + // Not checking. + continue; + } + if (lastModification != lastUpdates.get(name)) { ret = true; lastUpdates.put(name, lastModification); Modified: trunk/forge/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConServer.java =================================================================== --- trunk/forge/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConServer.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConServer.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -39,6 +39,7 @@ import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.Node; import org.jboss.shotoku.aop.Inject; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; import org.xml.sax.InputSource; /** @@ -182,7 +183,13 @@ try { // Values ok, adding application. - Node confirmed = cm.getNode(getConfirmedFilePath()); + Node confirmed; + try { + confirmed = cm.getNode(getConfirmedFilePath()); + } catch (ResourceDoesNotExist e) { + // Nothing to do here ... + throw new RuntimeException(e); + } String content = confirmed.getContent(); String newContent = ForgeHelper.replace(content, Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -95,7 +95,7 @@ * Search to perform. * @return A node list that is the result of the search. */ - public NodeList search(Search search) { + public NodeList search(Search search) throws ResourceDoesNotExist { return search.perform(this); } Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/exceptions/ResourceAlreadyExists.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/exceptions/ResourceAlreadyExists.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/exceptions/ResourceAlreadyExists.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -24,7 +24,7 @@ /** * @author Adam Warski (ad...@as...) */ -public class ResourceAlreadyExists extends RuntimeException { +public class ResourceAlreadyExists extends Exception { public ResourceAlreadyExists(String msg) { super(msg); } Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/exceptions/ResourceDoesNotExist.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/exceptions/ResourceDoesNotExist.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/exceptions/ResourceDoesNotExist.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -24,7 +24,7 @@ /** * @author Adam Warski (ad...@as...) */ -public class ResourceDoesNotExist extends RuntimeException { +public class ResourceDoesNotExist extends Exception { public ResourceDoesNotExist(String msg) { super(msg); } Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/DirectoryIncludeParameter.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/DirectoryIncludeParameter.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/DirectoryIncludeParameter.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -26,6 +26,7 @@ import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.Directory; import org.jboss.shotoku.NodeList; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * A search parameter which includes to the result all nodes from a directory. @@ -43,7 +44,7 @@ this.path = params.get("path"); } - public NodeList transform(NodeList list, ContentManager cm) { + public NodeList transform(NodeList list, ContentManager cm) throws ResourceDoesNotExist { if (path == null) { list.addAll(directory.getNodes()); } else { Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/HistoryIncludeParameter.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/HistoryIncludeParameter.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/HistoryIncludeParameter.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -27,6 +27,7 @@ import org.jboss.shotoku.History; import org.jboss.shotoku.Node; import org.jboss.shotoku.NodeList; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * A search parameter which includes to the result all nodes from the @@ -49,7 +50,7 @@ this.path = params.get("path"); } - public NodeList transform(NodeList list, ContentManager cm) { + public NodeList transform(NodeList list, ContentManager cm) throws ResourceDoesNotExist { if (path == null) { list.addAll(history.getAllRevisions()); } else { Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/Search.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/Search.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/Search.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -26,6 +26,7 @@ import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.NodeList; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * A class representing a search or a sub-search. @@ -42,7 +43,7 @@ searchParametersStack.add(parameter); } - public NodeList perform(ContentManager cm) { + public NodeList perform(ContentManager cm) throws ResourceDoesNotExist { NodeList list = new NodeList(); for (SearchParameter parameter : searchParametersStack) { list = parameter.transform(list, cm); @@ -51,7 +52,7 @@ return list; } - public NodeList transform(NodeList list, ContentManager cm) { + public NodeList transform(NodeList list, ContentManager cm) throws ResourceDoesNotExist { list.addAll(perform(cm)); return list; } Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/SearchParameter.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/SearchParameter.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/search/SearchParameter.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -23,10 +23,11 @@ import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.NodeList; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * @author Adam Warski (ad...@as...) */ public interface SearchParameter { - public NodeList transform(NodeList list, ContentManager cm); + public NodeList transform(NodeList list, ContentManager cm) throws ResourceDoesNotExist; } Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/velocity/ShotokuResourceLoader.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/velocity/ShotokuResourceLoader.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/velocity/ShotokuResourceLoader.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -28,6 +28,7 @@ import org.apache.velocity.runtime.resource.Resource; import org.apache.velocity.runtime.resource.loader.ResourceLoader; import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * @author Adam Warski (ad...@as...) @@ -55,17 +56,29 @@ @Override public InputStream getResourceStream(String resource) throws ResourceNotFoundException { - return cm.getNode(resource).getContentInputStream(); + try { + return cm.getNode(resource).getContentInputStream(); + } catch (ResourceDoesNotExist e) { + throw new ResourceNotFoundException(e.getMessage()); + } } @Override public boolean isSourceModified(Resource resource) { - return resource.getLastModified() != cm.getNode(resource.getName()).getLastModification(); + try { + return resource.getLastModified() != cm.getNode(resource.getName()).getLastModification(); + } catch (ResourceDoesNotExist e) { + return false; + } } @Override public long getLastModified(Resource resource) { - return cm.getNode(resource.getName()).getLastModification(); + try { + return cm.getNode(resource.getName()).getLastModification(); + } catch (ResourceDoesNotExist e) { + return 0; + } } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -130,11 +130,16 @@ @Override public Directory getRootDirectory() { - return getDirectory(""); + try { + return getDirectory(""); + } catch (ResourceDoesNotExist e) { + // Impossible. + return null; + } } @Override - public Node getNode(String path) { + public Node getNode(String path) throws ResourceDoesNotExist { File file = getFileForPath(path); if (!file.isFile()) @@ -145,7 +150,7 @@ } @Override - public Directory getDirectory(String path) { + public Directory getDirectory(String path) throws ResourceDoesNotExist { File file = getFileForPath(path); if (!file.isDirectory()) Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnDirectory.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnDirectory.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnDirectory.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -124,7 +124,7 @@ return new SvnDirectory(id, reqFullPath, reqDir, svnCm); } - public Node newNode(String name) { + public Node newNode(String name) throws ResourceAlreadyExists { String childFullPath = fullPath + '/' + name; try { @@ -143,7 +143,7 @@ } } - public Directory newDirectory(String name) throws RepositoryException { + public Directory newDirectory(String name) throws RepositoryException, ResourceAlreadyExists { String childFullPath = fullPath + '/' + name; try { service.synchronizeWithWriteLock(id, childFullPath); Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHeadNode.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHeadNode.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHeadNode.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -76,7 +76,6 @@ return content.asString(); } - public byte[] getContentByteArray() { if (content == null) { try { Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewDirectoryHelper.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewDirectoryHelper.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewDirectoryHelper.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -49,7 +49,11 @@ } protected AbstractResource getNormalResource() { - currentDirectory = parentDirectory.getDirectory(name); + try { + currentDirectory = parentDirectory.getDirectory(name); + } catch (ResourceDoesNotExist e) { + // Impossible. + } return currentDirectory; } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNodeHelper.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNodeHelper.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNodeHelper.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -31,6 +31,7 @@ import org.jboss.shotoku.History; import org.jboss.shotoku.Node; import org.jboss.shotoku.exceptions.RepositoryException; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * @author Adam Warski (ad...@as...) @@ -48,7 +49,12 @@ } protected AbstractResource getNormalResource() { - currentNode = parentDirectory.getNode(name); + try { + currentNode = parentDirectory.getNode(name); + } catch (ResourceDoesNotExist e) { + // Impossible. + } + return currentNode; } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewResourceHelper.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewResourceHelper.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewResourceHelper.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -24,6 +24,7 @@ import org.jboss.shotoku.AbstractResource; import org.jboss.shotoku.Directory; import org.jboss.shotoku.exceptions.RepositoryException; +import org.jboss.shotoku.exceptions.ResourceAlreadyExists; import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** @@ -55,7 +56,11 @@ try { lastParent = lastParent.getDirectory(nameParts[i]); } catch (ResourceDoesNotExist e) { - lastParent = lastParent.newDirectory(nameParts[i]); + try { + lastParent = lastParent.newDirectory(nameParts[i]); + } catch (ResourceAlreadyExists e1) { + // Impossible. + } lastParent.save(logMessage); } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/AddDeleteTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/AddDeleteTest.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/AddDeleteTest.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -22,6 +22,7 @@ package org.jboss.shotoku.test; import org.jboss.shotoku.Node; +import org.jboss.shotoku.exceptions.ResourceAlreadyExists; import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** @@ -42,7 +43,7 @@ } } - public void testDeleteWithoutSave() { + public void testDeleteWithoutSave() throws ResourceAlreadyExists, ResourceDoesNotExist { Node n = cm.getRootDirectory().newNode(TEST_FILE); checkTestFileNotExists(); @@ -52,7 +53,7 @@ checkTestFileNotExists(); } - public void testDeleteWithSaveImmediate() { + public void testDeleteWithSaveImmediate() throws ResourceAlreadyExists, ResourceDoesNotExist { Node n = cm.getRootDirectory().newNode(TEST_FILE); checkTestFileNotExists(); @@ -71,7 +72,7 @@ checkTestFileNotExists(); } - public void testDeleteWithSaveDelayed() { + public void testDeleteWithSaveDelayed() throws ResourceAlreadyExists, ResourceDoesNotExist { Node n = cm.getRootDirectory().newNode(TEST_FILE); checkTestFileNotExists(); @@ -104,7 +105,7 @@ checkTestFileNotExists(); } - public void testAddAfterDelete() { + public void testAddAfterDelete() throws ResourceAlreadyExists, ResourceDoesNotExist { // Adding and deleting Node n = cm.getRootDirectory().newNode(TEST_FILE); n.save(TEST_FILE); Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ContentSettingTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ContentSettingTest.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ContentSettingTest.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -25,6 +25,8 @@ import java.util.Arrays; import org.jboss.shotoku.Node; +import org.jboss.shotoku.exceptions.ResourceAlreadyExists; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * @author Adam Warski (ad...@as...) @@ -47,7 +49,7 @@ assertTrue(Arrays.equals(content.getBytes(), n.getContentByteArray())); } - public void testString() { + public void testString() throws ResourceAlreadyExists, ResourceDoesNotExist { // Getting the test node. Node n = cm.getNode(TEST_FILE); @@ -60,7 +62,7 @@ assertNodeContent(cm.getRootDirectory().getNode(TEST_FILE), TEST_CONTENT); } - public void testByteArray() { + public void testByteArray() throws ResourceAlreadyExists, ResourceDoesNotExist{ // Getting the test node. Node n = cm.getNode(TEST_FILE); @@ -73,7 +75,7 @@ assertNodeContent(cm.getRootDirectory().getNode(TEST_FILE), TEST_CONTENT_2); } - public void testOutputStream() throws IOException { + public void testOutputStream() throws ResourceAlreadyExists, ResourceDoesNotExist, IOException { // Getting the test node. Node n = cm.getNode(TEST_FILE); Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/HistoryTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/HistoryTest.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/HistoryTest.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -23,6 +23,8 @@ import org.jboss.shotoku.History; import org.jboss.shotoku.Node; +import org.jboss.shotoku.exceptions.ResourceAlreadyExists; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * @author Adam Warski (ad...@as...) @@ -37,7 +39,7 @@ n.save(TEST_FILE); } - public void testHistoryLengthThree() { + public void testHistoryLengthThree() throws ResourceAlreadyExists, ResourceDoesNotExist { Node n = cm.getRootDirectory().getNode(TEST_FILE); // First making a history for the test file. Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/LogMessageTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/LogMessageTest.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/LogMessageTest.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -23,6 +23,7 @@ import org.jboss.shotoku.Directory; import org.jboss.shotoku.Node; +import org.jboss.shotoku.exceptions.ResourceAlreadyExists; import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** @@ -33,7 +34,7 @@ private final static String TEST_FILE = "log-message-test-1"; private final static String TEST_DIR = "log-message-test-2"; - public void testNodeLogMessage() { + public void testNodeLogMessage() throws ResourceAlreadyExists, ResourceDoesNotExist { // Creating a new node. Node n = cm.getRootDirectory().newNode(TEST_FILE); @@ -50,7 +51,7 @@ assertNull(n.getLogMessage()); } - public void testDirectoryLogMessage() { + public void testDirectoryLogMessage() throws ResourceAlreadyExists, ResourceDoesNotExist { // Creating a new directory. Directory d = cm.getRootDirectory().newDirectory(TEST_DIR); Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ModifyContentTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ModifyContentTest.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ModifyContentTest.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -22,6 +22,8 @@ package org.jboss.shotoku.test; import org.jboss.shotoku.Node; +import org.jboss.shotoku.exceptions.ResourceAlreadyExists; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * @author Adam Warski (ad...@as...) @@ -40,7 +42,7 @@ n.save(TEST_FILE); } - public void testOneContentChange() { + public void testOneContentChange() throws ResourceAlreadyExists, ResourceDoesNotExist { // Getting the test node. Node n = cm.getNode(TEST_FILE); @@ -64,7 +66,7 @@ TEST_FILE).getContent())); } - public void testTwoContentChange() { + public void testTwoContentChange() throws ResourceAlreadyExists, ResourceDoesNotExist { Node n = cm.getNode(TEST_FILE); Node n2 = cm.getNode(TEST_FILE); Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ParentTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ParentTest.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ParentTest.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -22,6 +22,8 @@ package org.jboss.shotoku.test; import org.jboss.shotoku.Directory; +import org.jboss.shotoku.exceptions.ResourceAlreadyExists; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * @author Adam Warski (ad...@as...) @@ -32,7 +34,7 @@ private final static String TEST_DIR2 = "parent-test-2"; private final static String TEST_DIR3 = "parent-test-3"; - public void testThreeLevelParents() { + public void testThreeLevelParents() throws ResourceAlreadyExists, ResourceDoesNotExist { // First creating a simple directory structure. Directory new1 = cm.getRootDirectory().newDirectory(TEST_DIR1); new1.save(TEST_DIR1); Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/PropertiesTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/PropertiesTest.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/PropertiesTest.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -22,6 +22,8 @@ package org.jboss.shotoku.test; import org.jboss.shotoku.Node; +import org.jboss.shotoku.exceptions.ResourceAlreadyExists; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * @author Adam Warski (ad...@as...) @@ -39,7 +41,7 @@ n.save(TEST_FILE); } - public void testOnePropertyChange() { + public void testOnePropertyChange() throws ResourceAlreadyExists, ResourceDoesNotExist { // Getting the test node. Node n = cm.getNode(TEST_FILE); @@ -62,7 +64,7 @@ PROP_NAME))); } - public void testTwoPropertyChange() { + public void testTwoPropertyChange() throws ResourceAlreadyExists, ResourceDoesNotExist { // Getting the test nodes. Node n = cm.getNode(TEST_FILE); Node n2 = cm.getNode(TEST_FILE); @@ -86,7 +88,7 @@ } @Override - protected void tearDown() throws Exception { + protected void tearDown() throws ResourceAlreadyExists, ResourceDoesNotExist { cm.getNode(TEST_FILE).delete(); } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ResourceInjectTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ResourceInjectTest.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ResourceInjectTest.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -25,6 +25,8 @@ import org.jboss.shotoku.Node; import org.jboss.shotoku.aop.DirectoryInject; import org.jboss.shotoku.aop.NodeInject; +import org.jboss.shotoku.exceptions.ResourceAlreadyExists; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * @author Adam Warski (ad...@as...) @@ -37,7 +39,7 @@ private final static String TEST_TEXT_2 = "text2"; private final static String TEST_LOG = "log"; - public void setUp() { + public void setUp() throws ResourceAlreadyExists, ResourceDoesNotExist { Node testNode = cm.getRootDirectory().newNode(TEST_NODE); testNode.setContent(TEST_TEXT); testNode.save(TEST_LOG); @@ -55,14 +57,14 @@ @NodeInject(SHOTOKU_TEST_DIR + "/" + TEST_NODE) private String injectedString; - public void testInjects() { + public void testInjects() throws ResourceAlreadyExists, ResourceDoesNotExist { assertTrue(TEST_TEXT.equals(injectedString)); assertTrue(TEST_TEXT.equals(injectedNode.getContent())); assertTrue(TEST_LOG.equals(injectedNode.getLogMessage())); assertTrue(TEST_LOG.equals(injectedDir.getLogMessage())); } - public void testContentChange() { + public void testContentChange() throws ResourceAlreadyExists, ResourceDoesNotExist { injectedNode.setContent(TEST_TEXT_2); injectedNode.save(TEST_LOG); @@ -71,7 +73,7 @@ assertTrue(TEST_TEXT_2.equals(cm.getNode(TEST_NODE).getContent())); } - public void tearDown() { + public void tearDown() throws ResourceAlreadyExists, ResourceDoesNotExist { cm.getNode(TEST_NODE).delete(); cm.getDirectory(TEST_DIR).delete(); } Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SimpleDirectoryTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SimpleDirectoryTest.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SimpleDirectoryTest.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -23,6 +23,7 @@ import org.jboss.shotoku.Directory; import org.jboss.shotoku.Node; +import org.jboss.shotoku.exceptions.ResourceAlreadyExists; import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** @@ -30,7 +31,7 @@ * @author Damon Sicore (da...@si...) */ public class SimpleDirectoryTest extends ShotokuTest { - public void testAddDeleteDirectory() { + public void testAddDeleteDirectory() throws ResourceAlreadyExists, ResourceDoesNotExist { // Creating the directory. Directory newDir = cm.getRootDirectory().newDirectory("new-dir-test"); @@ -52,7 +53,7 @@ "new-dir-test/node2").getContent())); } - public void testNames() { + public void testNames() throws ResourceAlreadyExists, ResourceDoesNotExist { // Checking name of the root directory. assertTrue("".equals(cm.getRootDirectory().getName())); @@ -77,7 +78,7 @@ } @Override - protected void tearDown() { + protected void tearDown() throws ResourceAlreadyExists, ResourceDoesNotExist { try { Directory newDir = cm.getDirectory("new-dir-test"); newDir.delete(); Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -24,6 +24,8 @@ import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.Directory; import org.jboss.shotoku.Node; +import org.jboss.shotoku.exceptions.ResourceAlreadyExists; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * @author Adam Warski (ad...@as...) @@ -35,11 +37,11 @@ private final static String TEST_NESTED_NODE = "h/j/k"; private final static String TEST_CONTENT = "T"; - public void setUp() { + public void setUp() throws ResourceAlreadyExists, ResourceDoesNotExist { cm.getRootDirectory().newDirectory(TEST_DIR).save(TEST_DIR); } - public void testNested() { + public void testNested() throws ResourceAlreadyExists, ResourceDoesNotExist { Directory base = cm.getDirectory(TEST_DIR); Directory nested1 = base.newDirectory(TEST_NESTED_DIR); Node nested2 = base.newNode(TEST_NESTED_NODE); @@ -61,7 +63,7 @@ assertTrue(TEST_CONTENT.equals(base.getNode(TEST_NESTED_NODE).getContent())); } - public void testNestedExisting() { + public void testNestedExisting() throws ResourceAlreadyExists, ResourceDoesNotExist { Directory base = cm.getDirectory(TEST_DIR); base.newDirectory("h").save("h"); @@ -79,7 +81,7 @@ /** * Checks if content managers work with prefixes that contain unnecessary /. */ - public void testSlashesInCmPrefix() { + public void testSlashesInCmPrefix() throws ResourceAlreadyExists, ResourceDoesNotExist { ContentManager cm1 = ContentManager.getContentManager("/shotoku-test/"); cm1.getRootDirectory().getDirectory(TEST_DIR); @@ -88,7 +90,7 @@ cm2.getRootDirectory(); } - public void tearDown() { + public void tearDown() throws ResourceAlreadyExists, ResourceDoesNotExist { cm.getDirectory(TEST_DIR).delete(); } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/servlet/ShotokuServlet.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/servlet/ShotokuServlet.java 2005-11-16 19:29:14 UTC (rev 1577) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/servlet/ShotokuServlet.java 2005-11-16 21:32:28 UTC (rev 1578) @@ -1,6 +1,5 @@ package org.jboss.shotoku.test.servlet; -import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; @@ -10,9 +9,9 @@ import javax.servlet.http.HttpServletResponse; import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.Directory; import org.jboss.shotoku.Node; import org.jboss.shotoku.aop.Inject; -import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * @author Adam Warski (ad...@as...) @@ -31,21 +30,31 @@ @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - response.setContentType("text/html"); - PrintWriter pw = response.getWriter(); - pw.write("Depends test: " + test + "<br />"); - pw.write("<br />"); - - Node n; try { - n = test.getNode("image.png"); - } catch (ResourceDoesNotExist e) { - n = test.getRootDirectory().newNode("image.png"); + response.setContentType("text/html"); + PrintWriter pw = response.getWriter(); + pw.write("Depends test: " + test + "<br />"); + pw.write("<br />"); + + try { + Directory d = test.getRootDirectory().newDirectory("Z"); + d.save(""); + + test.getRootDirectory().newNode("BB").save(""); + + d = test.getDirectory("Z"); + Node n = d.newNode("A"); + n.save("C"); + + test.getRootDirectory().getNode("BB").getLastModification(); + d.getNode("A").getLastModification(); + } finally { + test.getDirectory("Z").delete(); + } + } catch (Exception e) { + throw new ServletException(e); } - n.setContent(new FileInputStream("/home/adamw/downloads/image.png")); - n.save(""); - //NodeList nl = new NodeList(); //pw.write(nl.getFeed("default/feeds/templates/hello-world.vm", null, new HashMap<String, Object>()).toString()); |
From: <jbo...@li...> - 2005-11-16 19:29:41
|
Author: aron.gombas Date: 2005-11-16 14:29:14 -0500 (Wed, 16 Nov 2005) New Revision: 1577 Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java Log: Javadoc tags fixed Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java 2005-11-16 19:28:29 UTC (rev 1576) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java 2005-11-16 19:29:14 UTC (rev 1577) @@ -83,7 +83,7 @@ /** * Stores the passed stream to an implementation-dependent "storage". - * @returns the absolute URL that points to the resulted file. + * @return the absolute URL that points to the resulted file. */ protected String storeFile(String fileName, InputStream in) { try { Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java 2005-11-16 19:28:29 UTC (rev 1576) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java 2005-11-16 19:29:14 UTC (rev 1577) @@ -19,7 +19,7 @@ public interface CachedDataStore { /** * Stores the passed stream to an implementation-dependent "storage". - * @returns the absolute URL that points to the resulted file. + * @return the absolute URL that points to the resulted file. */ public String storeFile(String fileName, InputStream in) throws Exception; // TODO exception? } |
From: <jbo...@li...> - 2005-11-16 19:28:48
|
Author: aron.gombas Date: 2005-11-16 14:28:29 -0500 (Wed, 16 Nov 2005) New Revision: 1576 Modified: trunk/labs/kosmos/build/kosmos-project.properties Log: Verno inced Modified: trunk/labs/kosmos/build/kosmos-project.properties =================================================================== --- trunk/labs/kosmos/build/kosmos-project.properties 2005-11-15 22:14:10 UTC (rev 1575) +++ trunk/labs/kosmos/build/kosmos-project.properties 2005-11-16 19:28:29 UTC (rev 1576) @@ -1,3 +1,3 @@ project.name=Kosmos project.name.short=kosmos -project.version=0.1.3 +project.version=0.1.4 |
From: <jbo...@li...> - 2005-11-15 22:14:22
|
Author: adamw Date: 2005-11-15 17:14:10 -0500 (Tue, 15 Nov 2005) New Revision: 1575 Removed: trunk/forge/portal-extensions/jboss-as-binaries/to-copy/server/all/deploy/httpha-invoker.sar/ trunk/forge/portal-extensions/jboss-as-binaries/to-copy/server/all/deploy/jmx-console.war/ trunk/forge/portal-extensions/jboss-as-binaries/to-copy/server/all/deploy/management/ Log: http://jira.jboss.com/jira/browse/JBLAB-491 |
From: <jbo...@li...> - 2005-11-15 15:17:41
|
Author: aron.gombas Date: 2005-11-15 10:17:31 -0500 (Tue, 15 Nov 2005) New Revision: 1573 Modified: trunk/labs/kosmos/web-server/WEB-INF/kosmos-services-servlet.xml trunk/labs/kosmos/xdocs/reference/reference-manual.xml Log: Pluggable store documented Modified: trunk/labs/kosmos/web-server/WEB-INF/kosmos-services-servlet.xml =================================================================== --- trunk/labs/kosmos/web-server/WEB-INF/kosmos-services-servlet.xml 2005-11-14 22:14:07 UTC (rev 1572) +++ trunk/labs/kosmos/web-server/WEB-INF/kosmos-services-servlet.xml 2005-11-15 15:17:31 UTC (rev 1573) @@ -46,7 +46,7 @@ <!-- This URL will be used as base URL for the generated images. If you don't specify anything here, the value of "webdavUrl" will be used. Uncomment this, if you want to override that. - <property name="webdavPassword" value="http://myserver/my-webdav/kosmos-images"/> + <property name="clientUrl" value="http://myserver/my-webdav/kosmos-images"/> --> </bean> </beans> Modified: trunk/labs/kosmos/xdocs/reference/reference-manual.xml =================================================================== --- trunk/labs/kosmos/xdocs/reference/reference-manual.xml 2005-11-14 22:14:07 UTC (rev 1572) +++ trunk/labs/kosmos/xdocs/reference/reference-manual.xml 2005-11-15 15:17:31 UTC (rev 1573) @@ -1247,52 +1247,95 @@ <para> - The server component can be easily configured through its own - <filename>web.xml</filename> - and the Spring application context configuration file + The server component can be configured through its Spring application context configuration file <filename>kosmos-services-servlet.xml</filename> - . It's absolutely straightforward to modify both, but + . (Please note that former versions were configurable partly through their + <filename>web.xml</filename>, but after introducing the pluggable + cache store mechanism, all configuration was moved to the Spring + XML.) It's absolutely straightforward to modify it, but please note that the configuration changes might require - reloading the servlet! + reloading the servlet to take effect! + + </para> + + <para> + + Here is some basic help for better understanding of the <filename>kosmos-services-servlet.xml</filename>: <itemizedlist> <listitem> <para> - <filename>web.xml</filename> - : you can specify the WebDAV access here, by defining - three - <literal>context-param</literal> - entities: - <programlisting><context-param> - <param-name>webdav.url</param-name> - <param-value>http://localhost:8080/slide/files</param-value> -</context-param> -<context-param> - <param-name>webdav.user</param-name> - <param-value></param-value> -</context-param> - <context-param> - <param-name>webdav.password</param-name> - <param-value></param-value> -</context-param> -<!-- This URL will be used as base URL for the generated images. - If you don't specify anything here, the value of "webdav.url" - will be used. Uncomment this, if you want to override that. - <context-param> - <param-name>webdav.clientUrl</param-name> - <param-value>http://myserver/my-webdav/kosmos/images</param-value> - </context-param> ---> -</programlisting> - The URL is required, but you can leave the other two - empty if your WebDAV is configured to serve also - unauthenticated requests. In the URL you can use + Each service is implemented by a POJO that is exposed as web service + by a Spring-based Hessian proxy class. Consequently there is one + section like this per service: + <programlisting><!-- CC service --> +<bean id="ccService" class="hu.midori.kosmos.server.cc.CcServiceImpl"/> + <property name="store" ref""webdavCachedDataStore"/> +</bean> +<bean name="/cc-service" class="org.springframework.remoting.caucho.HessianServiceExporter"> + <property name="service" ref="ccService"/> + <property name="serviceInterface" value="hu.midori.kosmos.protocol.CcService"/> +</bean></programlisting> + + You can activate and deactivate the services by adding or deleting + these sections, depending which portlets you're going to use. + In the default configuration, all the services are activated and unless there is a special + reason to remove them, it's better not to touch these sections. + There is hardly any performance penalty or security problem + even if you have unused, but active services. + + </para> + + <para> + + There is one required property for the services: this is called + <literal>store</literal> and it's a reference to the cache store + to use. See next section for more details. + </para> + + </listitem> + + <listitem> + + <para> + + The services can generate and save cached data, mostly images that are later + used by the portlets view tier. There is a simple, but flexible + store mechanism built into Kosmos. However this is a "pluggable" mechanism, + by default, there is only one implementation shipped with Kosmos: + a WebDAV-based cache store. (In the very beginning, using WebDAV for this + purpose was a requirement, not an option, but the poor quality of the WebDAV client libraries + and servers motivated adding an extra level of abstraction to ensure + that with some minimal work, any other web-based store can be used here.) + + </para> + + <para> + + The cache stores are implemented as POJOs, too. They can have different + properties depending on the implementation, we discuss only + <literal>WebdavCachedDataStore</literal> here: + + <programlisting><!-- WebDAV cached data store --> +<bean id="webdavCachedDataStore" class="hu.midori.kosmos.server.WebdavCachedDataStore"> + <property name="webdavUrl" value="http://localhost:8080/slide/files"/><!-- Both HTTP and HTTPS protocol can be used here. --> + <property name="webdavUser" value=""/> + <property name="webdavPassword" value=""/> + <!-- This URL will be used as base URL for the generated images. + If you don't specify anything here, the value of "webdavUrl" + will be used. Uncomment this, if you want to override that. + <property name="clientUrl" value="http://myserver/my-webdav/kosmos-images"/> + --> +</bean></programlisting> + + The URL is required, but you can leave the user and password + empty if your WebDAV is configured to serve + unauthenticated requests, too. In the URL you can use both HTTP and HTTPS protocols. The - <literal>webdav.clientUrl</literal> parameter makes it possible to - override the URLs generated for the clients (primarily - the portlets): you can store the images as + <literal>clientUrl</literal> parameter makes it possible to + override the URLs generated for the clients: you can store the images as <literal>https://secure.mydomain.com/mywebdav</literal>, but access them as <literal>http://public.mydomain.com/webdav</literal> if your network environment is configured to match this. @@ -1300,34 +1343,22 @@ </listitem> - <listitem> - + <listitem> + <para> - - <filename>kosmos-services-servlet.xml</filename> - : you can add and remove Hessian services depending which - portlets you're going to use, specify the URLs for - them and that's it. In the default configuration, - all the services are activated and unless there is a special - reason to remove them, it's better not to touch these sections: - <programlisting><!-- CC service --> -<bean id="ccService" class="hu.midori.kosmos.server.cc.CcServiceImpl"/> -<bean name="/cc-service" class="org.springframework.remoting.caucho.HessianServiceExporter"> - <property name="service" ref="ccService"/> - <property name="serviceInterface" value="hu.midori.kosmos.protocol.CcService"/> -</bean></programlisting> It's possible (and relatively easy) to do more - complicated changes than simply adding or removing - services, but please make sure that you know what you do - and study the related sections of the Spring Framework - documentation. + complicated changes (like using separate or even inhomogenous + cache stores per service, using more than one instance of the + same service, etc.), but please make sure that you know + what you do. It's recommended to study the related sections of the + <ulink url="http://www.springframework.org/documentation">Spring Framework documentation</ulink>, too. </para> </listitem> </itemizedlist> - For better understanding, please take a look at the sample + For better understanding, please take a look at the full sample configuration files shipped in the distributed package. </para> @@ -1615,7 +1646,10 @@ the <literal>AbstractKosmosService</literal> class. This where the initialization and caching is performed. You should start learning the server component code by studying its - javadocs.</para> + javadocs. Also, to understand the cache store mechanism, please + take a look at the <literal>CachedDataStore</literal> interface + and <literal>WebdavCachedDataStore</literal> as a sample + implementation.</para> <para>As the monitored resources and their interfaces vary a lot, there is no uniform way for the concrete services to access them. |
From: <jbo...@li...> - 2005-11-14 22:14:13
|
Author: szimano Date: 2005-11-14 17:14:07 -0500 (Mon, 14 Nov 2005) New Revision: 1572 Modified: trunk/forge/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java Log: http://jira.jboss.com/jira/browse/JBWIKI-68 : redirection for http://localhost/wiki/Wiki.jsp&page=NewPage http://jira.jboss.com/jira/browse/JBWIKI-67 : fruther modifications to ShotokuDataSource (still not working in 100%) Modified: trunk/forge/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java =================================================================== --- trunk/forge/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java 2005-11-14 21:54:43 UTC (rev 1571) +++ trunk/forge/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java 2005-11-14 22:14:07 UTC (rev 1572) @@ -75,6 +75,8 @@ private String wikiHome; private WikiEngine wikiEngine; + + private static final String oldLink = "Wiki.jsp?page="; /* * private ForgeHelper forgeHelper; private ContentManager contentManager; @@ -143,10 +145,16 @@ wikiSession.setAttribute("hostURL", hostURL); String requestURI = httpRequest.getRequestURI(); - + // get off "/wiki/" from the begining requestURI = requestURI.substring("/wiki/".length()); - + + // support old type link with Wiki.jsp?page= + if (requestURI.equals("Wiki.jsp") && httpRequest.getParameter("page") != null) { + httpResponse.sendRedirect(hostURL + wikiHome + "&page=" + httpRequest.getParameter("page")); + return; + } + while (requestURI.endsWith("/")) { // get rid of ending "/" character(s) requestURI = requestURI.substring(0, requestURI.length() - 1); @@ -166,7 +174,7 @@ if ((tokens.length == 1)&&(tokens[0].equals(""))) { //show Main page - as there is no place to go specified :) - httpResponse.sendRedirect(hostURL + wikiHome); + httpResponse.sendRedirect(hostURL + wikiHome ); return; } Modified: trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java =================================================================== --- trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java 2005-11-14 21:54:43 UTC (rev 1571) +++ trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java 2005-11-14 22:14:07 UTC (rev 1572) @@ -35,6 +35,7 @@ import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.Directory; import org.jboss.shotoku.Node; +import org.jboss.shotoku.exceptions.RepositoryException; import org.jboss.shotoku.exceptions.ResourceAlreadyExists; import org.jboss.shotoku.exceptions.ResourceDoesNotExist; import org.jboss.wiki.exceptions.PageRenamingException; @@ -223,13 +224,14 @@ if (pageExists(uid)) { // page exists on // harddisk - add new // version - Properties pageProps = getPageProps(uid); + Node propsNode = getPropsNode(uid); + + Properties pageProps = getPageProps(uid, propsNode); pageProps.setProperty(page.getLastVersion() + ".author", page .getLastAuthor().getName()); - OutputStream os = pagesManager.getNode( - "OLD/" + uid + "/page.properties").getOutputStream(); + OutputStream os = propsNode.getOutputStream(); try { pageProps.store(os, "Saved by ShotokuDataSource of JBoss Wiki"); } catch (Exception e) { @@ -245,6 +247,8 @@ } } + savePageProps(uid, propsNode); + log.info("Opening files"); // File pageFile = new File(pathToMedia + "/OLD/" + uid + "/" + @@ -253,7 +257,7 @@ Node pageFile = pagesManager.getDirectory("").newNode( "OLD/" + uid + "/" + (page.getLastVersion() - 1) + ".txt"); - Node pageOldFile = pagesManager.getDirectory("").newNode( + Node pageOldFile = pagesManager.getNode( uid + ".txt"); OutputStream pageFileWriter; @@ -274,8 +278,6 @@ pageFileWriter.close(); - pageOldFile.delete(); - pageFileWriter = pageOldFile.getOutputStream(); String pageContent = page.getContent(); @@ -286,6 +288,10 @@ pageFileWriter.close(); status = true; + + pageOldFile.save("Adding version "+page.getLastVersion()+" of page "+uid); + pageFile.save("Adding version "+page.getLastVersion()+" of page "+uid); + } catch (IOException ioe) { log.error("[ShotokuDataSource]: Cannot save page: ", ioe); } @@ -326,7 +332,9 @@ pagesManager.getDirectory("").newDirectory(pageDirName); - pageWriter = pagesManager.getNode(uid + ".txt") + Node pageFile = pagesManager.getRootDirectory().newNode(uid + ".txt"); + + pageWriter = pageFile .getOutputStream(); String pageContent = page.getContent(); @@ -338,6 +346,10 @@ pageWriter.close(); status = true; + + newPageFile.save("Adding version "+page.getLastVersion()+" of page "+uid); + pageFile.save("Adding version "+page.getLastVersion()+" of page "+uid); + } catch (Exception e) { log.error("Cannot write new page: ", e); status = false; @@ -354,16 +366,35 @@ return true; } - public Properties getPageProps(String pageName) { + public void savePageProps(String pageName, Node pagePropsNode) { + try { + pagePropsNode.save("Saving page props for page: "+pageName); + } catch (ResourceDoesNotExist e) { + // There is no prop file for some reson - create one. + + getPageProps(pageName, pagePropsNode); + } + } + + private Node getPropsNode(String pageName) { + try { + return pagesManager.getNode( + "OLD/" + pageName + "/page.properties"); + } catch (ResourceDoesNotExist e) { + return null; + } catch (RepositoryException e) { + return null; + } + } + + public Properties getPageProps(String pageName, Node pageNode) { Properties pageProps = new Properties(); try { - InputStream fpi = pagesManager.getNode( - "OLD/" + pageName + "/page.properties") - .getContentInputStream(); + InputStream fpi = pageNode.getContentInputStream(); pageProps.load(fpi); fpi.close(); - } catch (IOException ioe) { + } catch (Exception ioe) { // There is no prop file for some reson - create one. Node pagePropsFile = pagesManager.getDirectory("").newDirectory( @@ -378,6 +409,7 @@ pageProps.setProperty("1.author", "unknown"); pageProps.store(fpo, SAVE_COMMENT); fpo.close(); + pagePropsFile.save("genarating page props for page: "+pageName); } } catch (IOException e) { @@ -447,7 +479,7 @@ try { Node pageFile = pagesManager.getNode(pageName + ".txt"); - Properties pageProps = getPageProps(pageName); + Properties pageProps = getPageProps(pageName, getPropsNode(pageName)); if (pageProps != null) { @@ -602,7 +634,7 @@ } public Credentials getAuthorAtVersion(String pageName, int version) { - return new SimpleCredentials(getPageProps(pageName).getProperty( + return new SimpleCredentials(getPageProps(pageName, getPropsNode(pageName)).getProperty( version + ".author")); } |
From: <jbo...@li...> - 2005-11-14 21:54:49
|
Author: adamw Date: 2005-11-14 16:54:43 -0500 (Mon, 14 Nov 2005) New Revision: 1571 Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectDescriptor.java trunk/forge/portal-extensions/forge-podcast/ trunk/forge/portal-extensions/forge-speller/ Log: Warnings, ignores Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java 2005-11-14 21:44:56 UTC (rev 1570) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java 2005-11-14 21:54:43 UTC (rev 1571) @@ -28,8 +28,6 @@ import java.util.LinkedList; import java.util.List; -import javax.xml.transform.TransformerException; - import org.apache.xerces.parsers.DOMParser; import org.jboss.forge.common.XmlTools; import org.jboss.forge.common.projects.XmlInputFactory.XmlNotFoundException; Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2005-11-14 21:44:56 UTC (rev 1570) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2005-11-14 21:54:43 UTC (rev 1571) @@ -31,8 +31,6 @@ import java.util.Map; import java.util.Set; -import javax.xml.transform.TransformerException; - import org.apache.xerces.parsers.DOMParser; import org.jboss.forge.common.XmlTools; import org.jboss.shotoku.ContentManager; Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectDescriptor.java 2005-11-14 21:44:56 UTC (rev 1570) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectDescriptor.java 2005-11-14 21:54:43 UTC (rev 1571) @@ -52,8 +52,6 @@ private static final Logger log = Logger.getLogger(ProjectDescriptor.class); private DownloadsDescriptor downloads; - - private DownloadCounterDescriptor downloadCounter; private String portalName; Property changes on: trunk/forge/portal-extensions/forge-podcast ___________________________________________________________________ Name: svn:ignore + target Property changes on: trunk/forge/portal-extensions/forge-speller ___________________________________________________________________ Name: svn:ignore + target |
Author: adamw Date: 2005-11-14 16:44:56 -0500 (Mon, 14 Nov 2005) New Revision: 1570 Added: trunk/forge/portal-extensions/forge-kosmos/conf/server/kosmos-services-servlet.xml trunk/forge/portal-extensions/forge-kosmos/src/ trunk/forge/portal-extensions/forge-kosmos/src/java/ trunk/forge/portal-extensions/forge-kosmos/src/java/org/ trunk/forge/portal-extensions/forge-kosmos/src/java/org/jboss/ trunk/forge/portal-extensions/forge-kosmos/src/java/org/jboss/kosmos/ trunk/forge/portal-extensions/forge-kosmos/src/java/org/jboss/kosmos/ShotokuCachedDataStore.java Modified: trunk/forge/portal-extensions/forge-ear/src/META-INF/application.xml trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/FileAccessFilter.java trunk/forge/portal-extensions/forge-kosmos/ trunk/forge/portal-extensions/forge-kosmos/maven.xml trunk/forge/portal-extensions/forge-kosmos/project.xml trunk/forge/portal-extensions/forge-kosmos/to-copy/kosmos-portlet.war trunk/forge/portal-extensions/forge-kosmos/to-copy/kosmos-server.war trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHeadNode.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNode.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/servlet/ShotokuServlet.java Log: http://jira.jboss.com/jira/browse/JBLAB-490 : implementation Modified: trunk/forge/portal-extensions/forge-ear/src/META-INF/application.xml =================================================================== --- trunk/forge/portal-extensions/forge-ear/src/META-INF/application.xml 2005-11-14 21:44:02 UTC (rev 1569) +++ trunk/forge/portal-extensions/forge-ear/src/META-INF/application.xml 2005-11-14 21:44:56 UTC (rev 1570) @@ -15,6 +15,16 @@ </module> <module> <web> + <web-uri>kosmos-portlet.war</web-uri> + </web> + </module> + <module> + <web> + <web-uri>kosmos-server.war</web-uri> + </web> + </module> + <module> + <web> <web-uri>federation-register.war</web-uri> </web> </module> Modified: trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/FileAccessFilter.java =================================================================== --- trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/FileAccessFilter.java 2005-11-14 21:44:02 UTC (rev 1569) +++ trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/FileAccessFilter.java 2005-11-14 21:44:56 UTC (rev 1570) @@ -25,7 +25,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.net.URLDecoder; import javax.servlet.Filter; import javax.servlet.FilterChain; @@ -118,11 +117,6 @@ * want to get the part /path/to/resource. */ String requestedRes = requestURI.split("[/]", 3)[2]; - - // Decoding the requested resource name for kosmos-cache - if (requestedRes.indexOf(KOSMOS_CACHE_ACCESS) != -1) { - requestedRes = URLDecoder.decode(requestedRes, "utf-8"); - } try { // Checking if we can allow access to this resource. @@ -182,6 +176,7 @@ is.close(); } } catch (Exception e1) { + e1.printStackTrace(); response.setContentType("text/html"); response.getWriter().println(ACCESS_DENIED); } Property changes on: trunk/forge/portal-extensions/forge-kosmos ___________________________________________________________________ Name: svn:ignore - target + target .classpath .settings .project Added: trunk/forge/portal-extensions/forge-kosmos/conf/server/kosmos-services-servlet.xml =================================================================== --- trunk/forge/portal-extensions/forge-kosmos/conf/server/kosmos-services-servlet.xml 2005-11-14 21:44:02 UTC (rev 1569) +++ trunk/forge/portal-extensions/forge-kosmos/conf/server/kosmos-services-servlet.xml 2005-11-14 21:44:56 UTC (rev 1570) @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> + +<beans> + <!-- CC service --> + <bean id="ccService" class="hu.midori.kosmos.server.cc.CcServiceImpl"> + <property name="store" ref="shotokuCachedDataStore"/> + </bean> + <bean name="/cc-service" class="org.springframework.remoting.caucho.HessianServiceExporter"> + <property name="service" ref="ccService"/> + <property name="serviceInterface" value="hu.midori.kosmos.protocol.CcService"/> + </bean> + + <!-- JIRA service --> + <bean id="jiraService" class="hu.midori.kosmos.server.jira.JiraServiceImpl"> + <property name="store" ref="shotokuCachedDataStore"/> + </bean> + <bean name="/jira-service" class="org.springframework.remoting.caucho.HessianServiceExporter"> + <property name="service" ref="jiraService"/> + <property name="serviceInterface" value="hu.midori.kosmos.protocol.JiraService"/> + </bean> + + <!-- SF service --> + <bean id="sfService" class="hu.midori.kosmos.server.sf.SfServiceImpl"> + <property name="store" ref="shotokuCachedDataStore"/> + </bean> + <bean name="/sf-service" class="org.springframework.remoting.caucho.HessianServiceExporter"> + <property name="service" ref="sfService"/> + <property name="serviceInterface" value="hu.midori.kosmos.protocol.SfService"/> + </bean> + + <!-- SVN service --> + <bean id="svnService" class="hu.midori.kosmos.server.svn.SvnServiceImpl"> + <property name="store" ref="shotokuCachedDataStore"/> + </bean> + <bean name="/svn-service" class="org.springframework.remoting.caucho.HessianServiceExporter"> + <property name="service" ref="svnService"/> + <property name="serviceInterface" value="hu.midori.kosmos.protocol.SvnService"/> + </bean> + + <!-- Shotoku cached data store --> + <bean id="shotokuCachedDataStore" class="org.jboss.kosmos.ShotokuCachedDataStore"> + <property name="fileAccessUrl" value="http://localhost:8080/file-access"/> + <property name="prefix" value="kosmos/images/kosmos-cache"/> + </bean> +</beans> \ No newline at end of file Modified: trunk/forge/portal-extensions/forge-kosmos/maven.xml =================================================================== --- trunk/forge/portal-extensions/forge-kosmos/maven.xml 2005-11-14 21:44:02 UTC (rev 1569) +++ trunk/forge/portal-extensions/forge-kosmos/maven.xml 2005-11-14 21:44:56 UTC (rev 1570) @@ -13,6 +13,7 @@ </goal> <goal name="build"> + <attainGoal name="java:compile" /> </goal> <goal name="deploy"> @@ -31,13 +32,20 @@ <ant:filename name="**/*" /> </ant:fileset> </ant:copy> + + <!-- Copying cache class --> + <ant:copy todir="target/kosmos-server.war/WEB-INF/classes" overwrite="true"> + <ant:fileset dir="target/classes"> + <ant:filename name="**/*" /> + </ant:fileset> + </ant:copy> <!-- Deleting old deployment --> <ant:delete dir="${local.deploy.dir}/kosmos-server.war" /> <ant:delete dir="${local.deploy.dir}/kosmos-portlet.war" /> <!-- Deploying new packages --> - <ant:copy todir="${local.deploy.dir}" overwrite="true"> + <ant:copy todir="../${forge.ear.dir}/target/${forge.ear.name}" overwrite="true"> <ant:fileset dir="target"> <ant:filename name="**/*" /> </ant:fileset> Modified: trunk/forge/portal-extensions/forge-kosmos/project.xml =================================================================== --- trunk/forge/portal-extensions/forge-kosmos/project.xml 2005-11-14 21:44:02 UTC (rev 1569) +++ trunk/forge/portal-extensions/forge-kosmos/project.xml 2005-11-14 21:44:56 UTC (rev 1570) @@ -9,4 +9,16 @@ <extend>../common.xml</extend> <id>forge-kosmos</id> <name>Forge kosmos</name> + <dependencies> + <dependency> + <groupId>kosmos</groupId> + <artifactId>kosmos-server</artifactId> + <version>1.0</version> + <jar>kosmos-server.jar</jar> + </dependency> + </dependencies> + + <build> + <sourceDirectory>src/java</sourceDirectory> + </build> </project> Added: trunk/forge/portal-extensions/forge-kosmos/src/java/org/jboss/kosmos/ShotokuCachedDataStore.java =================================================================== --- trunk/forge/portal-extensions/forge-kosmos/src/java/org/jboss/kosmos/ShotokuCachedDataStore.java 2005-11-14 21:44:02 UTC (rev 1569) +++ trunk/forge/portal-extensions/forge-kosmos/src/java/org/jboss/kosmos/ShotokuCachedDataStore.java 2005-11-14 21:44:56 UTC (rev 1570) @@ -0,0 +1,114 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.kosmos; + +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Date; + +import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.Directory; +import org.jboss.shotoku.Node; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; + +import hu.midori.kosmos.server.CachedDataStore; + +/** + * + * @author Adam Warski (ad...@as...) + * @author <a href="mailto:aro...@mi...">Aron Gombas</a> + */ +public class ShotokuCachedDataStore implements CachedDataStore { + private String fileAccessUrl; + + private String prefix; + + private ContentManager cm; + + public String storeFile(String fileName, InputStream in) throws Exception { + Node file; + Directory cacheDir = cm.getRootDirectory(); + + // Clearing old cache. + String cachedWildcard = getCachedWildcard(fileName); + for (Node cacheNode : cacheDir.getNodes()) { + if (cacheNode.getName().endsWith(cachedWildcard)) { + cacheNode.delete(); + } + } + + // Saving the new file. + String cachedFileName = getCachedFileName(fileName); + try { + file = cm.getNode(cachedFileName); + } catch (ResourceDoesNotExist e) { + file = cm.getRootDirectory().newNode(cachedFileName); + } + + file.setContent(in); + file.save("Kosmos"); + + return fileAccessUrl + "/" + prefix + "/" + cachedFileName; + } + + public void setFileAccessUrl(String fileAccessUrl) { + this.fileAccessUrl = fileAccessUrl; + } + + public void setPrefix(String prefix) { + cm = ContentManager.getContentManager(prefix); + this.prefix = prefix; + } + + /** + * Returns the part of the filename for a cached item without the timestamp + * prefix. This is used to found the previous versions of the same cache item. + * @throws UnsupportedEncodingException + */ + private static String getCachedWildcard(String filename) + throws UnsupportedEncodingException { + return encodeFilename("", filename); + } + + /** + * Returns the local filename for a cached item, by adding a timestamp prefix + * so that browsers will not cache the item if it actually changes. + * @throws UnsupportedEncodingException + */ + private static String getCachedFileName(String filename) + throws UnsupportedEncodingException { + return encodeFilename(Long.toString(new Date().getTime()), filename); + } + + /** + * Encodes the local filename for a cached item. + * @param filename can contain any character. + * @return the filename which contain only file-system-compatible characters. + * @throws UnsupportedEncodingException + */ + private static String encodeFilename(String prefix, String filename) + throws UnsupportedEncodingException { + return URLEncoder.encode(String.format("%s_%s", prefix, filename), + "utf-8"); + } +} Modified: trunk/forge/portal-extensions/forge-kosmos/to-copy/kosmos-portlet.war =================================================================== (Binary files differ) Modified: trunk/forge/portal-extensions/forge-kosmos/to-copy/kosmos-server.war =================================================================== (Binary files differ) Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHeadNode.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHeadNode.java 2005-11-14 21:44:02 UTC (rev 1569) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHeadNode.java 2005-11-14 21:44:56 UTC (rev 1570) @@ -92,7 +92,6 @@ getNodeContent().setContent(stringContent); } - public void setContent(InputStream is) { try { getNodeContent().setContent(is); @@ -105,6 +104,10 @@ getNodeContent().setContent(bytes); } + protected void setContent(NodeContent content) { + this.content = content; + } + public OutputStream getOutputStream() { return getNodeContent().getOutputStream(); } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNode.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNode.java 2005-11-14 21:44:02 UTC (rev 1569) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNode.java 2005-11-14 21:44:56 UTC (rev 1570) @@ -117,7 +117,7 @@ throw new RepositoryException(e); } - super.setContent(content.asString()); + super.setContent(content); saveWithLock(logMessage); } Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java 2005-11-14 21:44:02 UTC (rev 1569) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java 2005-11-14 21:44:56 UTC (rev 1570) @@ -61,6 +61,21 @@ assertTrue(TEST_CONTENT.equals(base.getNode(TEST_NESTED_NODE).getContent())); } + public void testNestedExisting() { + Directory base = cm.getDirectory(TEST_DIR); + base.newDirectory("h").save("h"); + + Node nested = base.newNode(TEST_NESTED_NODE); + assertTrue((TEST_DIR + "/" + TEST_NESTED_NODE).equals(nested.getFullName())); + + nested.setContent(TEST_CONTENT); + nested.save(TEST_NESTED_NODE); + + assertTrue(TEST_CONTENT.equals(base.getDirectory("h"). + getDirectory("j").getNode("k").getContent())); + assertTrue(TEST_CONTENT.equals(base.getNode(TEST_NESTED_NODE).getContent())); + } + /** * Checks if content managers work with prefixes that contain unnecessary /. */ Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/servlet/ShotokuServlet.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/servlet/ShotokuServlet.java 2005-11-14 21:44:02 UTC (rev 1569) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/servlet/ShotokuServlet.java 2005-11-14 21:44:56 UTC (rev 1570) @@ -1,5 +1,6 @@ package org.jboss.shotoku.test.servlet; +import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; @@ -9,7 +10,9 @@ import javax.servlet.http.HttpServletResponse; import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.Node; import org.jboss.shotoku.aop.Inject; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * @author Adam Warski (ad...@as...) @@ -17,10 +20,6 @@ public class ShotokuServlet extends HttpServlet { @Inject(prefix="shotoku-test") ContentManager test; - - //@Inject(prefix="wiki-content") - //@Inject - ContentManager wikiCm; /*private void readInputStream(InputStream is) throws IOException { int b; @@ -37,9 +36,15 @@ pw.write("Depends test: " + test + "<br />"); pw.write("<br />"); - wikiCm = ContentManager.getContentManager("wiki-content/"); + Node n; + try { + n = test.getNode("image.png"); + } catch (ResourceDoesNotExist e) { + n = test.getRootDirectory().newNode("image.png"); + } - wikiCm.getDirectory(""); + n.setContent(new FileInputStream("/home/adamw/downloads/image.png")); + n.save(""); //NodeList nl = new NodeList(); //pw.write(nl.getFeed("default/feeds/templates/hello-world.vm", null, new HashMap<String, Object>()).toString()); |
From: <jbo...@li...> - 2005-11-14 21:44:09
|
Author: adamw Date: 2005-11-14 16:44:02 -0500 (Mon, 14 Nov 2005) New Revision: 1569 Added: trunk/forge/portal-extensions/binaries/maven-repo-addons/kosmos/ trunk/forge/portal-extensions/binaries/maven-repo-addons/kosmos/jars/ trunk/forge/portal-extensions/binaries/maven-repo-addons/kosmos/jars/kosmos-server.jar Log: http://jira.jboss.com/jira/browse/JBLAB-490 : kosmos jar Added: trunk/forge/portal-extensions/binaries/maven-repo-addons/kosmos/jars/kosmos-server.jar =================================================================== (Binary files differ) Property changes on: trunk/forge/portal-extensions/binaries/maven-repo-addons/kosmos/jars/kosmos-server.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream |
From: <jbo...@li...> - 2005-11-14 20:44:41
|
Author: unibrew Date: 2005-11-14 15:44:33 -0500 (Mon, 14 Nov 2005) New Revision: 1568 Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java Log: [JBLAB-263] DownloadCounters speed update. Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java 2005-11-14 11:23:53 UTC (rev 1567) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java 2005-11-14 20:44:33 UTC (rev 1568) @@ -127,7 +127,7 @@ * @param portalName * @return DownloadCountersDescriptor object. */ - public static synchronized DownloadCountersDescriptor getDesc(final String portalName) { + public static DownloadCountersDescriptor getDesc(final String portalName) { DownloadCountersDescriptor desc = (DownloadCountersDescriptor) ForgeHelper .getForgeManagement().getFromCache(portalName, DownloadCountersDescriptor.class.getName()); Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2005-11-14 11:23:53 UTC (rev 1567) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2005-11-14 20:44:33 UTC (rev 1568) @@ -181,7 +181,7 @@ * This Map<Strin,org.jboss.shotoku.Node> contains project ids with their download * counter descriptor's Node. */ - private synchronized void synchronizeCounters (Map<String,org.jboss.shotoku.Node> counters) { + private void synchronizeCounters (Map<String,org.jboss.shotoku.Node> counters) { // Iterating through projects nodes containing download counter descriptors. for (String projectId:counters.keySet()){ @@ -209,15 +209,9 @@ } } - // Removing links which shouldn't be tracked any more. - for (String link:linksToDelete) { - downloadCounters.remove(link); - } + removeLinksFromCounting(linksToDelete); - // Adding new download links for tracking. - for (String link:links) { - downloadCounters.put(link,new Counter(0,projectId)); - } + addLinksForCounting (links,projectId); } catch (Exception e) { System.out.println ("[DOWNLOADCOUNTER] Problem with opening project "+ @@ -233,6 +227,35 @@ } /** + * Method removes links specified in <code>linksToDelete</code> + * from tracking their downloads. + * + * @param linksToDelete + * List<String> of links which should be removed. + */ + private synchronized void removeLinksFromCounting (List<String> linksToDelete) { + // Removing links which shouldn't be tracked any more. + for (String link:linksToDelete) { + downloadCounters.remove(link); + } + } + + /** + * Method adds links which are wished to be tracked. + * + * @param links + * List<String> of links wished to be tracked + * @param projectId + * Project id name for which the links are added. + */ + private synchronized void addLinksForCounting (List<String> links,String projectId) { + // Adding new download links for tracking. + for (String link:links) { + downloadCounters.put(link,new Counter(0,projectId)); + } + } + + /** * This method returns a List<String> of links which * are now tracked for project given by <projectId> parameter. * @@ -240,7 +263,7 @@ * Id of a project for which the links will be searched. * @return List<String> Containing tracked links. */ - private List<String> getProjectLinks (String projectId) { + private synchronized List<String> getProjectLinks (String projectId) { List<String> links = new LinkedList<String>(); for (String link:downloadCounters.keySet()) { if (link.indexOf(File.separator+projectId+File.separator)!=-1) { @@ -347,7 +370,7 @@ * The id of a project for which occurence of the links will checked. * @return Bool value whether there is a link to this project tracked or not. */ - public boolean checkForProjectCounters(String projectId) { + public synchronized boolean checkForProjectCounters(String projectId) { for (String link:downloadCounters.keySet()) { if (link.indexOf(File.separator+projectId+File.separator)!=-1) { return true; |
Author: aron.gombas Date: 2005-11-14 06:23:53 -0500 (Mon, 14 Nov 2005) New Revision: 1567 Added: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/WebdavCachedDataStore.java Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java trunk/labs/kosmos/web-server/WEB-INF/kosmos-services-servlet.xml trunk/labs/kosmos/web-server/WEB-INF/web.xml Log: Pluggable data store introduced Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java 2005-11-14 10:25:37 UTC (rev 1566) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java 2005-11-14 11:23:53 UTC (rev 1567) @@ -6,43 +6,26 @@ */ package hu.midori.kosmos.server; -import hu.midori.kosmos.server.util.WebdavUtils; - -import java.io.IOException; import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import java.util.Date; -import java.util.Enumeration; import java.util.HashMap; import java.util.Map; -import org.apache.commons.httpclient.HttpURL; -import org.apache.commons.httpclient.HttpsURL; -import org.apache.commons.httpclient.URIException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.webdav.lib.WebdavResource; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.web.context.WebApplicationContext; /** - * Each Kosmos service must extend this baseclass. - * Services are implemented as POJOs, but they have access also to - * the Spring application-context and the servlet-context. + * Each Kosmos service must extend this baseclass. Services are implemented as POJOs. * * @author <a href="mailto:aro...@mi...">Aron Gombas</a> * @version $Id$ */ -public abstract class AbstractKosmosService implements ApplicationContextAware { +public abstract class AbstractKosmosService { private final static Log log = LogFactory.getLog(AbstractKosmosService.class); /** Cache timeout in milliseconds: a new request over this period will receive the cached result. */ private static final int CACHE_TIMEOUT = 10*60*1000;// TODO should be externally configurable - /** Spring application context. */ - private WebApplicationContext ctx; /** * Caches the result to return by the concrete service. * The key is a service-specific unique string (e.g. a URL or dir name) and the value is a service-specific object. @@ -51,11 +34,14 @@ /** The timestamp when the cache was most recently updated. */ private Date timestamp; - public void setApplicationContext(ApplicationContext ctx) { - this.ctx = (WebApplicationContext)ctx; - } + /** Pluggable cached data store implementation. */ + private CachedDataStore store; + + public void setStore(CachedDataStore store) { + this.store = store; + } - /** + /** * Returns the timestamp when the cache was most recently updated. * This can be invoked only after the service method was called. */ @@ -94,111 +80,18 @@ return value; } - - /** - * Saves the passed stream to a WebDAV repository-based cache and returns - * the absolute URL pointing to the resulted file. - */ - protected String saveCachedFile(String fileName, InputStream in) throws URIException, IOException { - // init - String url = ctx.getServletContext().getInitParameter("webdav.url"); - String user = ctx.getServletContext().getInitParameter("webdav.user"); - String password = ctx.getServletContext().getInitParameter("webdav.password"); - String clientUrl = ctx.getServletContext().getInitParameter("webdav.clientUrl"); - - log.debug(String.format("Connecting to \"%s\" as \"%s\" (\"%s\")...", url, user, password)); - if((url == null) || (url.trim().length() == 0)) - throw new IllegalStateException("'webdav.url' was not specified as servlet-context init-params"); - - // determine server-side cache path and cache URL - boolean isHttps = url.startsWith("https://"); - HttpURL webdavUrl = isHttps ? new HttpsURL(url) : new HttpURL(url); - if (!isHttps) {// TODO check this -> If you use the setUser method with a HttpsUrl, a NPE is thrown, in the string's init, somewhere from HttpClient - maybe that's a bug there? - if((user != null) && (user.trim().length() != 0)) - webdavUrl.setUser(user); - if((password != null) && (password.trim().length() != 0)) - webdavUrl.setPassword(password); - } - // use "webdav.url" if "webdav.clientUrl" was not specified - if((clientUrl == null) || (clientUrl.trim().length() == 0)) - clientUrl = webdavUrl.getURI(); - - // connect - WebdavResource root = new WebdavResource(webdavUrl); - - String cacheDirName = "kosmos-cache"; - String cacheDirPath = root.getPath() + "/" + cacheDirName + "/"; - - String cachedFilename = getCachedFileName(fileName); - String cachedFilePath = cacheDirPath + cachedFilename; - String cachedFileUrl = clientUrl + "/" + cacheDirName + "/" + URLEncoder.encode(cachedFilename, "utf-8"); - - log.info("cacheDirPath: " + cacheDirPath); - log.info("cachedFilePath: " + cachedFilePath); - log.info("cachedFileUrl: " + cachedFileUrl); - - // init cache: create WebDAV collection if not existing - WebdavResource cacheDir = null; - WebdavUtils.dumpResourceChildren(root); - cacheDir = root.getChildResources().getResource(cacheDirName); - if(cacheDir == null) { - log.info(String.format("Creating WebDAV collection \"%s\"...", cacheDirPath)); - root.mkcolMethod(cacheDirPath); - - WebdavUtils.dumpResourceChildren(root); - cacheDir = root.getChildResources().getResource(cacheDirName); - if(cacheDir == null) - throw new IllegalStateException("Couldn't find WebDAV cache directory"); - } - WebdavUtils.dumpResourceChildren(cacheDir); - - // clear cache: remove old resource(s) from WebDAV - String cachedWildcard = getCachedWildcard(fileName); - Enumeration oldCachedFiles = cacheDir.getChildResources().getResources(); - while(oldCachedFiles.hasMoreElements()) { - WebdavResource oldCachedFile = (WebdavResource)oldCachedFiles.nextElement(); - if(oldCachedFile.isCollection()) - continue; - - if(oldCachedFile.getName().endsWith(cachedWildcard)) { - log.debug(String.format("Deleting outdated WebDAV resource \"%s\"...", oldCachedFile.getName())); - root.deleteMethod(oldCachedFile.getPath()); - } - } - - // fill cache: put new resource to WebDAV - log.debug(String.format("Putting WebDAV resource \"%s\"...", cachedFilename)); - root.putMethod(cachedFilePath, in); - - cacheDir.close(); - root.close(); - - return cachedFileUrl; - } - /** - * Returns the part of the filename for a cached item without the timestamp - * prefix. This is used to found the previous versions of the same cache item. + /** + * Stores the passed stream to an implementation-dependent "storage". + * @returns the absolute URL that points to the resulted file. */ - private String getCachedWildcard(String filename) throws UnsupportedEncodingException { - return encodeFilename("", filename); + protected String storeFile(String fileName, InputStream in) { + try { + // delegate to the concrete store implementation + return store.storeFile(fileName, in); + } catch (Exception ex) { + log.error("Unable to store cached file", ex); + return ""; + } } - - /** - * Returns the local filename for a cached item, by adding a timestamp prefix - * so that browsers will not cache the item if it actually changes. - */ - private String getCachedFileName(String filename) throws UnsupportedEncodingException { - return encodeFilename(Long.toString(new Date().getTime()), filename); - } - - - /** - * Encodes the local filename for a cached item. - * @param filename can contain any character. - * @return the filename which contain only file-system-compatible characters. - */ - private String encodeFilename(String prefix, String filename) throws UnsupportedEncodingException { - return URLEncoder.encode(String.format("%s_%s", prefix, filename), "utf-8"); - } } Added: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java 2005-11-14 10:25:37 UTC (rev 1566) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java 2005-11-14 11:23:53 UTC (rev 1567) @@ -0,0 +1,25 @@ +/* + * Kosmos. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package hu.midori.kosmos.server; + +import java.io.InputStream; + +/** + * Any pluggable store implementation must implement this interface. + * The concrete implementations can have their own naming policy, + * cache eviction policy, storing mechanism and such. + * + * @author <a href="mailto:aro...@mi...">Aron Gombas</a> + * @version $Id$ + */ +public interface CachedDataStore { + /** + * Stores the passed stream to an implementation-dependent "storage". + * @returns the absolute URL that points to the resulted file. + */ + public String storeFile(String fileName, InputStream in) throws Exception; // TODO exception? +} Added: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/WebdavCachedDataStore.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/WebdavCachedDataStore.java 2005-11-14 10:25:37 UTC (rev 1566) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/WebdavCachedDataStore.java 2005-11-14 11:23:53 UTC (rev 1567) @@ -0,0 +1,158 @@ +/* + * Kosmos. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package hu.midori.kosmos.server; + +import hu.midori.kosmos.server.util.WebdavUtils; + +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Date; +import java.util.Enumeration; + +import org.apache.commons.httpclient.HttpURL; +import org.apache.commons.httpclient.HttpsURL; +import org.apache.commons.httpclient.URIException; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.webdav.lib.WebdavResource; + +/** + * WebDAV-based store implementation. + * Writes the cached data to WebDAV resources and uses their public + * URLs to access them. + * + * @author <a href="mailto:aro...@mi...">Aron Gombas</a> + * @version $Id$ + */ +public class WebdavCachedDataStore implements CachedDataStore { + private final static Log log = LogFactory.getLog(WebdavCachedDataStore.class); + + /* Spring-injected properties. */ + private String webdavUrl; + private String webdavUser; + private String webdavPassword; + private String clientUrl; + + public void setWebdavUrl(String webdavUrl) { + this.webdavUrl = webdavUrl; + } + + public void setWebdavUser(String webdavUser) { + this.webdavUser = webdavUser; + } + + public void setWebdavPassword(String webdavPassword) { + this.webdavPassword = webdavPassword; + } + + public void setClientUrl(String clientUrl) { + this.clientUrl = clientUrl; + } + + /** + * Saves the passed stream to a WebDAV repository-based cache and returns + * the absolute URL pointing to the resulted file. + */ + public String storeFile(String fileName, InputStream in) throws URIException, IOException { + // init + log.debug(String.format("Connecting to \"%s\" as \"%s\" (\"%s\")...", webdavUrl, webdavUser, webdavPassword)); + if(StringUtils.isBlank(webdavUrl)) + throw new IllegalStateException("'webdavUrl' was not specified as servlet-context init-params"); + + // determine server-side cache path and cache URL + boolean isHttps = webdavUrl.startsWith("https://"); + HttpURL webdavRootUrl = isHttps ? new HttpsURL(webdavUrl) : new HttpURL(webdavUrl); + if (!isHttps) {// TODO check this -> If you use the setUser method with a HttpsUrl, a NPE is thrown, in the string's init, somewhere from HttpClient - maybe that's a bug there? + if(!StringUtils.isBlank(webdavUser)) + webdavRootUrl.setUser(webdavUser); + if(!StringUtils.isBlank(webdavPassword)) + webdavRootUrl.setPassword(webdavPassword); + } + // use "webdav.url" if "webdav.clientUrl" was not specified + if(StringUtils.isBlank(clientUrl)) + clientUrl = webdavRootUrl.getURI(); + + // connect + WebdavResource root = new WebdavResource(webdavRootUrl); + + String cacheDirName = "kosmos-cache"; + String cacheDirPath = root.getPath() + "/" + cacheDirName + "/"; + + String cachedFilename = getCachedFileName(fileName); + String cachedFilePath = cacheDirPath + cachedFilename; + String cachedFileUrl = clientUrl + "/" + cacheDirName + "/" + URLEncoder.encode(cachedFilename, "utf-8"); + + log.info("cacheDirPath: " + cacheDirPath); + log.info("cachedFilePath: " + cachedFilePath); + log.info("cachedFileUrl: " + cachedFileUrl); + + // init cache: create WebDAV collection if not existing + WebdavResource cacheDir = null; + WebdavUtils.dumpResourceChildren(root); + cacheDir = root.getChildResources().getResource(cacheDirName); + if(cacheDir == null) { + log.info(String.format("Creating WebDAV collection \"%s\"...", cacheDirPath)); + root.mkcolMethod(cacheDirPath); + + WebdavUtils.dumpResourceChildren(root); + cacheDir = root.getChildResources().getResource(cacheDirName); + if(cacheDir == null) + throw new IllegalStateException("Couldn't find WebDAV cache directory"); + } + + // clear cache: remove old resource(s) from WebDAV + String cachedWildcard = getCachedWildcard(fileName); + Enumeration oldCachedFiles = cacheDir.getChildResources().getResources(); + while(oldCachedFiles.hasMoreElements()) { + WebdavResource oldCachedFile = (WebdavResource)oldCachedFiles.nextElement(); + if(oldCachedFile.isCollection()) + continue; + + if(oldCachedFile.getName().endsWith(cachedWildcard)) { + log.debug(String.format("Deleting outdated WebDAV resource \"%s\"...", oldCachedFile.getName())); + root.deleteMethod(oldCachedFile.getPath()); + } + } + + // fill cache: put new resource to WebDAV + log.debug(String.format("Putting WebDAV resource \"%s\"...", cachedFilename)); + root.putMethod(cachedFilePath, in); + + cacheDir.close(); + root.close(); + + return cachedFileUrl; + } + + /** + * Returns the part of the filename for a cached item without the timestamp + * prefix. This is used to found the previous versions of the same cache item. + */ + private static String getCachedWildcard(String filename) throws UnsupportedEncodingException { + return encodeFilename("", filename); + } + + /** + * Returns the local filename for a cached item, by adding a timestamp prefix + * so that browsers will not cache the item if it actually changes. + */ + private static String getCachedFileName(String filename) throws UnsupportedEncodingException { + return encodeFilename(Long.toString(new Date().getTime()), filename); + } + + /** + * Encodes the local filename for a cached item. + * @param filename can contain any character. + * @return the filename which contain only file-system-compatible characters. + */ + private static String encodeFilename(String prefix, String filename) throws UnsupportedEncodingException { + return URLEncoder.encode(String.format("%s_%s", prefix, filename), "utf-8"); + } +} Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java 2005-11-14 10:25:37 UTC (rev 1566) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java 2005-11-14 11:23:53 UTC (rev 1567) @@ -141,7 +141,7 @@ ByteArrayOutputStream out = new ByteArrayOutputStream(); ChartUtils.writeChartAsPng(ChartUtils.generateColorCodedPieChart(ChartUtils.collectionToPieDataset(testsPerCategory)), out); - String testsPerCategoryChartUrl = saveCachedFile(dir + "_tests_per_category.png", new ByteArrayInputStream(out.toByteArray())); + String testsPerCategoryChartUrl = storeFile(dir + "_tests_per_category.png", new ByteArrayInputStream(out.toByteArray())); // save previousLatestLogModified = latestLog.lastModified(); Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java 2005-11-14 10:25:37 UTC (rev 1566) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java 2005-11-14 11:23:53 UTC (rev 1567) @@ -215,7 +215,7 @@ ByteArrayOutputStream out = new ByteArrayOutputStream(); ChartUtils.writeChartAsPng(ChartUtils.generatePieChart(ChartUtils.collectionToPieDataset(openIssuesPerAssignee, ChartUtils.MAX_ITEMS)), out); - String openIssuesPerAssigneeChartUrl = saveCachedFile(prefix + "_open_issues_per_assignee.png", new ByteArrayInputStream(out.toByteArray())); + String openIssuesPerAssigneeChartUrl = storeFile(prefix + "_open_issues_per_assignee.png", new ByteArrayInputStream(out.toByteArray())); // generate issues-per-status chart List<Map.Entry<Integer, Integer>> issuesPerStatusMap = new ArrayList<Map.Entry<Integer, Integer>>(); @@ -232,7 +232,7 @@ out.reset(); ChartUtils.writeChartAsPng(ChartUtils.generateColorCodedPieChart(ChartUtils.collectionToPieDataset(issuesPerStatusMap)), out); - String issuesPerStatusChartUrl = saveCachedFile(prefix + "_issues_per_status.png", new ByteArrayInputStream(out.toByteArray())); + String issuesPerStatusChartUrl = storeFile(prefix + "_issues_per_status.png", new ByteArrayInputStream(out.toByteArray())); // generate issues-per-priority chart List<Map.Entry<Integer, Integer>> openIssuesPerPriorityMap = new ArrayList<Map.Entry<Integer, Integer>>(); @@ -251,7 +251,7 @@ out.reset(); ChartUtils.writeChartAsPng(ChartUtils.generateColorCodedPieChart(ChartUtils.collectionToPieDataset(openIssuesPerPriorityMap)), out); - String openIssuesPerPriorityChartUrl = saveCachedFile(prefix + "_open_issues_per_priority.png", new ByteArrayInputStream(out.toByteArray())); + String openIssuesPerPriorityChartUrl = storeFile(prefix + "_open_issues_per_priority.png", new ByteArrayInputStream(out.toByteArray())); // save JiraProject project = new JiraProject(name, prefix, projectKey, projectUrl, description, lead, Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-11-14 10:25:37 UTC (rev 1566) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-11-14 11:23:53 UTC (rev 1567) @@ -362,19 +362,19 @@ // generate charts ByteArrayOutputStream out = new ByteArrayOutputStream(); ChartUtils.writeChartAsPng(ChartUtils.generatePieChart(ChartUtils.collectionToPieDataset(stats.commitsPerAuthor, ChartUtils.MAX_ITEMS)), out); - stats.commitsPerAuthorChartUrl = saveCachedFile(prefix + "_commits_per_author.png", new ByteArrayInputStream(out.toByteArray())); + stats.commitsPerAuthorChartUrl = storeFile(prefix + "_commits_per_author.png", new ByteArrayInputStream(out.toByteArray())); out.reset(); ChartUtils.writeChartAsPng(ChartUtils.generatePieChart(ChartUtils.collectionToPieDataset(stats.commitsPerFile, ChartUtils.MAX_ITEMS)), out); - stats.commitsPerFileChartUrl = saveCachedFile(prefix + "_commits_per_file.png", new ByteArrayInputStream(out.toByteArray())); + stats.commitsPerFileChartUrl = storeFile(prefix + "_commits_per_file.png", new ByteArrayInputStream(out.toByteArray())); out.reset(); ChartUtils.writeChartAsPng(ChartUtils.generateTimeChart(stats.commitsPerWeek), out); - stats.commitsPerWeekChartUrl = saveCachedFile(prefix + "_commits_per_week.png", new ByteArrayInputStream(out.toByteArray())); + stats.commitsPerWeekChartUrl = storeFile(prefix + "_commits_per_week.png", new ByteArrayInputStream(out.toByteArray())); out.reset(); ChartUtils.writeChartAsPng(ChartUtils.generateTimeChart(stats.repoEntriesPerWeek), out); - stats.repoEntriesPerWeekChartUrl = saveCachedFile(prefix + "_files_per_week.png", new ByteArrayInputStream(out.toByteArray())); + stats.repoEntriesPerWeekChartUrl = storeFile(prefix + "_files_per_week.png", new ByteArrayInputStream(out.toByteArray())); } } } Modified: trunk/labs/kosmos/web-server/WEB-INF/kosmos-services-servlet.xml =================================================================== --- trunk/labs/kosmos/web-server/WEB-INF/kosmos-services-servlet.xml 2005-11-14 10:25:37 UTC (rev 1566) +++ trunk/labs/kosmos/web-server/WEB-INF/kosmos-services-servlet.xml 2005-11-14 11:23:53 UTC (rev 1567) @@ -3,30 +3,50 @@ <beans> <!-- CC service --> - <bean id="ccService" class="hu.midori.kosmos.server.cc.CcServiceImpl"/> + <bean id="ccService" class="hu.midori.kosmos.server.cc.CcServiceImpl"> + <property name="store" ref="webdavCachedDataStore"/> + </bean> <bean name="/cc-service" class="org.springframework.remoting.caucho.HessianServiceExporter"> <property name="service" ref="ccService"/> <property name="serviceInterface" value="hu.midori.kosmos.protocol.CcService"/> </bean> <!-- JIRA service --> - <bean id="jiraService" class="hu.midori.kosmos.server.jira.JiraServiceImpl"/> + <bean id="jiraService" class="hu.midori.kosmos.server.jira.JiraServiceImpl"> + <property name="store" ref="webdavCachedDataStore"/> + </bean> <bean name="/jira-service" class="org.springframework.remoting.caucho.HessianServiceExporter"> <property name="service" ref="jiraService"/> <property name="serviceInterface" value="hu.midori.kosmos.protocol.JiraService"/> </bean> <!-- SF service --> - <bean id="sfService" class="hu.midori.kosmos.server.sf.SfServiceImpl"/> + <bean id="sfService" class="hu.midori.kosmos.server.sf.SfServiceImpl"> + <property name="store" ref="webdavCachedDataStore"/> + </bean> <bean name="/sf-service" class="org.springframework.remoting.caucho.HessianServiceExporter"> <property name="service" ref="sfService"/> <property name="serviceInterface" value="hu.midori.kosmos.protocol.SfService"/> </bean> <!-- SVN service --> - <bean id="svnService" class="hu.midori.kosmos.server.svn.SvnServiceImpl"/> + <bean id="svnService" class="hu.midori.kosmos.server.svn.SvnServiceImpl"> + <property name="store" ref="webdavCachedDataStore"/> + </bean> <bean name="/svn-service" class="org.springframework.remoting.caucho.HessianServiceExporter"> <property name="service" ref="svnService"/> <property name="serviceInterface" value="hu.midori.kosmos.protocol.SvnService"/> </bean> + + <!-- WebDAV cached data store --> + <bean id="webdavCachedDataStore" class="hu.midori.kosmos.server.WebdavCachedDataStore"> + <property name="webdavUrl" value="http://localhost:8080/slide/files"/><!-- Both HTTP and HTTPS protocol can be used here. --> + <property name="webdavUser" value=""/> + <property name="webdavPassword" value=""/> + <!-- This URL will be used as base URL for the generated images. + If you don't specify anything here, the value of "webdavUrl" + will be used. Uncomment this, if you want to override that. + <property name="webdavPassword" value="http://myserver/my-webdav/kosmos-images"/> + --> + </bean> </beans> Modified: trunk/labs/kosmos/web-server/WEB-INF/web.xml =================================================================== --- trunk/labs/kosmos/web-server/WEB-INF/web.xml 2005-11-14 10:25:37 UTC (rev 1566) +++ trunk/labs/kosmos/web-server/WEB-INF/web.xml 2005-11-14 11:23:53 UTC (rev 1567) @@ -8,28 +8,6 @@ <display-name>Kosmos Services Servlet</display-name> <description>Server component of Kosmos. Runs as a regular web application.</description> - - <!-- Both HTTP and HTTPS protocol can be used here. --> - <context-param> - <param-name>webdav.url</param-name> - <param-value>http://localhost:8080/slide/files</param-value> - </context-param> - <context-param> - <param-name>webdav.user</param-name> - <param-value></param-value> - </context-param> - <context-param> - <param-name>webdav.password</param-name> - <param-value></param-value> - </context-param> - <!-- This URL will be used as base URL for the generated images. - If you don't specify anything here, the value of "webdav.url" - will be used. Uncomment this, if you want to override that. - <context-param> - <param-name>webdav.clientUrl</param-name> - <param-value>http://myserver/my-webdav/kosmos/images</param-value> - </context-param> - --> <servlet> <servlet-name>kosmos-services</servlet-name> |
From: <jbo...@li...> - 2005-11-14 10:25:41
|
Author: adamw Date: 2005-11-14 05:25:37 -0500 (Mon, 14 Nov 2005) New Revision: 1566 Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewResourceHelper.java Log: A small fix ;) Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewResourceHelper.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewResourceHelper.java 2005-11-13 23:41:22 UTC (rev 1565) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewResourceHelper.java 2005-11-14 10:25:37 UTC (rev 1566) @@ -24,6 +24,7 @@ import org.jboss.shotoku.AbstractResource; import org.jboss.shotoku.Directory; import org.jboss.shotoku.exceptions.RepositoryException; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; /** * A base class for new resource helpers - their function is tu tunnel all @@ -51,8 +52,12 @@ Directory lastParent = parentDirectory; for (int i=0; i<nameParts.length-1; i++) { if (!"".equals(nameParts[i])) { - lastParent = lastParent.newDirectory(nameParts[i]); - lastParent.save(logMessage); + try { + lastParent = lastParent.getDirectory(nameParts[i]); + } catch (ResourceDoesNotExist e) { + lastParent = lastParent.newDirectory(nameParts[i]); + lastParent.save(logMessage); + } } } |
From: <jbo...@li...> - 2005-11-13 23:41:33
|
Author: unibrew Date: 2005-11-13 18:41:22 -0500 (Sun, 13 Nov 2005) New Revision: 1565 Added: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Counter.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java Removed: trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/DownloadCounter.java trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterTools.java Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectDescriptor.java trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsHelper.java trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/FileAccessFilter.java trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterPortlet.java trunk/forge/portal-extensions/portal-default/src/web/WEB-INF/default-portal.xml Log: [JBLAB-263] DownloadCounter new version. Added: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Counter.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Counter.java 2005-11-12 21:22:11 UTC (rev 1564) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Counter.java 2005-11-13 23:41:22 UTC (rev 1565) @@ -0,0 +1,66 @@ +package org.jboss.forge.common.projects; + + +/** + * Each Counter class object represents simply one counter for a download link. + * Object contains the current counter value and projectId for this link. + * + * @author Ryszard Kozmik + */ + +public class Counter { + + /** + * Current value of a download counter. + */ + private long value; + + /** + * Project id for which this instance of Counter works. + */ + private String projectId; + + /** + * Main constructor simply initiates values. + * + * @param value + * Starting value for counter. + * @param projectId + * Name of project for this counter. + */ + Counter (long value,String projectId) { + this.value=value; + this.projectId=projectId; + } + + /** + * This method increments the value of the counter. + */ + void increment () { + value++; + } + + /** + * Method returns project id name for this counter. + * + * @return Project id name for this counter. + */ + String getProjectId() { + return projectId; + } + + /** + * Method returns current value of the counter. + * @return Current value of the counter. + */ + long getValue() { + return value; + } + + /** + * Overrided method returns String containing value of the counter. + */ + public String toString () { + return Long.toString(value); + } +} Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java 2005-11-12 21:22:11 UTC (rev 1564) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java 2005-11-13 23:41:22 UTC (rev 1565) @@ -23,8 +23,8 @@ package org.jboss.forge.common.projects; -import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.util.LinkedList; import java.util.List; @@ -33,44 +33,71 @@ import org.apache.xerces.parsers.DOMParser; import org.jboss.forge.common.XmlTools; import org.jboss.forge.common.projects.XmlInputFactory.XmlNotFoundException; -import org.jboss.shotoku.ContentManager; -import org.jboss.shotoku.aop.Inject; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +/** + * DownloadCounterDescriptor is an object representing a project download counter descriptor. + * It parses the xml descriptor and then is used for collecting data achieved from parsing. + * + * @author Ryszard Kozmik + */ + public class DownloadCounterDescriptor extends AbstractDescriptor { - @Inject - private ContentManager contentManager; + /** + * This variable contains all links, which need to be tracked, collected from xml descriptor. + */ + private List<String> links; - public DownloadCounterDescriptor (XmlInputFactory isf, DomToXmlTransformer xht, - String portalName, String projectId) throws SAXException, IOException, - XmlNotFoundException, TransformerException { - - // The isf is already suffixed with the members directory, so we just - // need to add project id and descriptor name. - String isfPathToXml = File.separator+projectId + File.separator + ProjectsHelper.DOWNLOADCOUNTER_DESC; - // Getting the categories and files descriptors + /** + * Name of tag in counter.xml containing counter link. + */ + public static final String LINK = "link"; + + /** + * Name of tag in counter.xml containing counter. + */ + public static final String COUNTER = "counter"; + + /** + * Main DownloadCounterDescriptor constructor which parses the xml descriptor for a project + * and collects data from it. + * + * @param counterDesc + * This Node points to the download counter project descriptor. + * @throws SAXException + * XML parser exception. + * @throws IOException + * File reading exception. + * @throws XmlNotFoundException + * File not found exception. + */ + public DownloadCounterDescriptor (org.jboss.shotoku.Node counterDesc) + throws SAXException, IOException,XmlNotFoundException { + + // Opening the download counter descriptor. DOMParser parser = new DOMParser(); - InputSource is = isf.getInputSource(isfPathToXml); - parser.parse(is); - org.w3c.dom.Document doc = parser.getDocument(); + InputStream is = counterDesc.getContentInputStream(); + parser.parse(new InputSource(is)); + Document doc = parser.getDocument(); Node n=null,property=null; NodeList nodes = doc.getDocumentElement().getChildNodes(); - List<String> links = new LinkedList<String>(); + // Parsing and gettting download links which are requested to be tracked by download counter. + links = new LinkedList<String>(); for (int i = 0; i < nodes.getLength(); i++) { n = nodes.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { - if (n.getNodeName().equals("counter")) { + if (n.getNodeName().equals(COUNTER)) { NodeList counterProps = n.getChildNodes(); for (int j=0;j< counterProps.getLength() ; j++) { property = counterProps.item(j); if (property.getNodeType()== Node.ELEMENT_NODE){ - if (property.getNodeName().equals("link") && XmlTools.unmarshallText(property) != null + if (property.getNodeName().equals(LINK) && XmlTools.unmarshallText(property) != null && !XmlTools.unmarshallText(property).trim().equals("")) { links.add(XmlTools.unmarshallText(property).trim()); } @@ -80,95 +107,15 @@ } } - if (!links.isEmpty()) { - addLinksToCounter(projectId,portalName,links,isf,xht); - } } /** - * Mathod adds new links to the main download counter xml file. - * @param projectId - * @param portalName - * @param links - * @param isf - * @param xht - * @throws SAXException - * @throws IOException - * @throws XmlNotFoundException - * @throws TransformerException + * Method simply returns links from the xml descriptor which are requested to be tracked. + * @return + * List<String> of download links. */ - private synchronized void addLinksToCounter (String projectId,String portalName, - List<String> links, XmlInputFactory isf, DomToXmlTransformer xht) - throws SAXException, IOException, XmlNotFoundException, TransformerException { - - // Opening the main download counter xml descriptor for parsing. - DOMParser parser = new DOMParser(); - parser.parse(isf.getInputSource(ProjectsHelper.DOWNLOADCOUNTERMAIN_DESC)); - Document doc = parser.getDocument(); - NodeList nodes = doc.getDocumentElement().getChildNodes(); - Node n=null,property=null; - - - // This loop will remove all links from the "List<String> link" - // which are already in the main download counter descriptor. - for (int i=0;i <nodes.getLength(); i++) { - n = nodes.item(i); - if (n.getNodeType() == Node.ELEMENT_NODE) { - if (n.getNodeName().equals("counter")) { - NodeList counterSettings = n.getChildNodes(); - for (int j=0; j <counterSettings.getLength() ; j++) { - property = counterSettings.item(j); - if (property.getNodeType() == Node.ELEMENT_NODE) { - String nodeName = property.getNodeName(); - String nodeNodeValue = XmlTools.unmarshallText(property).trim(); - if (nodeName.equals("link") && nodeNodeValue!=null && links.contains(nodeNodeValue)) { - links.remove(nodeNodeValue); - } - } - } - } - } - } - - - // Here the new links from the "List<String> links" will be added. - if (!links.isEmpty()) { - - for (String link:links) { - Node newCounter = doc.createElement("counter"); - - Node newLink = doc.createElement("link"); - Node newLinkText = doc.createTextNode(link); - newLink.appendChild(newLinkText); - - Node newProjectId = doc.createElement("id"); - Node newProjectIdText = doc.createTextNode(projectId); - newProjectId.appendChild(newProjectIdText); - - Node newValue = doc.createElement("value"); - Node newValueText = doc.createTextNode("0"); - newValue.appendChild(newValueText); - - newCounter.appendChild(newLink); - newCounter.appendChild(newProjectId); - newCounter.appendChild(newValue); - - doc.getDocumentElement().appendChild(newCounter); - } - } - - // Making path to main counter xml located in members directory. - String pathToCountersXml = File.separator + portalName + File.separator - + ProjectsHelper.MEMBERS_DIR + File.separator + ProjectsHelper.DOWNLOADCOUNTERMAIN_DESC; - - // Getting string containing whole xml. - String xmlString = xht.transformNode(doc.getDocumentElement()); - - // Saving the main download counter xml descriptor with a new content. - org.jboss.shotoku.Node xmlFile = contentManager.getNode(pathToCountersXml); - xmlFile.setContent(xmlString); - xmlFile.save ("[DownlaodCounter] Main xml descriptor file update."); - + public List<String> getLinks () { + return links; } } Added: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java 2005-11-12 21:22:11 UTC (rev 1564) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java 2005-11-13 23:41:22 UTC (rev 1565) @@ -0,0 +1,170 @@ + + /* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.forge.common.projects; + +import java.io.File; +import java.util.Map; + +import org.jboss.forge.common.ForgeHelper; +import org.jboss.portal.common.context.DelegateContext; +import org.jboss.shotoku.ContentManager; + +/** + * DownloadCounterTools class is just a tool class with static methods + * helpiing download counters to work. + * + * @author Ryszard Kozmik + */ + +public class DownloadCounterTools { + + /** + * Dir in portal where the JSP view file is. + */ + public static final String FORGE_FILE_ACCESS_DIR="file-access"; + + /** + * Name of JSP view file. + */ + public static final String DOWNLOADCOUNTER_JSP="normal.jsp"; + + /** + * Child of a counter node where value of a counter. + */ + public static final String VALUE = "value"; + + /** + * Child of a counter node containing download counter's tracked link. + */ + public static final String LINK = "link"; + + /** + * Child nodes of counters head context. + */ + public static final String COUNTER = "counter"; + + /** + * Head context name. + */ + public static final String COUNTERS = "counters"; + + /** + * Method prepares DelegateContext object for DownloadCountersPortlet view JSP file. + * + * @param portalName + * @param projectId + * Project id name for which tracked links should be added to the context. + * @param contentManager + * @return DelegateContext object containing content for JSP file. + * @throws Exception + */ + public static DelegateContext getContext (final String portalName,final String projectId,ContentManager contentManager) throws Exception { + + // If the projectId is null method returns empty DelegateContext object. + if (projectId==null) { + return new DelegateContext(); + } + + // Creating new empty context. + DelegateContext ctx = new DelegateContext(); + + // Getting the DownloadCountersDescriptor object containing counters. + DownloadCountersDescriptor desc = getDesc(portalName); + + // If there isn't a descriptor in cache, return empty context. + if (desc==null) { + return ctx; + } + + // If there is no tracked link for projectId return empty context. + if (!desc.checkForProjectCounters(projectId)) { + return ctx; + } + + // Getting the counters. + Map<String,Counter> values = desc.getCountersMap(); + + // Filling the context for portlet. + DelegateContext counters = ctx.next("counters"); + for (String keyLink:values.keySet()) { + // Getting project ID from the counter + String counterProjectId = values.get(keyLink).getProjectId(); + + if (counterProjectId!=null && counterProjectId.compareTo(projectId)==0) { + DelegateContext counter = counters.next("counter"); + // Resolving the file name. + String fileName = keyLink.split(File.separator)[keyLink.split(File.separator).length-1]; + counter.put("link",fileName); + counter.put("value",Long.toString(values.get(keyLink).getValue())); + } + } + return ctx; + } + + /** + * Method gets DownloadCountersDescriptor object from the forge cache. + * @param portalName + * @return DownloadCountersDescriptor object. + */ + public static synchronized DownloadCountersDescriptor getDesc(final String portalName) { + DownloadCountersDescriptor desc = (DownloadCountersDescriptor) ForgeHelper + .getForgeManagement().getFromCache(portalName, + DownloadCountersDescriptor.class.getName()); + return desc; + } + + /** + * Method constructs path to main download counters descriptor. + * + * @param portalName + * @return Path to main download counters descriptor. + */ + public static String getMainXmlPath (String portalName) { + return portalName + File.separator + ProjectsHelper.MEMBERS_DIR + File.separator + ProjectsHelper.DOWNLOADCOUNTERMAIN_DESC; + } + + /** + * Method constructs path to project's download counters descriptor. + * + * @param portalName + * @param projectId + * Project id name for which the download counter descriptor path will be constructed + * @return Path to project's download counters descriptor. + */ + public static String getProjectXmlPath(String portalName,String projectId) { + return portalName+File.separator+ProjectsHelper.MEMBERS_DIR+File.separator+projectId+ + File.separator+ProjectsHelper.DOWNLOADCOUNTER_DESC; + } + + /** + * Method constructs path to the DownloadCounterPortlet JSP view file. + * + * @param portalName + * @return Path to the JSP DownloadCounterPortlet view file. + */ + public static String getJspCmPath() { + return FORGE_FILE_ACCESS_DIR + File.separator + DOWNLOADCOUNTER_JSP; + } + +} \ No newline at end of file Added: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2005-11-12 21:22:11 UTC (rev 1564) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2005-11-13 23:41:22 UTC (rev 1565) @@ -0,0 +1,415 @@ + + /* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.forge.common.projects; + +import java.io.File; +import java.io.InputStream; +import java.util.Hashtable; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.xml.transform.TransformerException; + +import org.apache.xerces.parsers.DOMParser; +import org.jboss.forge.common.XmlTools; +import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.Directory; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; + +/** + * DownloadCountersDescriptor is a main class used for counting downloads. + * It contains code for synchronizing counters with main download counters xml + * as well as synchronizing the tracked links with projects dowload counter descriptors. + * + * @author Ryszard Kozmik + */ + +public class DownloadCountersDescriptor extends AbstractDescriptor{ + + /** + * Name of tag in counters.xml containing counter value. + */ + public static final String VALUE = "value"; + + /** + * Name of tag in counters.xml containing counter link. + */ + public static final String LINK = "link"; + + /** + * Name of tag in counters.xml containing counter. + */ + public static final String COUNTER = "counter"; + + /** + * Name of tag in counters.xml containing project id. + */ + public static final String ID = "id"; + + /** + * This Map contains all counters for the portal. + */ + private Map<String,Counter> downloadCounters; + + /** + * ContentManager is used for getting to file resources. + */ + private ContentManager contentManager; + + /** + * This boolean variable turns to true if one of the counters + * has been incremented. If value is true the downloadCounters Map + * will be synchronized with a main xml descriptor + */ + private boolean changeStatus; + + /** + * Constructor for DownloadCountersDescriptor. + * While constructing object all information from projects descriptors + * is being collected and the downloadCounters Map is filled with values + * from main xml download counters descriptor. + * + * @param portalName + * @param contentManager + */ + public DownloadCountersDescriptor (final String portalName, ContentManager contentManager) { + + // Just initializing the changeStatus variable + changeStatus=false; + + // Getting the path to main dowload counters descriptor. + String pathToCountersXml = File.separator + DownloadCounterTools.getMainXmlPath(portalName); + + // Saving the ContentManager. + this.contentManager = contentManager; + + try { + + // Parsing main download counters descriptor. + DOMParser parser = new DOMParser(); + InputStream is = contentManager.getNode(pathToCountersXml).getContentInputStream(); + parser.parse(new InputSource(is)); + Document doc = parser.getDocument(); + NodeList nodes = doc.getDocumentElement().getChildNodes(); + downloadCounters=getValuesFromNodes(nodes); + + // Getting Map containing pairs of ProjectId and shotoku Node + // which refers to project download counterdescriptor. + Map <String,org.jboss.shotoku.Node> descriptors = getDownloadDescriptors(portalName); + + // Synchronizing tracked links in downloadConters with links from + // projects download counter descriptors. + synchronizeCounters(descriptors); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Method only returns all download counters. + * @return Returns a Map containing tracked download counters. + */ + public Map<String,Counter> getCountersMap () { + return downloadCounters; + } + + + /** + * This method searches through projects direcories in order to find all download counter descriptors. + * Method returns Map containging pairs of String projectId and + * org.jboss.shotoku.Node download counter descriptor file node. + * @param portalName + * @return A Map<String,org.jboss.shotoku.Node> containing project ids with their download + * counter's Node. + */ + public Map<String,org.jboss.shotoku.Node> getDownloadDescriptors (String portalName) { + Map<String,org.jboss.shotoku.Node> nodes = new Hashtable<String,org.jboss.shotoku.Node>(); + + // Getting the members dir. + Directory membersDir = contentManager.getDirectory(portalName+File.separator+ProjectsHelper.MEMBERS_DIR); + + // Getting all projects dirs in members directory. + List<Directory> membersProjectDirs = membersDir.getDirectories(); + + for (Directory projectDir:membersProjectDirs) { + for (org.jboss.shotoku.Node n:projectDir.getNodes().toList()) { + // Checking if node is a node containing download counter descriptor. + if (n.getName().compareTo(ProjectsHelper.DOWNLOADCOUNTER_DESC)==0) { + org.jboss.shotoku.Node counter = projectDir.getNode(ProjectsHelper.DOWNLOADCOUNTER_DESC); + String projectId = projectDir.getName(); + nodes.put(projectId,counter); + break; + } + } + + } + return nodes; + } + + /** + * Method removes links which was disabled from counting + * and adds those which was added in their project download counter descriptor. + * + * @param counters + * This Map<Strin,org.jboss.shotoku.Node> contains project ids with their download + * counter descriptor's Node. + */ + private synchronized void synchronizeCounters (Map<String,org.jboss.shotoku.Node> counters) { + + // Iterating through projects nodes containing download counter descriptors. + for (String projectId:counters.keySet()){ + try { + // Parsing project download counter descriptor. + DownloadCounterDescriptor counterDesc = + new DownloadCounterDescriptor(counters.get(projectId)); + + // Getting list of links which are now tracked by downloadCounters. + List<String> xmlProjectLinks = getProjectLinks(projectId); + + // Getting the list of links from download counter descriptor. + List<String> links = counterDesc.getLinks(); + + // This list will be used for collecting links which must be + // removed from downloadCounters. + List<String> linksToDelete = new LinkedList<String>(); + + // Searching for links to remove and links which are already tracked. + for (String link:xmlProjectLinks) { + if (links.contains(link)) { + links.remove(link); + } else { + linksToDelete.add(link); + } + } + + // Removing links which shouldn't be tracked any more. + for (String link:linksToDelete) { + downloadCounters.remove(link); + } + + // Adding new download links for tracking. + for (String link:links) { + downloadCounters.put(link,new Counter(0,projectId)); + } + + } catch (Exception e) { + System.out.println ("[DOWNLOADCOUNTER] Problem with opening project "+ + projectId+" download counter descriptor."); + e.printStackTrace(); + } + + } + + // Changing status to false becouse downloadCounters Map + // is now synchronized with download counters descriptors. + changeStatus=false; + } + + /** + * This method returns a List<String> of links which + * are now tracked for project given by <projectId> parameter. + * + * @param projectId + * Id of a project for which the links will be searched. + * @return List<String> Containing tracked links. + */ + private List<String> getProjectLinks (String projectId) { + List<String> links = new LinkedList<String>(); + for (String link:downloadCounters.keySet()) { + if (link.indexOf(File.separator+projectId+File.separator)!=-1) { + links.add(new String(link)); + } + } + return links; + } + + /** + * Method synchronizes the downloadCounters Map with a main download counters descriptor file. + * + * @param portalName + */ + public void synchronizeWithFile(String portalName) { + + String pathToCountersXml = File.separator + DownloadCounterTools.getMainXmlPath(portalName); + + try { + DOMParser parser = new DOMParser(); + + // Opening main download counters descriptor file. + InputStream is = contentManager.getNode(pathToCountersXml).getContentInputStream(); + parser.parse(new InputSource(is)); + Document doc = parser.getDocument(); + Node mainTag = doc.createElement("counters"); + + // Replacing old main descriptor tag with new, empty. + doc.replaceChild(mainTag,doc.getDocumentElement()); + + // Filling the descriptor with new counter. + createDocument(doc); + + DomToXmlTransformer xht = new DomToXmlTransformer(); + + // Getting string containing whole xml. + String xmlString = xht.transformNode(doc.getDocumentElement()); + + // Saving the main download counter xml descriptor with a new content. + org.jboss.shotoku.Node xmlFile = contentManager.getNode(pathToCountersXml); + xmlFile.setContent(xmlString); + xmlFile.save ("[DownlaodCounter] Main xml descriptor file update."); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Method creates content of download counters main descriptor by + * copying values from downloadCounters Map. + * + * @param doc + * This Document object points to download counters main descriptor xml. + */ + private void createDocument (Document doc) { + Set<String> keys = downloadCounters.keySet(); + Counter temporary=null; + for (String link:keys) { + temporary = downloadCounters.get(link); + Node newCounter = doc.createElement(COUNTER); + + Node newLink = doc.createElement(LINK); + Node newLinkText = doc.createTextNode(link); + newLink.appendChild(newLinkText); + + Node newProjectId = doc.createElement(ID); + Node newProjectIdText = doc.createTextNode(temporary.getProjectId()); + newProjectId.appendChild(newProjectIdText); + + Node newValue = doc.createElement(VALUE); + Node newValueText = doc.createTextNode(Long.toString(temporary.getValue())); + newValue.appendChild(newValueText); + + newCounter.appendChild(newLink); + newCounter.appendChild(newProjectId); + newCounter.appendChild(newValue); + + doc.getDocumentElement().appendChild(newCounter); + } + } + + /** + * Method simply just increments the counter value for + * given in parameter <link>. + * + * @param link + * Counter value for this <code>link</code> will be incremented. + */ + synchronized public void increment (String link) { + if (downloadCounters.get(link)!=null) { + // Status change to inform about counters modification. + changeStatus=true; + downloadCounters.get(link).increment(); + } + } + + /** + * This method returns true if there is at least one link, + * connected with given in parameter <projectId>, tracked. + * If there is no link for this <projectId> tracked method returns false. + * + * @param projectId + * The id of a project for which occurence of the links will checked. + * @return Bool value whether there is a link to this project tracked or not. + */ + public boolean checkForProjectCounters(String projectId) { + for (String link:downloadCounters.keySet()) { + if (link.indexOf(File.separator+projectId+File.separator)!=-1) { + return true; + } + } + return false; + } + + /** + * Method returns true if there was change in downloadCounters Map. + * Othervise it returns false. + * + * @return Returns true if the status of downloadCounters has changed. + */ + public boolean hasChanged () { + return changeStatus; + } + + + /** + * Method used for pulling the links,counter values and projectIds out from the + * xml file nodes to the <String,Counter> Map. + * @param nodes + * NodeList containing conent of xml descriptor + * @return + * Map<String,Couner> containing counters for links which will be tracked. + */ + private static Map<String,Counter> getValuesFromNodes (NodeList nodes) { + Map<String,Counter> values = new Hashtable<String,Counter>(); + + // Temporary variables used for parsing. + Node n=null,property=null; + + // Parsing main download counters descriptor. + for (int i = 0; i < nodes.getLength(); i++) { + n = nodes.item(i); + if (n.getNodeType() == Node.ELEMENT_NODE) { + if (n.getNodeName().equals(DownloadCountersDescriptor.COUNTER)) { + NodeList counterProps = n.getChildNodes(); + String tempLink = null; + String tempValue = null; + String tempId = null; + for (int j=0;j< counterProps.getLength() ; j++) { + property = counterProps.item(j); + if (property.getNodeType()== Node.ELEMENT_NODE){ + String nodeTextCnt = XmlTools.unmarshallText(property); + if (property.getNodeName().equals(LINK) && nodeTextCnt != null && !nodeTextCnt.trim().equals("")) { + tempLink = nodeTextCnt.trim(); + } else if (property.getNodeName().equals(VALUE) && nodeTextCnt !=null && !nodeTextCnt.trim().equals("")) { + tempValue = nodeTextCnt.trim(); + } else if (property.getNodeName().equals(ID) && nodeTextCnt !=null && !nodeTextCnt.trim().equals("")) { + tempId = nodeTextCnt.trim(); + } + } + } + if (tempLink!=null && tempValue!=null && tempId!=null) { + values.put(tempLink,new Counter(Long.valueOf(tempValue),tempId)); + } + } + } + } + return values; + } + +} Added: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java 2005-11-12 21:22:11 UTC (rev 1564) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java 2005-11-13 23:41:22 UTC (rev 1565) @@ -0,0 +1,79 @@ +package org.jboss.forge.common.projects; + +import java.util.Collection; + +import org.jboss.forge.common.service.NodeWatcher; +import org.jboss.forge.common.service.ResourceWatcher; +import org.jboss.shotoku.ContentManager; + +/** + * DownloadCounterWatcher class which implements NodeWatcher interface + * is used for invoking updates of the main download counter xml descriptor + * and watching for changes in projects download counter descriptors. + * + * @author Ryszard Kozmik + * + */ +public class DownloadCountersWatcher implements NodeWatcher{ + + ContentManager contentManager; + ResourceWatcher rw; + + /** + * Simple constructor saving ContentManager given in parameter + * <code>conentManager</code> + * @param contentManager + */ + public DownloadCountersWatcher (ContentManager contentManager) { + this.contentManager = contentManager; + } + + + public Object init(String portalName) { + return getDescriptor(portalName); + } + + /** + * Method constructs the DownloadCountersDescriptor object registers it + * with the ResourceWatcher as well as all found DownloadCounterDescriptor's. + * + * @param portalName + * @return DownloadCountersDescriptor object. + */ + private Object getDescriptor (String portalName) { + DownloadCountersDescriptor descriptor = + new DownloadCountersDescriptor(portalName, contentManager); + rw = new ResourceWatcher(contentManager); + // Registering ResourceWatcher to watch for main download counters xml file change. + rw.watchResource(DownloadCounterTools.getMainXmlPath(portalName)); + + // Getting the project ids names where are project download counter descriptors. + Collection<String> projects = descriptor.getDownloadDescriptors(portalName).keySet(); + + // Adding found project download counter descriptors to the ResourceWatcher to watch + // for their changes. + for (String id:projects) { + rw.watchResource(DownloadCounterTools.getProjectXmlPath(portalName,id)); + } + return descriptor; + } + + /** + * Method updates main downlaod counters descriptor if there is such a need. + * If the object is changed the method returns new object if not returns null. + */ + public Object nodeUpdate(String portalName, Object currentValue) { + if (currentValue==null || rw.checkResources()) { + return getDescriptor(portalName); + } else if (((DownloadCountersDescriptor)currentValue).hasChanged()){ + DownloadCountersDescriptor descriptor = + (DownloadCountersDescriptor)currentValue; + descriptor.synchronizeWithFile(portalName); + return null; + } + return null; + } + + + +} Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectDescriptor.java 2005-11-12 21:22:11 UTC (rev 1564) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectDescriptor.java 2005-11-13 23:41:22 UTC (rev 1565) @@ -119,18 +119,6 @@ downloads = null; } - // Trying to create a downloads counter descriptor. - /* IMPLEMENTATION OF DOWNLOAD COUNTER TEMPORARY COMMENTED - try { - downloadCounter = new DownloadCounterDescriptor(isf, xht, portalName, getId()); - } catch (XmlNotFoundException e1) { - // It means that this project doesn't have downlaod counter descriptor. - } - catch (Exception e) { - log.warn("Project "+getId()+", unable te parse download counter" + - " descriptor: "+e); - downloadCounter = null; - }*/ } /** Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsHelper.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsHelper.java 2005-11-12 21:22:11 UTC (rev 1564) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/ProjectsHelper.java 2005-11-13 23:41:22 UTC (rev 1565) @@ -32,6 +32,7 @@ * Various helper methods for project-specific portlets. * * @author adamw + * @author Ryszard Kozmik */ public class ProjectsHelper { /** Deleted: trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/DownloadCounter.java =================================================================== --- trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/DownloadCounter.java 2005-11-12 21:22:11 UTC (rev 1564) +++ trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/DownloadCounter.java 2005-11-13 23:41:22 UTC (rev 1565) @@ -1,163 +0,0 @@ - - /* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.forge.fileaccess; - -import java.io.File; -import java.io.InputStream; - -import org.apache.xerces.parsers.DOMParser; -import org.jboss.forge.common.XmlTools; -import org.jboss.forge.common.projects.DomToXmlTransformer; -import org.jboss.forge.common.projects.ProjectsHelper; -import org.jboss.shotoku.ContentManager; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; - -public class DownloadCounter { - - // Name the main xml file containing download counter data. - public static final String DOWNLOADCOUNTER_FILE="counters.xml"; - - // Name of tag in counters.xml containing counter value. - public static final String VALUE = "value"; - - // Name of tag in counters.xml containing counter link. - public static final String LINK = "link"; - - // Name of tag in counters.xml containing counter. - public static final String COUNTER = "counter"; - - synchronized public static void increment (String link,ContentManager contentManager) { - if (link==null) { - return; - } - String portalName = resolvePortalName(link); - - link = File.separator + link; - - String pathToCountersXml = File.separator + portalName + File.separator - + ProjectsHelper.MEMBERS_DIR + File.separator + DOWNLOADCOUNTER_FILE; - - try { - DOMParser parser = new DOMParser(); - - // Getting stream of counters.xml file. - InputStream is = contentManager.getNode(pathToCountersXml).getContentInputStream(); - parser.parse(new InputSource(is)); - Document doc = parser.getDocument(); - NodeList nodes = doc.getDocumentElement().getChildNodes(); - - // This variable will reference Node containing counter for searched link. - Node linkNode = findLinkNode (nodes, link); - - // If the linkNode variable isn't NULL it means that we count this link and should increment it. - if (linkNode!=null) { - NodeList linkNodeChildren=linkNode.getChildNodes(); - Node tempNode = null; - for (int i=0;i<linkNodeChildren.getLength();i++) { - tempNode = linkNodeChildren.item(i); - if (tempNode.getNodeType()== Node.ELEMENT_NODE){ - - // Searching for VALUE node to change its value. - - if (tempNode.getNodeName().equals(VALUE)) { - String nodeTextCnt = XmlTools.unmarshallText(tempNode); - if (nodeTextCnt!=null && !nodeTextCnt.equals("")) { - long value = 1; - try { - // Trying to get the old value from the node. - value = Long.valueOf(nodeTextCnt) + 1; - } catch (NumberFormatException e) { - System.out.println ("[DownloadCounter] Incorrect "+DOWNLOADCOUNTER_FILE+" syntax."); - e.printStackTrace(); - } - NodeList content = tempNode.getChildNodes(); - for (int j=0;j<content.getLength();j++) { - if (content.item(j).getNodeType() == Node.TEXT_NODE){ - // Setting the new node value. - content.item(j).setNodeValue(Long.toString(value)); - break; - } else { - // Removing some inapropriate content of this node. - tempNode.removeChild(content.item(j)); - } - } - } else { - // Situation when the VALUE node is empty - Node newValueText = doc.createTextNode("1"); - tempNode.appendChild(newValueText); - } - break; - } - } - } - DomToXmlTransformer xht = new DomToXmlTransformer(); - String xmlString = xht.transformNode(doc.getDocumentElement()); - // Saving the updated xml. - org.jboss.shotoku.Node xmlFile = contentManager.getNode(pathToCountersXml); - xmlFile.setContent(xmlString); - xmlFile.save ("[DownlaodCounter] Main xml descriptor file update."); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * Method used to resolve portal name to which the download link aims. - * @param link - * @return - */ - private static String resolvePortalName (String link) { - return link.split(File.separator)[0]; - } - - private static Node findLinkNode (NodeList nodes, String link) { - - // Temporary variables used for parsing. - Node n=null,property=null; - - for (int i = 0; i < nodes.getLength(); i++) { - n = nodes.item(i); - if (n.getNodeType() == Node.ELEMENT_NODE) { - if (n.getNodeName().equals(COUNTER)) { - NodeList counterProps = n.getChildNodes(); - for (int j=0;j< counterProps.getLength() ; j++) { - property = counterProps.item(j); - if (property.getNodeType()== Node.ELEMENT_NODE){ - String nodeTextCnt = XmlTools.unmarshallText(property); - if (property.getNodeName().equals(LINK) && nodeTextCnt != null && nodeTextCnt.trim().equals(link)) { - return n; - } - } - } - } - } - } - return null; - } - -} Modified: trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/FileAccessFilter.java =================================================================== --- trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/FileAccessFilter.java 2005-11-12 21:22:11 UTC (rev 1564) +++ trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/FileAccessFilter.java 2005-11-13 23:41:22 UTC (rev 1565) @@ -39,9 +39,8 @@ import org.jboss.shotoku.aop.Inject; import org.jboss.forge.common.ForgeHelper; -/* TEMPORARY COMMENTED DOWNLOAD COUNTER PROJECT */ -//import org.jboss.forge.common.projects.DownloadCountersDescriptor; -//import org.jboss.forge.common.projects.DownloadCountersWatcher; +import org.jboss.forge.common.projects.DownloadCountersDescriptor; +import org.jboss.forge.common.projects.DownloadCountersWatcher; /** @@ -49,6 +48,7 @@ * a content repository. * * @author adamw + * @author Ryszard Kozmik */ public class FileAccessFilter implements Filter { /** @@ -81,6 +81,7 @@ @Inject private ContentManager contentManager; + public void init(FilterConfig conf) { } @@ -127,26 +128,32 @@ // Checking if we can allow access to this resource. checkResource(requestedRes); - /* IMPLEMENTATION OF DOWNLOAD COUNTER TEMPORARY COMMENTED + // DownloadCounter + // checking if it is file access to downloads if (requestedRes.indexOf(DOWNLOADS_ACCESS)!=-1) { + + // resolving portal name String portalName = resolvePortalName(requestedRes); + + // Trying to get DownloadCountersDescriptor object from the cache DownloadCountersDescriptor downloadCounters = (DownloadCountersDescriptor) ForgeHelper .getForgeManagement().getFromCache(portalName, DownloadCountersDescriptor.class.getName()); - + + // Checking if there was DownloadCountersDescriptor object in cache. + // If not creating new one. if (downloadCounters == null) downloadCounters = (DownloadCountersDescriptor) ForgeHelper.getForgeManagement() - .addNodeWatcher(portalName, + .addNodeWatcher(portalName, DownloadCountersDescriptor.class.getName(), new DownloadCountersWatcher(contentManager)); // Sending the request link to the DownloadCounter to increment // counter for this link if it's one of the tracked links. - - downloadCounters.increment(requestedRes); + downloadCounters.increment(File.separator+requestedRes); - } */ + } Node requestedNode = contentManager.getNode(requestedRes); String mimeType = requestedNode.getMimeType(); Modified: trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterPortlet.java =================================================================== --- trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterPortlet.java 2005-11-12 21:22:11 UTC (rev 1564) +++ trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterPortlet.java 2005-11-13 23:41:22 UTC (rev 1565) @@ -30,6 +30,7 @@ import javax.portlet.PortletRequestDispatcher; import org.jboss.forge.common.ForgeHelper; +import org.jboss.forge.common.projects.DownloadCounterTools; import org.jboss.forge.common.projects.ProjectsHelper; import org.jboss.portal.common.context.DelegateContext; import org.jboss.portal.core.servlet.jsp.PortalJsp; @@ -43,24 +44,29 @@ * @author Ryszard Kozmik * Downlaod Counter portlet. */ + public class DownloadCounterPortlet extends JBossPortlet { @Inject private ContentManager contentManager; + public void doView(JBossRenderRequest request, JBossRenderResponse response) throws IOException, PortletException { // Getting name of the project on which the download counter is used. - //String projectId = (String)request.getAttribute("project"); String projectId = ProjectsHelper.getSelectedProjectId(request); + // Preparing request & response ProjectsHelper.prepareRequest(request); response.setContentType("text/html"); + + // Resolving portal name. String portalName = ForgeHelper.getPortalName(request); DelegateContext context = null; try { + // Getting context for view of download counters tracked for project. context = DownloadCounterTools.getContext(portalName,projectId,contentManager); // Adding content context to request for JSP file. request.setAttribute(PortalJsp.CTX_REQUEST, context); @@ -69,6 +75,7 @@ throw new PortletException(e); } + // Dispaching request to the JSP file. PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher( ForgeHelper.createRepoAccessPath(portalName,DownloadCounterTools.getJspCmPath())); rd.include(request, response); Deleted: trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterTools.java =================================================================== --- trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterTools.java 2005-11-12 21:22:11 UTC (rev 1564) +++ trunk/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterTools.java 2005-11-13 23:41:22 UTC (rev 1565) @@ -1,130 +0,0 @@ - - /* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.forge.fileaccess.portlet; - -import java.io.File; -import java.io.InputStream; -import java.util.Hashtable; -import java.util.Map; - -import org.apache.xerces.parsers.DOMParser; -import org.jboss.forge.common.XmlTools; -import org.jboss.forge.common.projects.ProjectsHelper; -import org.jboss.forge.fileaccess.DownloadCounter; -import org.jboss.portal.common.context.DelegateContext; -import org.jboss.shotoku.ContentManager; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; - -public class DownloadCounterTools { - - public static final String FORGE_FILE_ACCESS_DIR="file-access"; - public static final String DOWNLOADCOUNTER_JSP="normal.jsp"; - - public static DelegateContext getContext (String portalName,String projectId,ContentManager contentManager) throws Exception { - - // If the projectId is null method returns empty DelegateContext object. - if (projectId==null) { - return new DelegateContext(); - } - - String pathToCountersXml = File.separator + portalName + File.separator - + ProjectsHelper.MEMBERS_DIR + File.separator + DownloadCounter.DOWNLOADCOUNTER_FILE; - - DOMParser parser = new DOMParser(); - - // Getting stream of counters.xml file. - InputStream is = contentManager.getNode(pathToCountersXml).getContentInputStream(); - parser.parse(new InputSource(is)); - Document doc = parser.getDocument(); - NodeList nodes = doc.getDocumentElement().getChildNodes(); - - // This Map will contain links as map keys and, counter values as map values. - Map<String,String> values = getValuesFromNodes (nodes); - - // Filling the context for portlet. - DelegateContext ctx = new DelegateContext(); - for (String keyLink:values.keySet()) { - // Getting project ID from the counter - String counterProjectId = null; - if (keyLink.split(File.separator).length>=4) - counterProjectId = keyLink.split(File.separator)[3]; - if (counterProjectId!=null && counterProjectId.compareTo(projectId)==0) { - DelegateContext counter = ctx.next("counter"); - String fileName = keyLink.split(File.separator)[keyLink.split(File.separator).length-1]; - counter.put("link",fileName); - counter.put("value",values.get(keyLink)); - } - } - return ctx; - } - - /** - * Method used for pulling the links and counter values out from the - * xml file nodes to the <String,String> Map. - * @param nodes - * @return - */ - private static Map<String,String> getValuesFromNodes (NodeList nodes) { - Map<String,String> values = new Hashtable<String,String>(); - - // Temporary variables used for parsing. - Node n=null,property=null; - - // Parsing main Download Counter descriptor. - for (int i = 0; i < nodes.getLength(); i++) { - n = nodes.item(i); - if (n.getNodeType() == Node.ELEMENT_NODE) { - if (n.getNodeName().equals(DownloadCounter.COUNTER)) { - NodeList counterProps = n.getChildNodes(); - String tempLink = null; - String tempValue = null; - for (int j=0;j< counterProps.getLength() ; j++) { - property = counterProps.item(j); - if (property.getNodeType()== Node.ELEMENT_NODE){ - String nodeTextCnt = XmlTools.unmarshallText(property); - if (property.getNodeName().equals("link") && nodeTextCnt != null && !nodeTextCnt.trim().equals("")) { - tempLink = nodeTextCnt.trim(); - } else if (property.getNodeName().equals("value") && nodeTextCnt !=null && !nodeTextCnt.trim().equals("")) { - tempValue = nodeTextCnt.trim(); - } - } - } - if (tempLink!=null && tempValue!=null) { - values.put(tempLink,tempValue); - } - } - } - } - return values; - } - - - public static String getJspCmPath() { - return FORGE_FILE_ACCESS_DIR + File.separator + DOWNLOADCOUNTER_JSP; - } - -} \ No newline at end of file Modified: trunk/forge/portal-extensions/portal-default/src/web/WEB-INF/default-portal.xml =================================================================== --- trunk/forge/portal-extensions/portal-default/src/web/WEB-INF/default-portal.xml 2005-11-12 21:22:11 UTC (rev 1564) +++ trunk/forge/portal-extensions/portal-default/src/web/WEB-INF/default-portal.xml 2005-11-13 23:41:22 UTC (rev 1565) @@ -274,6 +274,13 @@ <region>center</region> <height>0</height> </window> + <window> + <window-name>DownloadCounterPortletWindowDefaultDownloads</window-name> + <instance-ref>counter.DownloadCounterPortlet.DownloadCounterPortletInstance</instance-ref> + <region>center</region> + <height>0</height> + <window-state>normal</window-state> + </window> </page> <page> |
From: <jbo...@li...> - 2005-11-12 21:22:20
|
Author: adamw Date: 2005-11-12 16:22:11 -0500 (Sat, 12 Nov 2005) New Revision: 1564 Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/servlet/ShotokuServlet.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-32 : fix + test Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2005-11-12 12:58:50 UTC (rev 1563) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2005-11-12 21:22:11 UTC (rev 1564) @@ -279,7 +279,10 @@ */ public static ContentManager getContentManager(String id, String prefix) { if (id == null) id = defaultId; - if (prefix == null) prefix = ""; + if (prefix == null) + prefix = ""; + else + prefix = normalizeSlashes(prefix); Constructor constructor = contentManagers.get(id); @@ -295,4 +298,23 @@ return null; } } + + /** + * From the given string, removes unnecessary / in the middle, beggining + * and ending. For example: "/a//b//c/" is transformed to "a/b/c". + * @param toNormalize String to normalize. + * @return <code>toNormalize</code> with unnecessary / removed. + */ + protected static String normalizeSlashes(String toNormalize) { + while (toNormalize.contains("//")) + toNormalize = toNormalize.replace("//", "/"); + + if (toNormalize.startsWith("/")) + toNormalize = toNormalize.substring(1); + + if (toNormalize.endsWith("/")) + toNormalize = toNormalize.substring(0, toNormalize.length() - 1); + + return toNormalize; + } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java 2005-11-12 12:58:50 UTC (rev 1563) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java 2005-11-12 21:22:11 UTC (rev 1564) @@ -106,15 +106,8 @@ */ String[] getNamesFromPath(String path) { // Compacting path, that is, throwing out unnecessary /. - while (path.contains("//")) - path = path.replace("//", "/"); + path = normalizeSlashes(path); - if (path.startsWith("/")) - path = path.substring(1); - - if (path.endsWith("/")) - path = path.substring(0, path.length() - 1); - // Constructing fullName - just getting rid of the prefix and possible // / on the first position. String fullName = path.trim().substring(prefixLength); Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java 2005-11-12 12:58:50 UTC (rev 1563) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java 2005-11-12 21:22:11 UTC (rev 1564) @@ -21,6 +21,7 @@ */ package org.jboss.shotoku.test; +import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.Directory; import org.jboss.shotoku.Node; @@ -59,6 +60,18 @@ getDirectory("j").getNode("k").getContent())); assertTrue(TEST_CONTENT.equals(base.getNode(TEST_NESTED_NODE).getContent())); } + + /** + * Checks if content managers work with prefixes that contain unnecessary /. + */ + public void testSlashesInCmPrefix() { + ContentManager cm1 = ContentManager.getContentManager("/shotoku-test/"); + cm1.getRootDirectory().getDirectory(TEST_DIR); + + ContentManager cm2 = ContentManager.getContentManager( + "//shotoku-test///" + TEST_DIR + "///"); + cm2.getRootDirectory(); + } public void tearDown() { cm.getDirectory(TEST_DIR).delete(); Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/servlet/ShotokuServlet.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/servlet/ShotokuServlet.java 2005-11-12 12:58:50 UTC (rev 1563) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/servlet/ShotokuServlet.java 2005-11-12 21:22:11 UTC (rev 1564) @@ -1,11 +1,7 @@ package org.jboss.shotoku.test.servlet; -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.PrintWriter; -import java.util.Calendar; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -13,7 +9,6 @@ import javax.servlet.http.HttpServletResponse; import org.jboss.shotoku.ContentManager; -import org.jboss.shotoku.Node; import org.jboss.shotoku.aop.Inject; /** @@ -23,15 +18,16 @@ @Inject(prefix="shotoku-test") ContentManager test; - @Inject(prefix="wiki-content") + //@Inject(prefix="wiki-content") + //@Inject ContentManager wikiCm; - private void readInputStream(InputStream is) throws IOException { + /*private void readInputStream(InputStream is) throws IOException { int b; StringBuffer sb = new StringBuffer(); while ((b = is.read()) != -1) sb.append(b); - } + }*/ @Override protected void service(HttpServletRequest request, @@ -41,13 +37,14 @@ pw.write("Depends test: " + test + "<br />"); pw.write("<br />"); - pw.write("Velocity test:"); - pw.write("<br />"); + wikiCm = ContentManager.getContentManager("wiki-content/"); + wikiCm.getDirectory(""); + //NodeList nl = new NodeList(); //pw.write(nl.getFeed("default/feeds/templates/hello-world.vm", null, new HashMap<String, Object>()).toString()); - int processed; + /*int processed; pw.write("Shotoku file read: <br />"); long start = Calendar.getInstance().getTimeInMillis(); @@ -75,7 +72,7 @@ } } stop = Calendar.getInstance().getTimeInMillis(); - pw.write("Time: " + (stop-start) + ", processed: " + processed); + pw.write("Time: " + (stop-start) + ", processed: " + processed);*/ } } |
Author: szimano Date: 2005-11-12 07:58:50 -0500 (Sat, 12 Nov 2005) New Revision: 1563 Added: trunk/forge/portal-extensions/forge-speller/ trunk/forge/portal-extensions/forge-speller/.classpath trunk/forge/portal-extensions/forge-speller/.project trunk/forge/portal-extensions/forge-speller/maven.xml trunk/forge/portal-extensions/forge-speller/project.properties trunk/forge/portal-extensions/forge-speller/project.xml trunk/forge/portal-extensions/forge-speller/src/ trunk/forge/portal-extensions/forge-speller/src/etc/ trunk/forge/portal-extensions/forge-speller/src/etc/blank.html trunk/forge/portal-extensions/forge-speller/src/etc/controlWindow.js trunk/forge/portal-extensions/forge-speller/src/etc/controls.html trunk/forge/portal-extensions/forge-speller/src/etc/index.html trunk/forge/portal-extensions/forge-speller/src/etc/spellChecker.js trunk/forge/portal-extensions/forge-speller/src/etc/spellchecker.html trunk/forge/portal-extensions/forge-speller/src/etc/spellerStyle.css trunk/forge/portal-extensions/forge-speller/src/etc/wordWindow.js trunk/forge/portal-extensions/forge-speller/src/java/ trunk/forge/portal-extensions/forge-speller/src/java/org/ trunk/forge/portal-extensions/forge-speller/src/java/org/jboss/ trunk/forge/portal-extensions/forge-speller/src/java/org/jboss/labs/ trunk/forge/portal-extensions/forge-speller/src/java/org/jboss/labs/speller/ trunk/forge/portal-extensions/forge-speller/src/java/org/jboss/labs/speller/SpellerServlet.java trunk/forge/portal-extensions/forge-speller/src/web/ trunk/forge/portal-extensions/forge-speller/src/web/WEB-INF/ trunk/forge/portal-extensions/forge-speller/src/web/WEB-INF/jsp/ trunk/forge/portal-extensions/forge-speller/src/web/WEB-INF/jsp/normal.jsp trunk/forge/portal-extensions/forge-speller/src/web/WEB-INF/tld/ trunk/forge/portal-extensions/forge-speller/src/web/WEB-INF/tld/forge.tld trunk/forge/portal-extensions/forge-speller/src/web/WEB-INF/tld/portlet.tld trunk/forge/portal-extensions/forge-speller/src/web/WEB-INF/web.xml Modified: trunk/forge/portal-extensions/forge-ear/src/META-INF/application.xml trunk/forge/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/jbossForge.jsp trunk/forge/portal-extensions/jbosswiki/forge-wiki/src/web/WEB-INF/jsp/Edit.jsp Log: http://jira.jboss.com/jira/browse/JBWIKI-18 Added spell checker that can be used _everywhere_ in portal. Please reade this wiki page: http://labs.jboss.com/wiki/AddSpellChecker Modified nasty application.xml commited by someone :->. Modified: trunk/forge/portal-extensions/forge-ear/src/META-INF/application.xml =================================================================== --- trunk/forge/portal-extensions/forge-ear/src/META-INF/application.xml 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-ear/src/META-INF/application.xml 2005-11-12 12:58:50 UTC (rev 1563) @@ -87,7 +87,6 @@ <web> <web-uri>forge-status.war</web-uri> </web> - </module> </module> <module> <web> Added: trunk/forge/portal-extensions/forge-speller/.classpath =================================================================== --- trunk/forge/portal-extensions/forge-speller/.classpath 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/.classpath 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<classpath> + <classpathentry excluding="" kind="src" path="src/java"> + </classpathentry> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/tmate/jars/javasvn.jar"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/tmate/jars/jsch.jar"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/javax.servlet/jars/servlet-api-2.2.jar"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/jboss-forge/jars/forge-common-1.0.jar"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/portlet-api/jars/portlet-api-1.0.jar"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/jboss/jars/jboss-jmx.jar"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/jboss/jars/jboss-common.jar"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/jboss/jars/portal-common-lib.jar"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/jboss/jars/portal-core-lib.jar"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/jboss/jars/portal-portlet-lib.jar"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/shotoku/jars/shotoku-base.jar"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/shotoku/jars/shotoku-aop.jar"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/velocity/jars/velocity-1.4.jar"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/velocity/jars/velocity-dep-1.4.jar"> + </classpathentry> + <classpathentry kind="output" path="target/classes"> + </classpathentry> +</classpath> \ No newline at end of file Added: trunk/forge/portal-extensions/forge-speller/.project =================================================================== --- trunk/forge/portal-extensions/forge-speller/.project 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/.project 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<projectDescription> + <name>ads-portlet</name> + <comment> + </comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> \ No newline at end of file Added: trunk/forge/portal-extensions/forge-speller/maven.xml =================================================================== --- trunk/forge/portal-extensions/forge-speller/maven.xml 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/maven.xml 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,29 @@ +<!-- + JBoss, the OpenSource J2EE webOS + Distributable under LGPL license. + See terms of license at gnu.org. + --> +<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:u="jelly:util"> + <!-- Default war-project goals --> + + <goal name="all"> + <attainGoal name="build" /> + <attainGoal name="deploy" /> + </goal> + + <goal name="build"> + <attainGoal name="war" /> + </goal> + + <goal name="deploy"> + <ant:copy todir="${local.deploy.dir}" flatten="true"> + <ant:fileset dir="."> + <ant:filename name="target/*.war" /> + </ant:fileset> + </ant:copy> + </goal> + + <goal name="clean"> + <attainGoal name="prj-clean" /> + </goal> +</project> Added: trunk/forge/portal-extensions/forge-speller/project.properties =================================================================== --- trunk/forge/portal-extensions/forge-speller/project.properties 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/project.properties 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,3 @@ +maven.repo.remote=http://repository.atlassian.com,http://www.ibiblio.org/maven,http://dist.codehaus.org/ +maven.junit.fork=yes +maven.war.src=${basedir}/src/web Added: trunk/forge/portal-extensions/forge-speller/project.xml =================================================================== --- trunk/forge/portal-extensions/forge-speller/project.xml 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/project.xml 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,59 @@ +<?xml version='1.0' encoding='ISO-8859-1'?> +<!-- + JBoss, the OpenSource J2EE webOS + Distributable under LGPL license. + See terms of license at gnu.org. + --> +<project> + <pomVersion>3</pomVersion> + <extend>../common.xml</extend> + <id>speller</id> + <name>speller servlet</name> + <currentVersion>1.0</currentVersion> + <build> + <sourceDirectory>src/java</sourceDirectory> + <resources> + <resource> + <directory>src/etc/</directory> + <include>**/*.js</include> + </resource> + <resource> + <directory>src/etc/</directory> + <include>**/*.html</include> + </resource> + </resources> + </build> + + <organization> + <name>Tomasz Szymanski</name> + <url>http://mamut.net.pl</url> + </organization> + <description></description> + <dependencies> + <dependency> + <groupId>tmate</groupId> + <artifactId>javasvn</artifactId> + <version>1.0</version> + <jar>javasvn.jar</jar> + </dependency> + + <dependency> + <groupId>tmate</groupId> + <artifactId>jsch</artifactId> + <version>1.0</version> + <jar>jsch.jar</jar> + </dependency> + + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.2</version> + </dependency> + + <dependency> + <groupId>jboss-forge</groupId> + <artifactId>forge-common</artifactId> + <version>1.0</version> + </dependency> + </dependencies> +</project> Added: trunk/forge/portal-extensions/forge-speller/src/etc/blank.html =================================================================== Added: trunk/forge/portal-extensions/forge-speller/src/etc/controlWindow.js =================================================================== --- trunk/forge/portal-extensions/forge-speller/src/etc/controlWindow.js 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/src/etc/controlWindow.js 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,86 @@ +//////////////////////////////////////////////////// +// controlWindow object +//////////////////////////////////////////////////// +function controlWindow( controlForm ) { + // private properties + this._form = controlForm; + + // public properties + this.windowType = "controlWindow"; + this.noSuggestionSelection = "- No suggestions -"; + // set up the properties for elements of the given control form + this.suggestionList = this._form.sugg; + this.evaluatedText = this._form.misword; + this.replacementText = this._form.txtsugg; + this.undoButton = this._form.btnUndo; + + // public methods + this.addSuggestion = addSuggestion; + this.clearSuggestions = clearSuggestions; + this.selectDefaultSuggestion = selectDefaultSuggestion; + this.resetForm = resetForm; + this.setSuggestedText = setSuggestedText; + this.enableUndo = enableUndo; + this.disableUndo = disableUndo; +} + +function resetForm() { + if( this._form ) { + this._form.reset(); + } +} + +function setSuggestedText() { + var slct = this.suggestionList; + var txt = this.replacementText; + var str = ""; + if( (slct.options[0].text) && slct.options[0].text != this.noSuggestionSelection ) { + str = slct.options[slct.selectedIndex].text; + } + txt.value = str; +} + +function selectDefaultSuggestion() { + var slct = this.suggestionList; + var txt = this.replacementText; + if( slct.options.length == 0 ) { + this.addSuggestion( this.noSuggestionSelection ); + } else { + slct.options[0].selected = true; + } + this.setSuggestedText(); +} + +function addSuggestion( sugg_text ) { + var slct = this.suggestionList; + if( sugg_text ) { + var i = slct.options.length; + var newOption = new Option( sugg_text, 'sugg_text'+i ); + slct.options[i] = newOption; + } +} + +function clearSuggestions() { + var slct = this.suggestionList; + for( var j = slct.length - 1; j > -1; j-- ) { + if( slct.options[j] ) { + slct.options[j] = null; + } + } +} + +function enableUndo() { + if( this.undoButton ) { + if( this.undoButton.disabled == true ) { + this.undoButton.disabled = false; + } + } +} + +function disableUndo() { + if( this.undoButton ) { + if( this.undoButton.disabled == false ) { + this.undoButton.disabled = true; + } + } +} Added: trunk/forge/portal-extensions/forge-speller/src/etc/controls.html =================================================================== --- trunk/forge/portal-extensions/forge-speller/src/etc/controls.html 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/src/etc/controls.html 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,153 @@ +<html> +<head> +<link rel="stylesheet" type="text/css" href="spellerStyle.css"/> + +<script src="controlWindow.js"></script> + +<script> +var spellerObject; +var controlWindowObj; + +if( parent.opener ) { + spellerObject = parent.opener.speller; +} + +function ignore_word() { + if( spellerObject ) { + spellerObject.ignoreWord(); + } +} + +function ignore_all() { + if( spellerObject ) { + spellerObject.ignoreAll(); + } +} + +function replace_word() { + if( spellerObject ) { + spellerObject.replaceWord(); + } +} + +function replace_all() { + if( spellerObject ) { + spellerObject.replaceAll(); + } +} + +function end_spell() { + if( spellerObject ) { + spellerObject.terminateSpell(); + } +} + +function undo() { + if( spellerObject ) { + spellerObject.undo(); + } +} + +function suggText() { + if( controlWindowObj ) { + controlWindowObj.setSuggestedText(); + } +} + +function init_spell() { + var controlForm = document.spellcheck; + + // create a new controlWindow object + controlWindowObj = new controlWindow( controlForm ); + + // call the init_spell() function in the parent frameset + if( parent.frames.length ) { + parent.init_spell( controlWindowObj ); + } else { + alert( 'This page was loaded outside of a frameset. It might not display properly' ); + } +} + +</script> + +</head> + +<body class="controlWindowBody" onLoad="init_spell();"> + +<form name="spellcheck"> + +<table border="0" cellpadding="0" cellspacing="0" border="0"> +<tr> + <td colspan="3" class="normalLabel">Not in dictionary:</td> +</tr> +<tr> + <td colspan="3"><input class="readonlyInput" type="text" name="misword" readonly /></td> +</tr> +<tr> + <td colspan="3" height="5"></td> +</tr> +<tr> + <td class="normalLabel">Change to:</td> +</tr> +<tr valign="top"> + <td> + <table border="0" cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="normalLabel"> + <input class="textDefault" type="text" name="txtsugg" /> + </td> + </tr> + <tr> + <td> + <select class="suggSlct" name="sugg" size="7" onChange="suggText();" onDblClick="replace_word();"> + <option></option> + </select> + </td> + </tr> + </table> + </td> + <td> </td> + <td> + <table border="0" cellpadding="0" cellspacing="0" border="0"> + <tr> + <td> + <input class="buttonDefault" type="button" value="Ignore" onClick="ignore_word();"> + </td> + <td> </td> + <td> + <input class="buttonDefault" type="button" value="Ignore All" onClick="ignore_all();"> + </td> + </tr> + <tr> + <td colspan="3" height="5"></td> + </tr> + <tr> + + <td> + <input class="buttonDefault" type="button" value="Replace" onClick="replace_word();"> + </td> + <td> </td> + <td> + <input class="buttonDefault" type="button" value="Replace All" onClick="replace_all();"> + </td> + </tr> + <tr> + <td colspan="3" height="5"></td> + </tr> + <tr> + <td> + <input class="buttonDefault" type="button" name="btnUndo" value="Undo" onClick="undo();" disabled> + </td> + <td> </td> + <td> + <input class="buttonDefault" type="button" value="Close" onClick="end_spell();"> + </td> + </tr> + </table> + </td> +</tr> +</table> + +</form> +</body> +</html> Added: trunk/forge/portal-extensions/forge-speller/src/etc/index.html =================================================================== --- trunk/forge/portal-extensions/forge-speller/src/etc/index.html 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/src/etc/index.html 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,137 @@ +<html> +<head> +<title>Spell Check Tester</title> + +<style type="text/css"> +body { + font-family:verdana, helvetica, arial, sans-serif; + font-size:small; + color:black; + background:white; + margin-top:0; + margin-left:0; + margin-right:0; +} +table { + color:#000000; + background:#FFFFFF; +} +td, p { + font-family:verdana, helvetica, arial, sans-serif; + font-size:small; +} +h1 { + font-family: sans-serif; + font-size: 150%; + font-weight: bold; + margin-top:.8em; + letter-spacing:2; +} +h2 { + font-family: sans-serif; + font-size: 125%; + font-weight: bold; + letter-spacing:2; +} +h3 { + font-family: sans-serif; + font-size: 100%; + font-weight: bold; + letter-spacing:2; +} +img { + vertical-align: middle; +} +a { + text-decoration: none; +} +a:hover { + color: blue; + background-color: #EBEBEB; +} +a.headerlink { + color: #EBEBEB; + /*text-decoration: none;*/ + background-color: #999999; +} +a.headerlink:hover { + color: #FFFFFF; + background-color: transparent; + text-decoration: underline; +} +a.imghref:hover { + background-color: transparent; +} +.smaller { + font-size: 75%; +} +</style> + +<script src="/speller/pages/spellChecker.js"></script> + +<script> +// +// openSpellChecker() +// +// this function is an example that illustrates the various ways you can invoke +// the the Speller Pages spell-checking process +// +function openSpellChecker() { + + // example 1. + // Pass in the text inputs or textarea inputs that you + // want to spell-check to the object's constructor, + // then call the openChecker() method. + /*var text1 = document.form1.text1; + var textarea1 = document.form1.textarea1; + var speller = new spellChecker( text1, textarea1 ); + speller.openChecker();*/ + + // example 2. + // Rather than passing in the form elements to the object's + // constructor, populate the object's textInputs property, + // then call the openChecker() method. + + /* + var speller = new spellChecker(); + var spellerInputs = new Array(); + for( var i = 0 ; i < document.form1.elements.length; i++ ) { + if( document.form1.elements[i].type.match( /^text/ )) { + spellerInputs[spellerInputs.length] = document.form1.elements[i]; + } + } + speller.textInputs = spellerInputs; + speller.openChecker(); + */ + + // example 3. + // use the spellCheckAll() method to check every text input + // and textarea input in every form in the HTML document. + // You can also use the checkTextBoxes() method or checkTextAreas() + // method instead of spellCheckAll() to check only text inputs + // or textarea inputs, respectively + + var speller = new spellChecker(); + speller.spellCheckAll(); + +} + +</script> +</head> + +<body> + +<h1>Speller Pages</h1> +<h3>This is only a demo of working Speller Pages ported to Labs</h3> +<form name="form1"> +<input type="text" name="text1" size="30"> +<br /> +<textarea name="textarea1" rows="10" cols="60"> +</textarea> +<br /> +<input type="button" value="Check Spelling" onClick="openSpellChecker();"/> +</form> + + +</body> +</html> Added: trunk/forge/portal-extensions/forge-speller/src/etc/spellChecker.js =================================================================== --- trunk/forge/portal-extensions/forge-speller/src/etc/spellChecker.js 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/src/etc/spellChecker.js 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,451 @@ +//////////////////////////////////////////////////// +// spellChecker.js +// +// spellChecker object +// +// This file is sourced on web pages that have a textarea object to evaluate +// for spelling. It includes the implementation for the spellCheckObject. +// +//////////////////////////////////////////////////// + + +// constructor +function spellChecker( textObject ) { + + // public properties - configurable + this.popUpUrl = '/speller/pages/spellchecker.html'; + //this.popUpUrl = 'http://www.netjs.com/speller/spellchecker.html' + this.popUpName = 'spellchecker'; + this.popUpProps = "menu=no,width=440,height=350,top=70,left=120,resizable=yes,status=yes"; + this.spellCheckScript = '/speller'; + //this.spellCheckScript = 'http://www.netjs.com/speller/server-scripts/spellchecker.php'; + //this.spellCheckScript = '/cgi-bin/spellchecker.pl'; + + // values used to keep track of what happened to a word + this.replWordFlag = "R"; // single replace + this.ignrWordFlag = "I"; // single ignore + this.replAllFlag = "RA"; // replace all occurances + this.ignrAllFlag = "IA"; // ignore all occurances + this.fromReplAll = "~RA"; // an occurance of a "replace all" word + this.fromIgnrAll = "~IA"; // an occurance of a "ignore all" word + // properties set at run time + this.wordFlags = new Array(); + this.currentTextIndex = 0; + this.currentWordIndex = 0; + this.spellCheckerWin = null; + this.controlWin = null; + this.wordWin = null; + this.textArea = textObject; // deprecated + this.textInputs = arguments; + + // private methods + this._spellcheck = _spellcheck; + this._getSuggestions = _getSuggestions; + this._setAsIgnored = _setAsIgnored; + this._getTotalReplaced = _getTotalReplaced; + this._setWordText = _setWordText; + this._getFormInputs = _getFormInputs; + + // public methods + this.openChecker = openChecker; + this.startCheck = startCheck; + this.checkTextBoxes = checkTextBoxes; + this.checkTextAreas = checkTextAreas; + this.spellCheckAll = spellCheckAll; + this.ignoreWord = ignoreWord; + this.ignoreAll = ignoreAll; + this.replaceWord = replaceWord; + this.replaceAll = replaceAll; + this.terminateSpell = terminateSpell; + this.undo = undo; + + // set the current window's "speller" property to the instance of this class. + // this object can now be referenced by child windows/frames. + window.speller = this; +} + +// call this method to check all text boxes (and only text boxes) in the HTML document +function checkTextBoxes() { + this.textInputs = this._getFormInputs( "^text$" ); + this.openChecker(); +} + +// call this method to check all textareas (and only textareas ) in the HTML document +function checkTextAreas() { + this.textInputs = this._getFormInputs( "^textarea$" ); + this.openChecker(); +} + +// call this method to check all text boxes and textareas in the HTML document +function spellCheckAll() { + this.textInputs = this._getFormInputs( "^text(area)?$" ); + this.openChecker(); +} + +// call this method to check text boxe(s) and/or textarea(s) that were passed in to the +// object's constructor or to the textInputs property +function openChecker() { + this.spellCheckerWin = window.open( this.popUpUrl, this.popUpName, this.popUpProps ); + if( !this.spellCheckerWin.opener ) { + this.spellCheckerWin.opener = window; + } +} + +function startCheck( wordWindowObj, controlWindowObj ) { + + // set properties from args + this.wordWin = wordWindowObj; + this.controlWin = controlWindowObj; + + // reset properties + this.wordWin.resetForm(); + this.controlWin.resetForm(); + this.currentTextIndex = 0; + this.currentWordIndex = 0; + // initialize the flags to an array - one element for each text input + this.wordFlags = new Array( this.wordWin.textInputs.length ); + // each element will be an array that keeps track of each word in the text + for( var i=0; i<this.wordFlags.length; i++ ) { + this.wordFlags[i] = []; + } + + // start + this._spellcheck(); + + return true; +} + +function ignoreWord() { + var wi = this.currentWordIndex; + var ti = this.currentTextIndex; + if( !this.wordWin ) { + alert( 'Error: Word frame not available.' ); + return false; + } + if( !this.wordWin.getTextVal( ti, wi )) { + alert( 'Error: "Not in dictionary" text is missing.' ); + return false; + } + // set as ignored + if( this._setAsIgnored( ti, wi, this.ignrWordFlag )) { + this.currentWordIndex++; + this._spellcheck(); + } +} + +function ignoreAll() { + var wi = this.currentWordIndex; + var ti = this.currentTextIndex; + if( !this.wordWin ) { + alert( 'Error: Word frame not available.' ); + return false; + } + // get the word that is currently being evaluated. + var s_word_to_repl = this.wordWin.getTextVal( ti, wi ); + if( !s_word_to_repl ) { + alert( 'Error: "Not in dictionary" text is missing' ); + return false; + } + + // set this word as an "ignore all" word. + this._setAsIgnored( ti, wi, this.ignrAllFlag ); + + // loop through all the words after this word + for( var i = ti; i < this.wordWin.textInputs.length; i++ ) { + for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) { + if(( i == ti && j > wi ) || i > ti ) { + // future word: set as "from ignore all" if + // 1) do not already have a flag and + // 2) have the same value as current word + if(( this.wordWin.getTextVal( i, j ) == s_word_to_repl ) + && ( !this.wordFlags[i][j] )) { + this._setAsIgnored( i, j, this.fromIgnrAll ); + } + } + } + } + + // finally, move on + this.currentWordIndex++; + this._spellcheck(); +} + +function replaceWord() { + var wi = this.currentWordIndex; + var ti = this.currentTextIndex; + if( !this.wordWin ) { + alert( 'Error: Word frame not available.' ); + return false; + } + if( !this.wordWin.getTextVal( ti, wi )) { + alert( 'Error: "Not in dictionary" text is missing' ); + return false; + } + if( !this.controlWin.replacementText ) { + return; + } + var txt = this.controlWin.replacementText; + if( txt.value ) { + var newspell = new String( txt.value ); + if( this._setWordText( ti, wi, newspell, this.replWordFlag )) { + this.currentWordIndex++; + this._spellcheck(); + } + } +} + +function replaceAll() { + var ti = this.currentTextIndex; + var wi = this.currentWordIndex; + if( !this.wordWin ) { + alert( 'Error: Word frame not available.' ); + return false; + } + var s_word_to_repl = this.wordWin.getTextVal( ti, wi ); + if( !s_word_to_repl ) { + alert( 'Error: "Not in dictionary" text is missing' ); + return false; + } + var txt = this.controlWin.replacementText; + if( !txt.value ) return; + var newspell = new String( txt.value ); + + // set this word as a "replace all" word. + this._setWordText( ti, wi, newspell, this.replAllFlag ); + + // loop through all the words after this word + for( var i = ti; i < this.wordWin.textInputs.length; i++ ) { + for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) { + if(( i == ti && j > wi ) || i > ti ) { + // future word: set word text to s_word_to_repl if + // 1) do not already have a flag and + // 2) have the same value as s_word_to_repl + if(( this.wordWin.getTextVal( i, j ) == s_word_to_repl ) + && ( !this.wordFlags[i][j] )) { + this._setWordText( i, j, newspell, this.fromReplAll ); + } + } + } + } + + // finally, move on + this.currentWordIndex++; + this._spellcheck(); +} + +function terminateSpell() { + // called when we have reached the end of the spell checking. + var msg = "Spell check complete:\n\n"; + var numrepl = this._getTotalReplaced(); + if( numrepl == 0 ) { + // see if there were no misspellings to begin with + if( !this.wordWin ) { + msg = ""; + } else { + if( this.wordWin.totalMisspellings() ) { + msg += "No words changed."; + } else { + msg += "No misspellings found."; + } + } + } else if( numrepl == 1 ) { + msg += "One word changed."; + } else { + msg += numrepl + " words changed."; + } + if( msg ) { + msg += "\n"; + alert( msg ); + } + + if( numrepl > 0 ) { + // update the text field(s) on the opener window + for( var i = 0; i < this.textInputs.length; i++ ) { + // this.textArea.value = this.wordWin.text; + if( this.wordWin ) { + if( this.wordWin.textInputs[i] ) { + this.textInputs[i].value = this.wordWin.textInputs[i]; + } + } + } + } + + // return back to the calling window + this.spellCheckerWin.close(); + + return true; +} + +function undo() { + // skip if this is the first word! + var ti = this.currentTextIndex; + var wi = this.currentWordIndex + + if( this.wordWin.totalPreviousWords( ti, wi ) > 0 ) { + this.wordWin.removeFocus( ti, wi ); + + // go back to the last word index that was acted upon + do { + // if the current word index is zero then reset the seed + if( this.currentWordIndex == 0 && this.currentTextIndex > 0 ) { + this.currentTextIndex--; + this.currentWordIndex = this.wordWin.totalWords( this.currentTextIndex )-1; + if( this.currentWordIndex < 0 ) this.currentWordIndex = 0; + } else { + if( this.currentWordIndex > 0 ) { + this.currentWordIndex--; + } + } + } while ( + this.wordWin.totalWords( this.currentTextIndex ) == 0 + || this.wordFlags[this.currentTextIndex][this.currentWordIndex] == this.fromIgnrAll + || this.wordFlags[this.currentTextIndex][this.currentWordIndex] == this.fromReplAll + ); + + var text_idx = this.currentTextIndex; + var idx = this.currentWordIndex; + var preReplSpell = this.wordWin.originalSpellings[text_idx][idx]; + + // if we got back to the first word then set the Undo button back to disabled + if( this.wordWin.totalPreviousWords( text_idx, idx ) == 0 ) { + this.controlWin.disableUndo(); + } + + // examine what happened to this current word. + switch( this.wordFlags[text_idx][idx] ) { + // replace all: go through this and all the future occurances of the word + // and revert them all to the original spelling and clear their flags + case this.replAllFlag : + for( var i = text_idx; i < this.wordWin.textInputs.length; i++ ) { + for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) { + if(( i == text_idx && j >= idx ) || i > text_idx ) { + var origSpell = this.wordWin.originalSpellings[i][j]; + if( origSpell == preReplSpell ) { + this._setWordText ( i, j, origSpell, undefined ); + } + } + } + } + break; + + // ignore all: go through all the future occurances of the word + // and clear their flags + case this.ignrAllFlag : + for( var i = text_idx; i < this.wordWin.textInputs.length; i++ ) { + for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) { + if(( i == text_idx && j >= idx ) || i > text_idx ) { + var origSpell = this.wordWin.originalSpellings[i][j]; + if( origSpell == preReplSpell ) { + this.wordFlags[i][j] = undefined; + } + } + } + } + break; + + // replace: revert the word to its original spelling + case this.replWordFlag : + this._setWordText ( text_idx, idx, preReplSpell, undefined ); + break; + } + + // For all four cases, clear the wordFlag of this word. re-start the process + this.wordFlags[text_idx][idx] = undefined; + this._spellcheck(); + } +} + +function _spellcheck() { + var ww = this.wordWin; + + // check if this is the last word in the current text element + if( this.currentWordIndex == ww.totalWords( this.currentTextIndex) ) { + this.currentTextIndex++; + this.currentWordIndex = 0; + // keep going if we're not yet past the last text element + if( this.currentTextIndex < this.wordWin.textInputs.length ) { + this._spellcheck(); + return; + } else { + this.terminateSpell(); + return; + } + } + + // if this is after the first one make sure the Undo button is enabled + if( this.currentWordIndex > 0 ) { + this.controlWin.enableUndo(); + } + + // skip the current word if it has already been worked on + if( this.wordFlags[this.currentTextIndex][this.currentWordIndex] ) { + // increment the global current word index and move on. + this.currentWordIndex++; + this._spellcheck(); + } else { + var evalText = ww.getTextVal( this.currentTextIndex, this.currentWordIndex ); + if( evalText ) { + this.controlWin.evaluatedText.value = evalText; + ww.setFocus( this.currentTextIndex, this.currentWordIndex ); + this._getSuggestions( this.currentTextIndex, this.currentWordIndex ); + } + } +} + +function _getSuggestions( text_num, word_num ) { + this.controlWin.clearSuggestions(); + // add suggestion in list for each suggested word. + // get the array of suggested words out of the + // three-dimensional array containing all suggestions. + var a_suggests = this.wordWin.suggestions[text_num][word_num]; + if( a_suggests ) { + // got an array of suggestions. + for( var ii = 0; ii < a_suggests.length; ii++ ) { + this.controlWin.addSuggestion( a_suggests[ii] ); + } + } + this.controlWin.selectDefaultSuggestion(); +} + +function _setAsIgnored( text_num, word_num, flag ) { + // set the UI + this.wordWin.removeFocus( text_num, word_num ); + // do the bookkeeping + this.wordFlags[text_num][word_num] = flag; + return true; +} + +function _getTotalReplaced() { + var i_replaced = 0; + for( var i = 0; i < this.wordFlags.length; i++ ) { + for( var j = 0; j < this.wordFlags[i].length; j++ ) { + if(( this.wordFlags[i][j] == this.replWordFlag ) + || ( this.wordFlags[i][j] == this.replAllFlag ) + || ( this.wordFlags[i][j] == this.fromReplAll )) { + i_replaced++; + } + } + } + return i_replaced; +} + +function _setWordText( text_num, word_num, newText, flag ) { + // set the UI and form inputs + this.wordWin.setText( text_num, word_num, newText ); + // keep track of what happened to this word: + this.wordFlags[text_num][word_num] = flag; + return true; +} + +function _getFormInputs( inputPattern ) { + var inputs = new Array(); + for( var i = 0; i < document.forms.length; i++ ) { + for( var j = 0; j < document.forms[i].elements.length; j++ ) { + if( document.forms[i].elements[j].type.match( inputPattern )) { + inputs[inputs.length] = document.forms[i].elements[j]; + } + } + } + return inputs; +} + Added: trunk/forge/portal-extensions/forge-speller/src/etc/spellchecker.html =================================================================== --- trunk/forge/portal-extensions/forge-speller/src/etc/spellchecker.html 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/src/etc/spellchecker.html 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,71 @@ + +<script> + +var wordWindow = null; +var controlWindow = null; + +function init_spell( spellerWindow ) { + + if( spellerWindow ) { + if( spellerWindow.windowType == "wordWindow" ) { + wordWindow = spellerWindow; + } else if ( spellerWindow.windowType == "controlWindow" ) { + controlWindow = spellerWindow; + } + } + + if( controlWindow && wordWindow ) { + // populate the speller object and start it off! + var speller = opener.speller; + wordWindow.speller = speller; + speller.startCheck( wordWindow, controlWindow ); + } +} + +// encodeForPost +function encodeForPost( str ) { + var s = new String( str ); + s = encodeURIComponent( s ); + // additionally encode single quotes to evade any PHP + // magic_quotes_gpc setting (it inserts escape characters and + // therefore skews the btye positions of misspelled words) + return s.replace( /\'/g, '%27' ); +} + +// post the text area data to the script that populates the speller +function postWords() { + var bodyDoc = window.frames[0].document; + bodyDoc.open(); + bodyDoc.write('<html>'); + bodyDoc.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'); + bodyDoc.write('<link rel="stylesheet" type="text/css" href="spellerStyle.css"/>'); + if (opener) { + var speller = opener.speller; + bodyDoc.write('<body class="normalText" onLoad="document.forms[0].submit();">'); + bodyDoc.write('<p>Spell check in progress...</p>'); + bodyDoc.write('<form action="'+speller.spellCheckScript+'" method="get">'); + for( var i = 0; i < speller.textInputs.length; i++ ) { + bodyDoc.write('<input type="hidden" name="textinputs[]" value="'+encodeForPost(speller.textInputs[i].value)+'">'); + } + bodyDoc.write('</form>'); + bodyDoc.write('</body>'); + } else { + bodyDoc.write('<body class="normalText">'); + bodyDoc.write('<p><b>This page cannot be displayed</b></p><p>The window was not opened from another window.</p>'); + bodyDoc.write('</body>'); + } + bodyDoc.write('</html>'); + bodyDoc.close(); +} +</script> + +<html> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> +<head> +<title>Speller Pages</title> +</head> +<frameset rows="*,201" onLoad="postWords();"> +<frame src="blank.html"> +<frame src="controls.html"> +</frameset> +</html> Added: trunk/forge/portal-extensions/forge-speller/src/etc/spellerStyle.css =================================================================== --- trunk/forge/portal-extensions/forge-speller/src/etc/spellerStyle.css 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/src/etc/spellerStyle.css 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,47 @@ +.blend { + font-family: courier new; + font-size: 10pt; + border: 0; + margin-bottom:-1; +} +.normalLabel { + font-size:8pt; +} +.normalText { + font-family:arial, helvetica, sans-serif; + font-size:10pt; + color:000000; + background-color:FFFFFF; +} +.plainText { + font-family: courier new, courier, monospace; + font-size: 10pt; + color:000000; + background-color:FFFFFF; +} +.controlWindowBody { + font-family:arial, helvetica, sans-serif; + font-size:8pt; + color:000000; + background-color:DADADA; +} +.readonlyInput { + background-color:DADADA; + color:000000; + font-size:8pt; + width:392px; +} +.textDefault { + font-size:8pt; + width: 200px; +} +.buttonDefault { + width:90px; + height:22px; + font-size:8pt; +} +.suggSlct { + width:200px; + margin-top:2; + font-size:8pt; +} \ No newline at end of file Added: trunk/forge/portal-extensions/forge-speller/src/etc/wordWindow.js =================================================================== --- trunk/forge/portal-extensions/forge-speller/src/etc/wordWindow.js 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/src/etc/wordWindow.js 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,269 @@ +//////////////////////////////////////////////////// +// wordWindow object +//////////////////////////////////////////////////// +function wordWindow() { + // private properties + this._forms = []; + + // private methods + this._getWordObject = _getWordObject; + //this._getSpellerObject = _getSpellerObject; + this._wordInputStr = _wordInputStr; + this._adjustIndexes = _adjustIndexes; + this._isWordChar = _isWordChar; + this._lastPos = _lastPos; + + // public properties + this.wordChar = /[a-zA-Z]/; + this.windowType = "wordWindow"; + this.originalSpellings = new Array(); + this.suggestions = new Array(); + this.checkWordBgColor = "pink"; + this.normWordBgColor = "white"; + this.text = ""; + this.textInputs = new Array(); + this.indexes = new Array(); + //this.speller = this._getSpellerObject(); + + // public methods + this.resetForm = resetForm; + this.totalMisspellings = totalMisspellings; + this.totalWords = totalWords; + this.totalPreviousWords = totalPreviousWords; + //this.getTextObjectArray = getTextObjectArray; + this.getTextVal = getTextVal; + this.setFocus = setFocus; + this.removeFocus = removeFocus; + this.setText = setText; + //this.getTotalWords = getTotalWords; + this.writeBody = writeBody; + this.printForHtml = printForHtml; +} + +function resetForm() { + if( this._forms ) { + for( var i = 0; i < this._forms.length; i++ ) { + this._forms[i].reset(); + } + } + return true; +} + +function totalMisspellings() { + var total_words = 0; + for( var i = 0; i < this.textInputs.length; i++ ) { + total_words += this.totalWords( i ); + } + return total_words; +} + +function totalWords( textIndex ) { + return this.originalSpellings[textIndex].length; +} + +function totalPreviousWords( textIndex, wordIndex ) { + var total_words = 0; + for( var i = 0; i <= textIndex; i++ ) { + for( var j = 0; j < this.totalWords( i ); j++ ) { + if( i == textIndex && j == wordIndex ) { + break; + } else { + total_words++; + } + } + } + return total_words; +} + +//function getTextObjectArray() { +// return this._form.elements; +//} + +function getTextVal( textIndex, wordIndex ) { + var word = this._getWordObject( textIndex, wordIndex ); + if( word ) { + return word.value; + } +} + +function setFocus( textIndex, wordIndex ) { + var word = this._getWordObject( textIndex, wordIndex ); + if( word ) { + if( word.type == "text" ) { + word.focus(); + word.style.backgroundColor = this.checkWordBgColor; + } + } +} + +function removeFocus( textIndex, wordIndex ) { + var word = this._getWordObject( textIndex, wordIndex ); + if( word ) { + if( word.type == "text" ) { + word.blur(); + word.style.backgroundColor = this.normWordBgColor; + } + } +} + +function setText( textIndex, wordIndex, newText ) { + var word = this._getWordObject( textIndex, wordIndex ); + var beginStr; + var endStr; + if( word ) { + var pos = this.indexes[textIndex][wordIndex]; + var oldText = word.value; + // update the text given the index of the string + beginStr = this.textInputs[textIndex].substring( 0, pos ); + endStr = this.textInputs[textIndex].substring( + pos + oldText.length, + this.textInputs[textIndex].length + ); + this.textInputs[textIndex] = beginStr + newText + endStr; + + // adjust the indexes on the stack given the differences in + // length between the new word and old word. + var lengthDiff = newText.length - oldText.length; + this._adjustIndexes( textIndex, wordIndex, lengthDiff ); + + word.size = newText.length; + word.value = newText; + this.removeFocus( textIndex, wordIndex ); + } +} + + +function writeBody() { + var d = window.document; + var is_html = false; + + d.open(); + + // iterate through each text input. + for( var txtid = 0; txtid < this.textInputs.length; txtid++ ) { + var end_idx = 0; + var begin_idx = 0; + d.writeln( '<form name="textInput'+txtid+'">' ); + var wordtxt = this.textInputs[txtid]; + this.indexes[txtid] = []; + + if( wordtxt ) { + var orig = this.originalSpellings[txtid]; + if( !orig ) break; + + //!!! plain text, or HTML mode? + d.writeln( '<div class="plainText">' ); + // iterate through each occurrence of a misspelled word. + for( var i = 0; i < orig.length; i++ ) { + // find the position of the current misspelled word, + // starting at the last misspelled word. + // and keep looking if it's a substring of another word + do { + begin_idx = wordtxt.indexOf( orig[i], end_idx ); + end_idx = begin_idx + orig[i].length; + // word not found? messed up! + if( begin_idx == -1 ) break; + // look at the characters immediately before and after + // the word. If they are word characters we'll keep looking. + var before_char = wordtxt.charAt( begin_idx - 1 ); + var after_char = wordtxt.charAt( end_idx ); + } while ( + this._isWordChar( before_char ) + || this._isWordChar( after_char ) + ); + + // keep track of its position in the original text. + this.indexes[txtid][i] = begin_idx; + + // write out the characters before the current misspelled word + for( var j = this._lastPos( txtid, i ); j < begin_idx; j++ ) { + // !!! html mode? make it html compatible + d.write( this.printForHtml( wordtxt.charAt( j ))); + } + + // write out the misspelled word. + d.write( this._wordInputStr( orig[i] )); + + // if it's the last word, write out the rest of the text + if( i == orig.length-1 ){ + d.write( printForHtml( wordtxt.substr( end_idx ))); + } + } + + d.writeln( '</div>' ); + + } + d.writeln( '</form>' ); + } + //for ( var j = 0; j < d.forms.length; j++ ) { + // alert( d.forms[j].name ); + // for( var k = 0; k < d.forms[j].elements.length; k++ ) { + // alert( d.forms[j].elements[k].name + ": " + d.forms[j].elements[k].value ); + // } + //} + + // set the _forms property + this._forms = d.forms; + d.close(); +} + +// return the character index in the full text after the last word we evaluated +function _lastPos( txtid, idx ) { + if( idx > 0 ) + return this.indexes[txtid][idx-1] + this.originalSpellings[txtid][idx-1].length; + else + return 0; +} + +function printForHtml( n ) { + var htmlstr = n; + if( htmlstr.length == 1 ) { + // do simple case statement if it's just one character + switch ( n ) { + case "\n": + htmlstr = '<br/>'; + break; + case "<": + htmlstr = '<'; + break; + case ">": + htmlstr = '>'; + break; + } + return htmlstr; + } else { + htmlstr = htmlstr.replace( /</g, '<' ); + htmlstr = htmlstr.replace( />/g, '>' ); + htmlstr = htmlstr.replace( /\n/g, '<br/>' ); + return htmlstr; + } +} + +function _isWordChar( letter ) { + if( letter.search( this.wordChar ) == -1 ) { + return false; + } else { + return true; + } +} + +function _getWordObject( textIndex, wordIndex ) { + if( this._forms[textIndex] ) { + if( this._forms[textIndex].elements[wordIndex] ) { + return this._forms[textIndex].elements[wordIndex]; + } + } + return null; +} + +function _wordInputStr( word ) { + var str = '<input readonly '; + str += 'class="blend" type="text" value="' + word + '" size="' + word.length + '">'; + return str; +} + +function _adjustIndexes( textIndex, wordIndex, lengthDiff ) { + for( var i = wordIndex + 1; i < this.originalSpellings[textIndex].length; i++ ) { + this.indexes[textIndex][i] = this.indexes[textIndex][i] + lengthDiff; + } +} Added: trunk/forge/portal-extensions/forge-speller/src/java/org/jboss/labs/speller/SpellerServlet.java =================================================================== --- trunk/forge/portal-extensions/forge-speller/src/java/org/jboss/labs/speller/SpellerServlet.java 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/src/java/org/jboss/labs/speller/SpellerServlet.java 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,334 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.labs.speller; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.net.URLDecoder; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * This file was orignally written in PHP by James Shimada, admin of the Speller + * Pages project http://sourceforge.net/projects/spellerpages/ and then ported + * to work as servlet by Tomasz Szymanski + * + * James Shimada did really great work. + * + * @author James Shimada jsh...@us... + * @author Tomasz Szymanski tom...@jb... + * + */ +public class SpellerServlet extends HttpServlet { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private static final String SERVLET_PREFIX = "/speller/"; + + private String spellercss = "/speller/pages/spellerStyle.css"; + + private String word_win_src = "/speller/pages/wordWindow.js"; + + private String pageLocation = "/home/tomek/tmp/spellerpages-0.5.1/speller/"; + + private String[] textinputs = null; // $_POST['textinputs']; # array + + private String aspell_prog = "aspell"; + + private String lang = "en_US"; + + private String aspell_opts = "-a --lang=" + lang + " --encoding=utf-8"; + + private String input_separator = "A"; + + /* + * set the JavaScript variable to the submitted text. textinputs is an + * array, each element corresponding to the (url-encoded) value of the text + * control submitted for spell-checking + */ + + private void print_textinputs_var(PrintWriter writer) { + for (int i = 0; (textinputs != null) && (i < textinputs.length); i++ /* + * as + * $key=>$val + */) { + textinputs[i] = textinputs[i].replaceAll("'", "%27"); + writer.write("textinputs[" + i + "] = decodeURIComponent(\"" + + textinputs[i] + "\");\n"); + } + + } // make declarations for the text input index + + private void print_textindex_decl(int text_input_idx, PrintWriter writer) { + writer.write("words[" + text_input_idx + "] = [];\n"); + writer.write("suggs[" + text_input_idx + "] = [];\n"); + } + + // set an element of the JavaScript 'words' array to a misspelled word + private void print_words_elem(String word, int index, int textInputIdx, + PrintWriter writer) { + writer.write("words[" + textInputIdx + "][" + index + "] = '" + + escape_quote(word) + "';\n"); + } + + // set an element of the JavaScript 'suggs' array to a list of suggestions + private void print_suggs_elem(String[] suggs, int index, int textInputIdx, + PrintWriter writer) { + writer.write("suggs[" + textInputIdx + "][" + index + "] = ["); + + for (int i = 0; i < suggs.length; i++ /* as $key=>$val */) { + if (!suggs[i].equals("")) { + writer.write("'" + escape_quote(suggs[i]) + "'"); + if (i + 1 < suggs.length) { + writer.write(", "); + } + } + } + + writer.write("];\n"); + } + + // escape single quote + private String escape_quote(String str) { + return str.replaceAll("'", "\\\\'"); + } + + // handle a server-side error. + private void error_handler(String err, PrintWriter writer) { + writer.write("error = '" + escape_quote(err) + "';\n"); + } + + /* + * get the list of misspelled words. Put the results in the javascript words + * array for each misspelled word, get suggestions and put in the javascript + * suggs array + */ + + private void print_checker_results(PrintWriter writer) { + + String aspell_err = ""; + // create temp file + File tempfile; + try { + tempfile = File.createTempFile("to_translate", "aspell_data_"); + } catch (IOException e1) { + error_handler("Couldn't create tmpfile", writer); + e1.printStackTrace(); + return; + } + // $tempfile = tempnam( tempfiledir, "aspelldata" ); + + try { + // open temp file, add the submitted text. + // FileOutputStream fos = new FileOutputStream(tempfile); + PrintWriter w = new PrintWriter(tempfile); + + for (int i = 0; i < textinputs.length; i++) { + String text = URLDecoder.decode(textinputs[i], "utf-8"); + String[] lines = text.split("\n"); + w.write("%\n"); // exit terse mode + w.write("^" + input_separator + "\n"); + w.write("!\n"); // enter terse mode + + for (int j = 0; j < lines.length; j++/* as $key=>$value */) { + // use carat on each line to escape possible aspell commands + w.write("^" + lines[j] + "\n"); + } + + } + + w.close(); + + // exec aspell command - redirect STDERR to STDOUT + String cmd = aspell_prog + " " + aspell_opts; + + try { + int chr; + String aspellret = ""; + + Process proc = Runtime.getRuntime().exec(cmd); + + BufferedInputStream cmdout = new BufferedInputStream(proc + .getInputStream()); + + OutputStream out = proc.getOutputStream(); + + InputStream in = new FileInputStream(tempfile); + + while ((chr = in.read()) != -1) + out.write(chr); + + in.close(); + out.close(); + + while ((chr = cmdout.read()) != -1) { + aspellret += (char) chr; + } + aspellret += "\n"; + + String[] linesout = aspellret.split("\n"); + + int index = 0; + int text_input_index = -1; + // parse each line of aspell return + for (int i = 0; i < linesout.length; i++/* as $key=>$val */) { + if (linesout[i].length() > 0) { + + String[] suggs = null; + + char chardesc = linesout[i].charAt(0); + // if '&', then not in dictionary but has suggestions + // if '#', then not in dictionary and no suggestions + // if '*', then it is a delimiter between text inputs + // if '@' then version info + + if ((chardesc == '&') || (chardesc == '#')) { + String[] line = linesout[i].split(" ", 5); + print_words_elem(line[1], index, text_input_index, + writer); + if (line.length > 4) { + suggs = line[4].split(", "); + } else { + suggs = new String[0]; + } + print_suggs_elem(suggs, index, text_input_index, + writer); + index++; + } else if (chardesc == '*') { + text_input_index++; + print_textindex_decl(text_input_index, writer); + index = 0; + } else if ((chardesc != '@') && (chardesc != '\0')) { + // assume this is error output + aspell_err += linesout[i]; + } + } + } + if (!aspell_err.equals("")) { + aspell_err = "Error executing " + cmd + "\\n" + aspell_err; + error_handler(aspell_err, writer); + } + } catch (Exception e) { + e.printStackTrace(); + error_handler("System error: Aspell program execution failed (" + + cmd + ")", writer); + } + } catch (Exception e) { + error_handler("System error: Could not open file '" + tempfile + + "' for writing", writer); + } + + // close temp file, delete file + tempfile.delete(); + } + + @Override + protected void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + + response.setContentType("text/html"); + PrintWriter writer = response.getWriter(); + + String URI = request.getRequestURI(); + + if ((URI.equals(SERVLET_PREFIX)) + && (request.getParameterValues("textinputs[]") == null)) { + InputStream fin = SpellerServlet.class + .getResourceAsStream("/index.html"); + + int chr; + + while ((chr = fin.read()) != -1) { + writer.write(chr); + } + + fin.close(); + } else if (URI.startsWith(SERVLET_PREFIX + "pages/")) { + String[] t = URI.split("/"); + + InputStream fin = SpellerServlet.class.getResourceAsStream("/" + + t[t.length - 1]); + + int chr; + + while ((chr = fin.read()) != -1) { + writer.write(chr); + } + + fin.close(); + } else { + + textinputs = request.getParameterValues("textinputs[]"); + + writer + .write("<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<link rel=\"stylesheet\" type=\"text/css\" href=\"" + + spellercss + + "\" />\n<script language=\"javascript\" src=\"" + + word_win_src + + "\"></script>\n<script language=\"javascript\">\n"); + writer.write("var suggs = new Array();\n" + + "var words = new Array();\n" + + "var textinputs = new Array();\n" + "var error;\n"); + + print_textinputs_var(writer); + + print_checker_results(writer); + + writer.write("\nvar wordWindowObj = new wordWindow();\n" + + "wordWindowObj.originalSpellings = words;\n" + + "wordWindowObj.suggestions = suggs;\n" + + "wordWindowObj.textInputs = textinputs;\n\n"); + + writer + .write("function init_spell() {\n" + + " // check if any error occured during server-side processing\n" + + " if( error ) {\n" + + " alert( error );\n" + + " } else {\n" + + " // call the init_spell() function in the parent frameset\n" + + " if (parent.frames.length) {\n" + + " parent.init_spell( wordWindowObj );\n" + + " } else {\n" + + " alert('This page was loaded outside of a frameset. It might not display properly');\n" + + " }\n" + " }\n" + "}\n"); + + writer.write("</script></head>\n" + + "<body onLoad=\"init_spell();\">\n" + + "<script type=\"text/javascript\">\n" + + "wordWindowObj.writeBody();\n" + "</script>\n" + + "</body>\n" + "</html>\n"); + } + + writer.close(); + } +} \ No newline at end of file Added: trunk/forge/portal-extensions/forge-speller/src/web/WEB-INF/jsp/normal.jsp =================================================================== --- trunk/forge/portal-extensions/forge-speller/src/web/WEB-INF/jsp/normal.jsp 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/src/web/WEB-INF/jsp/normal.jsp 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,26 @@ +<!-- + JBoss, the OpenSource J2EE webOS + Distributable under LGPL license. + See terms of license at gnu.org. + --> +<%@ page language="java" extends="org.jboss.portal.core.servlet.jsp.PortalJsp" %> + <%@ taglib uri="/WEB-INF/tld/portlet.tld" prefix="n" %> + <%@ taglib uri="/WEB-INF/tld/forge.tld" prefix="forge" %> + <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %> + <%@ page isELIgnored ="false" %> + <portlet:defineObjects/> + +<div id="LeftAds"> + +<n:iterate ctx="menuentry"> + <!-- iterated menuentry --> + <div class="item"> + <a href="${n:out("menuentry.url")}"><img src="<forge:imagePath src="ads/images/${n:out('menuentry.name')}"/>" + width="175" height="64" border="0" /> + </a> + </div> +</n:iterate> + +</div> + + \ No newline at end of file Added: trunk/forge/portal-extensions/forge-speller/src/web/WEB-INF/tld/forge.tld =================================================================== --- trunk/forge/portal-extensions/forge-speller/src/web/WEB-INF/tld/forge.tld 2005-11-11 23:57:37 UTC (rev 1562) +++ trunk/forge/portal-extensions/forge-speller/src/web/WEB-INF/tld/forge.tld 2005-11-12 12:58:50 UTC (rev 1563) @@ -0,0 +1,139 @@ +<taglib xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd" + version="2.0"> + <!-- + JBoss, the OpenSource J2EE webOS + Distributable under LGPL license. + See terms of license at gnu.org. + --> + <tlib-version>1.1</tlib-version> + <jsp-version>2.0</jsp-version> + <shortname>forge</shortname> + <info>Forge tags</info> + + <tag> + <name>pageURL</name> + <tagclass>org.jboss.forge.common.taglib.PageURLTag</tagclass> + <attribute> + <name>page</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + <attribute> + <name>form</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> + + <tag> + <name>param</name> + <tagclass>org.jboss.forge.common.taglib.ParamTag</tagclass> + <attribute> + <name>name</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + <attribute> + <name>value</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> + + <tag> + <name>wikiURL</name> + <tagclass>org.jboss.forge.common.taglib.WikiURLTag</tagclass> + <attribute> + <name>page</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> + + <tag> + <name>freezoneURL</name> + <tagclass>org.jboss.forge.common.taglib.FreezoneURLTag</tagclass> + <attribute> + <name>page</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> + + <tag> + <name>projectURL</name> + <tagclass>org.jboss.forge.common.taglib.ProjectURLTag</tagclass> + <attribute> + <name>project</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + <attribute> + <name>page</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + <attribute> + <name>form</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> + + <tag> + <name>categoryURL</name> + <tagclass>org.jboss.forge.common.taglib.CategoryURLTag</tagclass> + <attribute> + <name>category</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + <attribute> + <name>form</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> + + <tag> + <name>selectedProject</name> + <tagclass>org.jboss.forge.common.taglib.SelectedProjectTag</tagcl... [truncated message content] |
From: <jbo...@li...> - 2005-11-11 23:57:44
|
Author: adamw Date: 2005-11-11 18:57:37 -0500 (Fri, 11 Nov 2005) New Revision: 1562 Modified: trunk/forge/portal-extensions/forge-feeds/src/java/org/jboss/forge/feeds/FeedsDescriptor.java trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/NodeList.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-15 Modified: trunk/forge/portal-extensions/forge-feeds/src/java/org/jboss/forge/feeds/FeedsDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-feeds/src/java/org/jboss/forge/feeds/FeedsDescriptor.java 2005-11-11 23:51:29 UTC (rev 1561) +++ trunk/forge/portal-extensions/forge-feeds/src/java/org/jboss/forge/feeds/FeedsDescriptor.java 2005-11-11 23:57:37 UTC (rev 1562) @@ -397,7 +397,7 @@ if (searchNameAttr == null) searchNameAttr = "nodes"; - vc.put(searchNameAttr, list.toList()); + vc.put(searchNameAttr, list); } catch (Exception e) { log.warn("Error generating shotoku feed " + feedName + ".", e); Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/NodeList.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/NodeList.java 2005-11-11 23:51:29 UTC (rev 1561) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/NodeList.java 2005-11-11 23:57:37 UTC (rev 1562) @@ -21,7 +21,6 @@ */ package org.jboss.shotoku; -import java.io.Writer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -29,9 +28,6 @@ import java.util.Iterator; import java.util.List; -import org.apache.velocity.VelocityContext; -import org.jboss.shotoku.exceptions.RepositoryException; - /** * A class representing a list of nodes and providing the possibility to * manipulate these nodes. @@ -39,7 +35,7 @@ * @author Adam Warski (ad...@as...) * @author Damon Sicore (da...@si...) */ -public class NodeList implements Iterable<Node> { +public class NodeList implements Collection<Node> { private List<Node> nodeList; public NodeList() { @@ -56,8 +52,9 @@ * @param node * Node to add. */ - public void add(Node node) { + public boolean add(Node node) { nodeList.add(node); + return true; } /** @@ -97,10 +94,6 @@ return Collections.unmodifiableList(nodeList); } - public Iterator<Node> iterator() { - return toList().iterator(); - } - /** * Limits the size of this node list. After this operation, * the size of this node list will be lower or equal to the @@ -113,37 +106,55 @@ } } - /** - * @deprecated - * @param cm - * @param templateName - * @param nodesParameter - * @param w - * @throws RepositoryException + /* + * Implementation of the Collection interface methods. */ - public void mergeWithTemplate(ContentManager cm, String templateName, - String nodesParameter, Writer w) - throws RepositoryException { - mergeWithTemplate(cm, templateName, nodesParameter, new VelocityContext(), w); + + public Iterator<Node> iterator() { + return toList().iterator(); } - /** - * @deprecated - * @param cm - * @param templateName - * @param nodesParameter - * @param context - * @param w - * @throws RepositoryException - */ - public void mergeWithTemplate(ContentManager cm, String templateName, - String nodesParameter, VelocityContext context, Writer w) - throws RepositoryException { - context.put(nodesParameter, nodeList); - try { - cm.getVelocityEngine().mergeTemplate(templateName, context, w); - } catch (Exception e) { - throw new RepositoryException(e); - } + public int size() { + return nodeList.size(); } + + public boolean isEmpty() { + return nodeList.isEmpty(); + } + + public boolean contains(Object o) { + return nodeList.contains(o); + } + + public Object[] toArray() { + return nodeList.toArray(); + } + + public <T> T[] toArray(T[] a) { + return nodeList.toArray(a); + } + + public boolean remove(Object o) { + return nodeList.remove(o); + } + + public boolean containsAll(Collection<?> c) { + return nodeList.containsAll(c); + } + + public boolean addAll(Collection<? extends Node> c) { + return nodeList.addAll(c); + } + + public boolean removeAll(Collection<?> c) { + return nodeList.removeAll(c); + } + + public boolean retainAll(Collection<?> c) { + return nodeList.retainAll(c); + } + + public void clear() { + nodeList.clear(); + } } |
Author: dam...@jb... Date: 2005-11-11 18:51:29 -0500 (Fri, 11 Nov 2005) New Revision: 1561 Added: trunk/forge/portal-extensions/binaries/maven-repo-addons/jdom/ trunk/forge/portal-extensions/binaries/maven-repo-addons/jdom/jdom.jar trunk/forge/portal-extensions/forge-podcast/ trunk/forge/portal-extensions/forge-podcast/maven.xml trunk/forge/portal-extensions/forge-podcast/project.properties trunk/forge/portal-extensions/forge-podcast/project.xml trunk/forge/portal-extensions/forge-podcast/src/ trunk/forge/portal-extensions/forge-podcast/src/java/ trunk/forge/portal-extensions/forge-podcast/src/java/org/ trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/ trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/ trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/ trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastDescriptor.java trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastNodeWatcher.java trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastPortlet.java trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastTools.java trunk/forge/portal-extensions/forge-podcast/src/web/ trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/ trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-app.xml trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-portlet.xml trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-service.xml trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/portlet-instances.xml trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/portlet.xml trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/tld/ trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/tld/forge.tld trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/tld/portlet.tld trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/web.xml Removed: trunk/forge/portal-extensions/binaries/maven-repo-addons/jdom/jdom.jar trunk/forge/portal-extensions/forge-podcast/maven.xml trunk/forge/portal-extensions/forge-podcast/project.properties trunk/forge/portal-extensions/forge-podcast/project.xml trunk/forge/portal-extensions/forge-podcast/src/ trunk/forge/portal-extensions/forge-podcast/src/java/ trunk/forge/portal-extensions/forge-podcast/src/java/org/ trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/ trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/ trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/ trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastDescriptor.java trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastNodeWatcher.java trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastPortlet.java trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastTools.java trunk/forge/portal-extensions/forge-podcast/src/web/ trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/ trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-app.xml trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-portlet.xml trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-service.xml trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/portlet-instances.xml trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/portlet.xml trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/tld/ trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/tld/forge.tld trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/tld/portlet.tld trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/web.xml Modified: trunk/forge/portal-extensions/binaries/maven-repo-addons/informa/jars/informa.jar trunk/forge/portal-extensions/forge-ear/src/META-INF/application.xml trunk/forge/portal-extensions/portal-default/src/web/WEB-INF/default-portal.xml Log: MERGED: -r 1440:1531 https://svn.labs.jboss.com/branches/forge/interns/pawel/portal-extensions . Modified: trunk/forge/portal-extensions/binaries/maven-repo-addons/informa/jars/informa.jar =================================================================== (Binary files differ) Copied: trunk/forge/portal-extensions/binaries/maven-repo-addons/jdom (from rev 1531, branches/forge/interns/pawel/portal-extensions/binaries/maven-repo-addons/jdom) Deleted: trunk/forge/portal-extensions/binaries/maven-repo-addons/jdom/jdom.jar =================================================================== (Binary files differ) Copied: trunk/forge/portal-extensions/binaries/maven-repo-addons/jdom/jdom.jar (from rev 1531, branches/forge/interns/pawel/portal-extensions/binaries/maven-repo-addons/jdom/jdom.jar) Modified: trunk/forge/portal-extensions/forge-ear/src/META-INF/application.xml =================================================================== --- trunk/forge/portal-extensions/forge-ear/src/META-INF/application.xml 2005-11-11 22:53:22 UTC (rev 1560) +++ trunk/forge/portal-extensions/forge-ear/src/META-INF/application.xml 2005-11-11 23:51:29 UTC (rev 1561) @@ -88,4 +88,10 @@ <web-uri>forge-status.war</web-uri> </web> </module> + </module> + <module> + <web> + <web-uri>forge-podcast.war</web-uri> + </web> + </module> </application> Copied: trunk/forge/portal-extensions/forge-podcast (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast) Deleted: trunk/forge/portal-extensions/forge-podcast/maven.xml =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/maven.xml 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/maven.xml 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,24 +0,0 @@ -<!-- - JBoss, the OpenSource J2EE webOS - Distributable under LGPL license. - See terms of license at gnu.org. - --> -<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:u="jelly:util"> - <!-- Default war-project goals --> - - <goal name="all"> - <attainGoal name="prj-all" /> - </goal> - - <goal name="build"> - <attainGoal name="prj-war-build" /> - </goal> - - <goal name="deploy"> - <attainGoal name="prj-war-deploy" /> - </goal> - - <goal name="clean"> - <attainGoal name="prj-clean" /> - </goal> -</project> Copied: trunk/forge/portal-extensions/forge-podcast/maven.xml (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/maven.xml) Deleted: trunk/forge/portal-extensions/forge-podcast/project.properties =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/project.properties 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/project.properties 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,3 +0,0 @@ -maven.repo.remote=http://repository.atlassian.com,http://www.ibiblio.org/maven,http://dist.codehaus.org/ -maven.junit.fork=yes -maven.war.src=${basedir}/src/web Copied: trunk/forge/portal-extensions/forge-podcast/project.properties (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/project.properties) Deleted: trunk/forge/portal-extensions/forge-podcast/project.xml =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/project.xml 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/project.xml 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,63 +0,0 @@ -<?xml version='1.0' encoding='ISO-8859-1'?> -<!-- - JBoss, the OpenSource J2EE webOS - Distributable under LGPL license. - See terms of license at gnu.org. - --> -<project> - <pomVersion>3</pomVersion> - <extend>../common.xml</extend> - <id>forge-podcast</id> - <name>Podcast portlet</name> - <currentVersion>1.0</currentVersion> - <organization> - <name>Pawel Wrzeszcz</name> - <url></url> - </organization> - <description></description> - - <dependencies> - <dependency> - <groupId>tmate</groupId> - <artifactId>javasvn</artifactId> - <version>1.0</version> - <jar>javasvn.jar</jar> - </dependency> - - <dependency> - <groupId>tmate</groupId> - <artifactId>jsch</artifactId> - <version>1.0</version> - <jar>jsch.jar</jar> - </dependency> - - <dependency> - <groupId>jboss-forge</groupId> - <artifactId>forge-common</artifactId> - <version>1.0</version> - </dependency> - - <dependency> - <groupId>aslibs</groupId> - <artifactId>javax.servlet</artifactId> - <version>1.0</version> - <jar>javax.servlet.jar</jar> - </dependency> - <dependency> - <groupId>informa</groupId> - <artifactId>informa</artifactId> - <version>0.6.5</version> - <jar>informa.jar</jar> - <properties> - <war.bundle>true</war.bundle> - </properties> - </dependency> - <dependency> - <id>jdom</id> - <version>1.0</version> - <properties> - <war.bundle>true</war.bundle> - </properties> - </dependency> - </dependencies> -</project> Copied: trunk/forge/portal-extensions/forge-podcast/project.xml (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/project.xml) Copied: trunk/forge/portal-extensions/forge-podcast/src (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src) Copied: trunk/forge/portal-extensions/forge-podcast/src/java (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java) Copied: trunk/forge/portal-extensions/forge-podcast/src/java/org (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java/org) Copied: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java/org/jboss) Copied: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java/org/jboss/forge) Copied: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast) Deleted: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,278 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.forge.podcast; - -import java.util.Iterator; -import java.util.Map; -import java.util.HashMap; -import java.util.Set; -import java.util.HashSet; -import java.util.SimpleTimeZone; - -import java.util.Date; -import java.text.DateFormat; -import java.util.SimpleTimeZone; - -import java.net.URL; - -import org.jboss.forge.common.XmlTools; -import org.jboss.forge.common.projects.AbstractDescriptor; -import org.jboss.forge.common.projects.permissions.PermissionsChecker; -import org.jboss.forge.common.projects.permissions.RenderRequestPermissionsChecker; -import org.jboss.forge.common.projects.DomToXmlTransformer; - -import org.jboss.portal.common.context.DelegateContext; -import org.jboss.shotoku.ContentManager; - -import org.apache.xerces.parsers.DOMParser; -import org.xml.sax.InputSource; - -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.NamedNodeMap; - -import de.nava.informa.core.ChannelIF; -import de.nava.informa.impl.basic.ChannelBuilder; -import de.nava.informa.parsers.FeedParser; -import de.nava.informa.utils.ItemComparator; -import de.nava.informa.core.ItemIF; -import de.nava.informa.core.ItemEnclosureIF; -import de.nava.informa.core.ImageIF; - -/** - * A class holding the podcast feeds. - * - * @author Pawel Wrzeszcz - */ -public class Podcast extends AbstractDescriptor { - - /** - * <code>PODCAST_ELEMENT</code> - root tag in the xml file defining the list of watched feeds - */ - public static final String PODCAST_ELEMENT = "podcast"; - - /** - * <code>podcasts_number</code> - Defines maximum number of podcasts to display. - */ - public int podcastsNumber; - - private static int DEFAULT_PODCASTS_NUMBER = 50; - - /* Other tags in the xml file */ - private static final String FEED_ELEMENT = "feed"; - private static final String ID_ELEMENT = "id"; - private static final String URL_ELEMENT = "url"; - - private static final int BYTES_IN_MB = (1024*1024); - - private String portalName; - - /** - * <code>allItemsArr</code> - Array if ItemIF objects, containing items from all feeds. - */ - private Object[] allItemsArr; - - Podcast(String portalName, Node root) { - this.portalName = portalName; - - podcastsNumber = getPodcastsNumber(root); - - // Get the feeds nodes - HashSet<String> podcastNodes = new HashSet<String>(); - podcastNodes.add(FEED_ELEMENT); - - Set<Node> feedsNodes; - feedsNodes = getChildNodesSet(root, podcastNodes); - - // Parse each node to get the feed url - HashSet<String> propertiesTags = new HashSet<String>(); - propertiesTags.add(ID_ELEMENT); - propertiesTags.add(URL_ELEMENT); - - HashSet<Map<String,Node>> nodes = new HashSet<Map<String,Node>>(); - // Each Map in this Set describes one feed - // (contains it's id and url Nodes) - Map<String,Node> nodeProperties; - - for (Iterator iter = feedsNodes.iterator(); iter.hasNext();) { - Node n = (Node) iter.next(); - nodeProperties = getChildNodesMap(n, propertiesTags); - nodes.add(nodeProperties); - } - - // Parse and sort the items - allItemsArr = getAllItems(nodes).toArray(); - java.util.Arrays.sort((Object[]) allItemsArr, new ItemComparator(true)); - } - - /** - * Fills the given context with podcast information. - * - * @param context Context to fill. - */ - public void fillContext(DelegateContext context) { - - int iterations = Math.min(allItemsArr.length, podcastsNumber); - - for (int i = 0; i < iterations; i++) { - ItemIF item = (ItemIF) allItemsArr[i]; - DelegateContext nodeContext = new DelegateContext(); - - nodeContext.put("no", i+1); - nodeContext.put("title", item.getTitle()); - nodeContext.put("description", item.getDescription()); - - Date date = item.getDate(); - if (date != null) { - DateFormat dateFormat = DateFormat.getInstance(); - dateFormat.setTimeZone(new SimpleTimeZone(0, "GMT")); - String dateString = dateFormat.format(date) + " GMT"; - nodeContext.put("date", dateString); - } - - URL link = item.getLink(); - if (link != null) { - nodeContext.put("link", link.toString()); - } - - ItemEnclosureIF enclosure = item.getEnclosure(); - if (enclosure != null) { - DelegateContext enclosureContext = nodeContext.next("enclosure-link"); - - nodeContext.put("enclosure-type", enclosure.getType()); - nodeContext.put("enclosure-size", Math.round(enclosure.getLength() / BYTES_IN_MB)); - - URL enclosureLocation = enclosure.getLocation(); - if (enclosureLocation != null) { - nodeContext.put("enclosure-link", enclosureLocation.toString()); - } - } - - ChannelIF channel = item.getChannel(); - - nodeContext.put("channel-title", channel.getTitle()); - URL channelLocation = channel.getLocation(); - if (channelLocation != null) { - nodeContext.put("channel-link", channelLocation.toString()); - } - - ImageIF channelImage = channel.getImage(); - if ((channelImage != null) && (channelImage.getLocation() != null)) { - nodeContext.put("channel-image", channelImage.getLocation().toString()); - } - - context.append("podcast", nodeContext); - } - } - - - /** - * For the given Node, computes Set of it's child Nodes. - * Only child Nodes with names included in <code>nodesNames</code> Set - * appear in computed Set. - * - * @param root - * @param nodesNames - * @return Set containing <code>root</code>'s child Nodes, - * but only those with names included in <code>nodeNames</code> Set - */ - private Set getChildNodesSet(Node root, Set<String> nodesNames) { - HashSet ret = new HashSet<Node>(); - NodeList list = root.getChildNodes(); - - for (int i = 0; i < list.getLength(); i++) { - Node n = list.item(i); - if ((n.getNodeType() == Node.ELEMENT_NODE) - && (nodesNames.contains(n.getNodeName()))) { - ret.add(n); - } - } - - return ret; - } - - /** - * Similar to <code>getChildNodesSet(Node,Set)</code>. - * Map binds child Nodes names with appropriate Nodes. - */ - private Map getChildNodesMap(Node root, Set<String> nodesNames) { - HashMap ret = new HashMap<String,Node>(); - NodeList list = root.getChildNodes(); - - for (int i = 0; i < list.getLength(); i++) { - Node n = list.item(i); - if ((n.getNodeType() == Node.ELEMENT_NODE) - && (nodesNames.contains(n.getNodeName()))) { - ret.put(n.getNodeName(),n); - } - } - - return ret; - } - - /** - * For the given Set of feeds descripions, computes Set of all items from these feeds. - * - * @param nodes Set of Maps describing the feeds. - * For each feed, it's Map binds "id" and "url" with appropiate Nodes. - * - * @return Set of all items from feeds described in the given Set. - */ - private Set<ItemIF> getAllItems(Set<Map<String,Node>> nodes) { - HashSet<ItemIF> ret = new HashSet<ItemIF>(); - - for (Iterator iter = nodes.iterator(); iter.hasNext();) { - try { - Map nodeProperties = (Map<String,Node>) iter.next(); - - Node urlNode = (Node) nodeProperties.get(URL_ELEMENT); - URL url = new URL(XmlTools.unmarshallText(urlNode)); - - ChannelIF channel = FeedParser.parse(new ChannelBuilder(), url); - ret.addAll(channel.getItems()); - - } catch (Exception e) { - e.printStackTrace(); - } - } - return ret; - } - - /** - * Parses attribute defining maximum number of podcasts to display. - * If it is not defined in the xml file, returns default value (DEFAULT_PODCASTS_NUMBER). - * - * @param root Root Node of the xml file. - * @return - */ - private int getPodcastsNumber(Node root) { - if (!root.hasAttributes()) { - return DEFAULT_PODCASTS_NUMBER; - } - NamedNodeMap m = root.getAttributes(); - String intString = XmlTools.unmarshallText(m.item(0)); - return Integer.parseInt(intString); - } - -} Copied: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java) Deleted: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastDescriptor.java =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastDescriptor.java 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastDescriptor.java 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,90 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.forge.podcast; - -import java.io.IOException; -import java.util.Set; -import java.util.HashSet; - -import org.jboss.forge.podcast.PodcastTools; - -import org.apache.xerces.parsers.DOMParser; -import org.jboss.forge.common.ForgeHelper; -import org.jboss.forge.common.projects.ProjectsHelper; -import org.jboss.portal.common.context.DelegateContext; -import org.jboss.portlet.JBossRenderRequest; -import org.jboss.shotoku.ContentManager; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.jboss.logging.Logger; - -/** - * @author Pawel Wrzeszcz - * A class which handles xml parsing and accessing parsed feeds information. - */ -public class PodcastDescriptor { - - private static final Logger log = Logger.getLogger(PodcastDescriptor.class); - - private DelegateContext context; - - private Podcast podcast; - - private HashSet<String> feeds; - - public PodcastDescriptor(String portalName, ContentManager cm) { - try { - feeds = new HashSet<String>(); - - DOMParser parser = new DOMParser(); - parser.parse(new InputSource(cm.getNode(PodcastTools - .getXmlCmPath(portalName)).getContentInputStream())); - - Node root = parser.getDocument().getDocumentElement(); - - - if ((root.getNodeType() == Node.ELEMENT_NODE) - && (root.getNodeName().equals(Podcast.PODCAST_ELEMENT))) { - podcast = new Podcast(portalName, root); - } - - fillContext(); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - private void fillContext() { - context = new DelegateContext(); - podcast.fillContext(context); - } - - public DelegateContext getContext(JBossRenderRequest request) { - - return context; - } -} Copied: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastDescriptor.java (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastDescriptor.java) Deleted: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastNodeWatcher.java =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastNodeWatcher.java 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastNodeWatcher.java 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,61 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.forge.podcast; - -import org.jboss.forge.common.service.NodeWatcher; -import org.jboss.forge.common.service.ResourceWatcher; - -import org.jboss.shotoku.ContentManager; - -/** -* @author Pawel Wrzeszcz -*/ - -public class PodcastNodeWatcher implements NodeWatcher { - private ResourceWatcher rw; - private ContentManager cm; - - public PodcastNodeWatcher(ContentManager cm) { - this.cm = cm; - } - - private PodcastDescriptor getDesc(String portalName) { - PodcastDescriptor desc = new PodcastDescriptor(portalName, cm); - - rw = new ResourceWatcher(cm); - rw.watchResource(PodcastTools.getXmlCmPath(portalName)); - - return desc; - } - - public Object init(String portalName) { - return getDesc(portalName); - } - - public Object nodeUpdate(String portalName, Object currentValue) { - if ((currentValue == null) || (rw.checkResources())) - return getDesc(portalName); - else - return null; - } -} Copied: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastNodeWatcher.java (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastNodeWatcher.java) Deleted: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastPortlet.java =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastPortlet.java 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastPortlet.java 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,67 +0,0 @@ - /* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.forge.podcast; - -import java.io.IOException; - -import javax.portlet.PortletException; -import javax.portlet.PortletRequestDispatcher; - -import org.jboss.forge.common.ForgeHelper; -import org.jboss.forge.common.projects.Projects; -import org.jboss.forge.common.projects.ProjectsHelper; -import org.jboss.forge.common.projects.permissions.PermissionsChecker; -import org.jboss.forge.common.projects.permissions.RenderRequestPermissionsChecker; - -import org.jboss.portal.common.context.DelegateContext; -import org.jboss.portal.core.servlet.jsp.PortalJsp; - -import org.jboss.portlet.JBossPortlet; -import org.jboss.portlet.JBossRenderRequest; -import org.jboss.portlet.JBossRenderResponse; - -/** - * Podcast portlet. - * @author Pawel Wrzeszcz - */ -public class PodcastPortlet extends JBossPortlet { - - public void doView(JBossRenderRequest request, JBossRenderResponse response) - throws IOException, PortletException { - response.setContentType("text/html"); - - String portalName = ForgeHelper.getPortalName(request); - - // Getting the podcast context - DelegateContext context = PodcastTools.getDesc(portalName).getContext(request); - - // Displaying the JSP - request.setAttribute(PortalJsp.CTX_REQUEST, context); - - PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher( - ForgeHelper.createRepoAccessPath(portalName, PodcastTools - .getJspCmPath())); - rd.include(request, response); - - } -} Copied: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastPortlet.java (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastPortlet.java) Deleted: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastTools.java =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastTools.java 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastTools.java 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,58 +0,0 @@ -package org.jboss.forge.podcast; - -import org.jboss.forge.common.ForgeHelper; - -import org.jboss.shotoku.ContentManager; -import org.jboss.shotoku.aop.Inject; - -/** - * Common constants and functions. - * @author Pawel Wrzeszcz - */ -public class PodcastTools { - - /** - * <code>PODCAST_XML<code> - file defining the list of watched feeds - */ - private final static String PODCAST_XML = "podcast.xml"; - - /** - * <code>PODCAST_DIR</code> - directory in which file <code>PODCAST_XML<code> is stored. - */ - private final static String PODCAST_DIR = "podcast"; - - private final static String PODCAST_JSP = "podcast.jsp"; - private final static String PODCAST_JSP_DIR = "podcast"; - - @Inject - private static ContentManager cm; - - /** - * Path to the xml file defining list of watched feeds. - */ - public static String getXmlCmPath(String portalName) { - return portalName + "/" + PODCAST_DIR + "/" + PODCAST_XML; - } - - /** - * Path to the file displaying the podcast feeds. - */ - public static String getJspCmPath() { - return PODCAST_JSP_DIR + "/" + PODCAST_JSP; - } - - public static synchronized PodcastDescriptor getDesc(final String portalName) { - String cacheKey = PodcastDescriptor.class.getName(); - - PodcastDescriptor desc = (PodcastDescriptor) ForgeHelper - .getForgeManagement().getFromCache(portalName, cacheKey); - - if (desc == null) - desc = (PodcastDescriptor) ForgeHelper.getForgeManagement() - .addNodeWatcher(portalName, - cacheKey, - new PodcastNodeWatcher(cm)); - - return desc; - } -} Copied: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastTools.java (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/PodcastTools.java) Copied: trunk/forge/portal-extensions/forge-podcast/src/web (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web) Copied: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF) Deleted: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-app.xml =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-app.xml 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-app.xml 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,3 +0,0 @@ -<jboss-app> - <app-name>podcast</app-name> -</jboss-app> Copied: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-app.xml (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-app.xml) Deleted: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-portlet.xml =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-portlet.xml 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-portlet.xml 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,6 +0,0 @@ -<portlet-app> - <portlet> - <portlet-name>PodcastPortlet</portlet-name> - <security></security> - </portlet> -</portlet-app> \ No newline at end of file Copied: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-portlet.xml (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-portlet.xml) Deleted: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-service.xml =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-service.xml 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-service.xml 2005-11-11 23:51:29 UTC (rev 1561) @@ -1 +0,0 @@ -<server></server> \ No newline at end of file Copied: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-service.xml (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/jboss-service.xml) Deleted: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/portlet-instances.xml =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/portlet-instances.xml 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/portlet-instances.xml 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,7 +0,0 @@ -<?xml version="1.0" standalone="yes"?> -<instances> - <instance> - <instance-name>PodcastPortletInstance</instance-name> - <component-ref>PodcastPortlet</component-ref> - </instance> -</instances> Copied: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/portlet-instances.xml (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/portlet-instances.xml) Deleted: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/portlet.xml =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/portlet.xml 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/portlet.xml 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" - version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"> - <portlet> - <description>Podcast Portlet</description> - <portlet-name>PodcastPortlet</portlet-name> - <display-name>Feeds</display-name> - <portlet-class>org.jboss.forge.podcast.PodcastPortlet</portlet-class> - <supports> - <mime-type>text/html</mime-type> - <portlet-mode>VIEW</portlet-mode> - </supports> - <portlet-info> - <title>Podcast</title> - </portlet-info> - </portlet> - </portlet-app> Copied: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/portlet.xml (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/portlet.xml) Copied: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/tld (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/tld) Deleted: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/tld/forge.tld =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/tld/forge.tld 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/tld/forge.tld 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,139 +0,0 @@ -<taglib xmlns="http://java.sun.com/xml/ns/j2ee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd" - version="2.0"> - <!-- - JBoss, the OpenSource J2EE webOS - Distributable under LGPL license. - See terms of license at gnu.org. - --> - <tlib-version>1.1</tlib-version> - <jsp-version>2.0</jsp-version> - <shortname>forge</shortname> - <info>Forge tags</info> - - <tag> - <name>pageURL</name> - <tagclass>org.jboss.forge.common.taglib.PageURLTag</tagclass> - <attribute> - <name>page</name> - <required>true</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - <attribute> - <name>form</name> - <required>false</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - </tag> - - <tag> - <name>param</name> - <tagclass>org.jboss.forge.common.taglib.ParamTag</tagclass> - <attribute> - <name>name</name> - <required>true</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - <attribute> - <name>value</name> - <required>true</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - </tag> - - <tag> - <name>wikiURL</name> - <tagclass>org.jboss.forge.common.taglib.WikiURLTag</tagclass> - <attribute> - <name>page</name> - <required>true</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - </tag> - - <tag> - <name>freezoneURL</name> - <tagclass>org.jboss.forge.common.taglib.FreezoneURLTag</tagclass> - <attribute> - <name>page</name> - <required>true</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - </tag> - - <tag> - <name>projectURL</name> - <tagclass>org.jboss.forge.common.taglib.ProjectURLTag</tagclass> - <attribute> - <name>project</name> - <required>true</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - <attribute> - <name>page</name> - <required>false</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - <attribute> - <name>form</name> - <required>false</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - </tag> - - <tag> - <name>categoryURL</name> - <tagclass>org.jboss.forge.common.taglib.CategoryURLTag</tagclass> - <attribute> - <name>category</name> - <required>true</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - <attribute> - <name>form</name> - <required>false</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - </tag> - - <tag> - <name>selectedProject</name> - <tagclass>org.jboss.forge.common.taglib.SelectedProjectTag</tagclass> - </tag> - - <tag> - <name>imagePath</name> - <tagclass>org.jboss.forge.common.taglib.ImagePathTag</tagclass> - <attribute> - <name>src</name> - <required>true</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - <attribute> - <name>project</name> - <required>false</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - </tag> - - <tag> - <name>attrValue</name> - <tagclass>org.jboss.forge.common.taglib.AttrValueTag</tagclass> - <attribute> - <name>name</name> - <required>true</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - </tag> - - <tag> - <name>attrIf</name> - <tagclass>org.jboss.forge.common.taglib.AttrIfTag</tagclass> - <attribute> - <name>name</name> - <required>true</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - </tag> -</taglib> Copied: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/tld/forge.tld (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/tld/forge.tld) Deleted: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/tld/portlet.tld =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/tld/portlet.tld 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/tld/portlet.tld 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,77 +0,0 @@ -<taglib xmlns="http://java.sun.com/xml/ns/j2ee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd" - version="2.0"> - <tlib-version>1.1</tlib-version> - <jsp-version>2.0</jsp-version> - <shortname>JBoss Portal tags</shortname> - <info>JBoss Portal tags</info> - - <function> - <name>i18n</name> - <function-class>org.jboss.portal.core.servlet.jsp.taglib.PortalLib</function-class> - <function-signature>java.lang.String getMessage(java.lang.String)</function-signature> - </function> - - <function> - <name>out</name> - <function-class>org.jboss.portal.core.servlet.jsp.taglib.PortalLib</function-class> - <function-signature>java.lang.String out(java.lang.String)</function-signature> - </function> - - <function> - <name>i18nout</name> - <function-class>org.jboss.portal.core.servlet.jsp.taglib.PortalLib</function-class> - <function-signature>java.lang.String i18nOut(java.lang.String)</function-signature> - </function> - - <tag> - <name>if</name> - <tagclass>org.jboss.portal.core.servlet.jsp.taglib.IfTag</tagclass> - <attribute> - <name>ctx</name> - <required>true</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - </tag> - - <tag> - <name>iterate</name> - <tagclass>org.jboss.portal.core.servlet.jsp.taglib.IterateTag</tagclass> - <attribute> - <name>ctx</name> - <required>true</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - </tag> - - <tag> - <name>include</name> - <tagclass>org.jboss.portal.core.servlet.jsp.taglib.IncludeTag</tagclass> - <attribute> - <name>page</name> - <required>true</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - </tag> - - <tag> - <name>error</name> - <tagclass>org.jboss.portal.core.servlet.jsp.taglib.ErrorTag</tagclass> - <attribute> - <name>key</name> - <required>true</required> - <rtexprvalue>true</rtexprvalue> - </attribute> - </tag> - - <tag> - <name>errors</name> - <tagclass>org.jboss.portal.core.servlet.jsp.taglib.ErrorsTag</tagclass> - </tag> - - <tag> - <name>success</name> - <tagclass>org.jboss.portal.core.servlet.jsp.taglib.SuccessTag</tagclass> - </tag> -</taglib> Copied: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/tld/portlet.tld (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/tld/portlet.tld) Deleted: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/web.xml =================================================================== --- branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/web.xml 2005-11-08 17:21:03 UTC (rev 1531) +++ trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/web.xml 2005-11-11 23:51:29 UTC (rev 1561) @@ -1,16 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE web-app PUBLIC - "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" - "http://java.sun.com/dtd/web-app_2_3.dtd"> -<web-app> - <filter> - <filter-name>filesFromRepoFilter</filter-name> - <filter-class>org.jboss.forge.common.FilesFromRepoFilter</filter-class> - </filter> - - <filter-mapping> - <filter-name>filesFromRepoFilter</filter-name> - <url-pattern>/repo-access/*</url-pattern> - <dispatcher>INCLUDE</dispatcher> - </filter-mapping> -</web-app> \ No newline at end of file Copied: trunk/forge/portal-extensions/forge-podcast/src/web/WEB-INF/web.xml (from rev 1531, branches/forge/interns/pawel/portal-extensions/forge-podcast/src/web/WEB-INF/web.xml) Modified: trunk/forge/portal-extensions/portal-default/src/web/WEB-INF/default-portal.xml =================================================================== --- trunk/forge/portal-extensions/portal-default/src/web/WEB-INF/default-portal.xml 2005-11-11 22:53:22 UTC (rev 1560) +++ trunk/forge/portal-extensions/portal-default/src/web/WEB-INF/default-portal.xml 2005-11-11 23:51:29 UTC (rev 1561) @@ -74,33 +74,33 @@ <height>2</height> <window-state>normal</window-state> </window> - </page> - - <!-- login page --> - <page> - <page-name>login</page-name> - <window> - <window-name>LoginWindow</window-name> - <instance-ref>forgeLogin.Login.LoginInstance</instance-ref> - <default>true</default> - <region>center</region> - <height>0</height> - </window> - <window> - <window-name>NavigationPortletWindowDefaultLogin</window-name> - <instance-ref>navigation.NavigationPortlet.NavigationPortletInstance</instance-ref> - <region>left</region> - <height>0</height> - <window-state>normal</window-state> - </window> - <window> - <window-name>AdsPortletWindowDefaultLogin</window-name> - <instance-ref>ads.AdsPortlet.AdsPortletInstance</instance-ref> - <region>left</region> - <height>2</height> - <window-state>normal</window-state> - </window> </page> + + <!-- login page --> + <page> + <page-name>login</page-name> + <window> + <window-name>LoginWindow</window-name> + <instance-ref>forgeLogin.Login.LoginInstance</instance-ref> + <default>true</default> + <region>center</region> + <height>0</height> + </window> + <window> + <window-name>NavigationPortletWindowDefaultLogin</window-name> + <instance-ref>navigation.NavigationPortlet.NavigationPortletInstance</instance-ref> + <region>left</region> + <height>0</height> + <window-state>normal</window-state> + </window> + <window> + <window-name>AdsPortletWindowDefaultLogin</window-name> + <instance-ref>ads.AdsPortlet.AdsPortletInstance</instance-ref> + <region>left</region> + <height>2</height> + <window-state>normal</window-state> + </window> + </page> <page> <page-name>softwaremap</page-name> @@ -383,7 +383,7 @@ <height>0</height> </window> - </page> + </page> <page> <page-name>status</page-name> @@ -412,6 +412,29 @@ </window> </page> - + <page> + <page-name>podcast</page-name> + <window> + <window-name>NavigationPortletWindowDefaultPodcast</window-name> + <instance-ref>navigation.NavigationPortlet.NavigationPortletInstance</instance-ref> + <region>left</region> + <height>0</height> + <window-state>normal</window-state> + </window> + <window> + <window-name>AdsPortletWindowDefaultPodcast</window-name> + <instance-ref>ads.AdsPortlet.AdsPortletInstance</instance-ref> + <region>left</region> + <height>2</height> + <window-state>normal</window-state> + </window> + <window> + <window-name>PodcastPortletWindowDefaultPodcast</window-name> + <instance-ref>podcast.PodcastPortlet.PodcastPortletInstance</instance-ref> + <region>center</region> + <height>0</height> + </window> + </page> + </pages> </portal> |
Author: adamw Date: 2005-11-11 17:53:22 -0500 (Fri, 11 Nov 2005) New Revision: 1560 Added: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/AbstractResource.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnResource.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnDirectory.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHeadNode.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHistoricNode.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewDirectory.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewDirectoryHelper.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNode.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNodeHelper.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewResourceHelper.java trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNode.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-29 : implementation Modified: trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/AbstractResource.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/AbstractResource.java 2005-11-11 16:00:04 UTC (rev 1559) +++ trunk/forge/portal-extensions/shotoku/shotoku-base/src/java/org/jboss/shotoku/AbstractResource.java 2005-11-11 22:53:22 UTC (rev 1560) @@ -92,4 +92,12 @@ * is the root directory. */ public String getName(); + + /** + * Gets the full name of this resource, that is, path to this resource + * relative to the content manager this node was read from. + * + * @return Full name of this resource. + */ + public String getFullName(); } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnResource.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnResource.java 2005-11-11 16:00:04 UTC (rev 1559) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/AbstractSvnResource.java 2005-11-11 22:53:22 UTC (rev 1560) @@ -46,28 +46,22 @@ protected String fullPath; protected File file; protected String name; + protected String fullName; protected SvnContentManager svnCm; - public AbstractSvnResource(String id, String resFullPath, File file, String name, + public AbstractSvnResource(String id, String resFullPath, File file, SvnContentManager svnCm) { this.file = file; this.id = id; - this.name = name; this.svnCm = svnCm; - fullPath = resFullPath; + String[] pathParams = svnCm.getNamesFromPath(resFullPath); - // Compacting fullPath, that is, throwing out unnecessary /. - while (fullPath.contains("//")) - fullPath = fullPath.replace("//", "/"); + fullPath = pathParams[0]; + name = pathParams[1]; + fullName = pathParams[2]; - if (fullPath.startsWith("/")) - fullPath = fullPath.substring(1); - - if (fullPath.endsWith("/")) - fullPath = fullPath.substring(0, fullPath.length() - 1); - modifiedProperties = new HashMap<String, String>(); service = Tools.getService(); } @@ -115,6 +109,10 @@ return name; } + public String getFullName() { + return fullName; + } + protected boolean deleteResource() { return false; } @@ -154,26 +152,15 @@ return null; String parentPath; - String parentName; int lastSlash = fullPath.lastIndexOf('/'); if (lastSlash == -1) { // No / at all in the path - this resource must be a child of the // root directory. parentPath = ""; - parentName = ""; } else { // Getting the parent path. parentPath = fullPath.substring(0, lastSlash); - - // Getting the name from the parent's path. This is either the same - // as path, if the parent directory is a child of the root - // directory, or the last segment of parent's path. - int parentLastSlash = parentPath.lastIndexOf('/'); - if (parentLastSlash == -1) - parentName = parentPath; - else - parentName = parentPath.substring(parentLastSlash+1); } // Checking if the path that we constructed is valid (that is, not @@ -187,6 +174,6 @@ File parentFile = svnCm.getFileForPrefixedPath(parentPath); - return new SvnDirectory(id, parentPath, parentFile, parentName, svnCm); + return new SvnDirectory(id, parentPath, parentFile, svnCm); } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java 2005-11-11 16:00:04 UTC (rev 1559) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java 2005-11-11 22:53:22 UTC (rev 1560) @@ -39,11 +39,13 @@ * <code>service</code> - service interface binding. */ private SvnService service; + private int prefixLength; public SvnContentManager(String id, String prefix) { super(id, prefix); service = Tools.getService(); + prefixLength = prefix.length(); } /** @@ -93,33 +95,50 @@ boolean checkPathChild(String path) { return path.startsWith(prefix) && (!path.equals(prefix)); } - - @Override - public Directory getRootDirectory() { - return getDirectory(""); - } - - private String getNameFromPath(String path) { + + /** + * From the given full file path, extractes a node's name and full name. + * Also, modifies the given path to a most compact form (removing any + * unnecessary / and spaces. + * @param path Path from which to extract the names. + * @return An array of strings, containing 3 elements: { compacted full + * file path, name of resource, full name of resource }. + */ + String[] getNamesFromPath(String path) { + // Compacting path, that is, throwing out unnecessary /. + while (path.contains("//")) + path = path.replace("//", "/"); + + if (path.startsWith("/")) + path = path.substring(1); + + if (path.endsWith("/")) + path = path.substring(0, path.length() - 1); + + // Constructing fullName - just getting rid of the prefix and possible + // / on the first position. + String fullName = path.trim().substring(prefixLength); + if (fullName.startsWith("/")) + fullName = fullName.substring(1); + + // Constructing name. String name; - path = path.trim(); - // Getting the index of last /. - int lastSlash = path.lastIndexOf('/'); + int lastSlash = fullName.lastIndexOf('/'); - // If the name ends with a /, getting the part before it. - if ((lastSlash == path.length()-1) && (lastSlash != -1)) { - path = path.substring(0, lastSlash); - lastSlash = path.lastIndexOf('/'); - } - if (lastSlash != -1) { - name = path.substring(lastSlash+1); + name = fullName.substring(lastSlash+1); } else - name = path; + name = fullName; - return name; + return new String[] { path, name, fullName }; } + + @Override + public Directory getRootDirectory() { + return getDirectory(""); + } @Override public Node getNode(String path) { @@ -129,7 +148,7 @@ throw new ResourceDoesNotExist(file.getAbsolutePath()); return new SvnHeadNode(id, getPrefixedPath(path), file, - getNameFromPath(path), this); + this); } @Override @@ -140,6 +159,6 @@ throw new ResourceDoesNotExist(file.getAbsolutePath()); return new SvnDirectory(id, getPrefixedPath(path), file, - getNameFromPath(path), this); + this); } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnDirectory.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnDirectory.java 2005-11-11 16:00:04 UTC (rev 1559) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnDirectory.java 2005-11-11 22:53:22 UTC (rev 1560) @@ -39,9 +39,9 @@ * @author Damon Sicore (da...@si...) */ public class SvnDirectory extends AbstractSvnResource implements Directory { - public SvnDirectory(String id, String fullPath, File file, String name, + public SvnDirectory(String id, String fullPath, File file, SvnContentManager svnCm) { - super(id, fullPath, file, name, svnCm); + super(id, fullPath, file, svnCm); } public NodeList getNodes() { @@ -65,7 +65,7 @@ for (String node : list) { String childFullPath = fullPath + '/' + node; ret.add(new SvnHeadNode(id, childFullPath, new File(service - .getFileSystemPath(id, childFullPath)), node, svnCm)); + .getFileSystemPath(id, childFullPath)), svnCm)); } } catch (SvnOperationFailed e) { throw new RepositoryException(e); @@ -96,7 +96,7 @@ for (String directory : list) { String childFullPath = fullPath + '/' + directory; ret.add(new SvnDirectory(id, childFullPath, new File(service - .getFileSystemPath(id, childFullPath)), directory, + .getFileSystemPath(id, childFullPath)), svnCm)); } } catch (SvnOperationFailed e) { @@ -106,37 +106,25 @@ return ret; } - private void checkName(String name) throws RepositoryException { - if (name.contains("/")) - throw new RepositoryException("A / found in the given name: " - + name); - } - public Node getNode(String name) throws RepositoryException, ResourceDoesNotExist { - checkName(name); - String reqFullPath = fullPath + "/" + name; File reqNode = svnCm.getFileForPrefixedPath(reqFullPath); if (!reqNode.isFile()) throw new ResourceDoesNotExist(reqNode.getAbsolutePath()); - return new SvnHeadNode(id, reqFullPath, reqNode, name, svnCm); + return new SvnHeadNode(id, reqFullPath, reqNode, svnCm); } public Directory getDirectory(String name) throws RepositoryException, ResourceDoesNotExist { - checkName(name); - String reqFullPath = fullPath + "/" + name; File reqDir = svnCm.getFileForPrefixedPath(reqFullPath); if (!reqDir.isDirectory()) throw new ResourceDoesNotExist(reqDir.getAbsolutePath()); - return new SvnDirectory(id, reqFullPath, reqDir, name, svnCm); + return new SvnDirectory(id, reqFullPath, reqDir, svnCm); } public Node newNode(String name) { - checkName(name); - String childFullPath = fullPath + '/' + name; try { @@ -148,16 +136,14 @@ if (newFile.exists()) throw new ResourceAlreadyExists(childFullPath); - return new SvnNewNodeHelper(id, childFullPath, newFile, name, - svnCm, this); + return new SvnNewNodeHelper(id, childFullPath, newFile, + svnCm, this, name); } catch (SvnOperationFailed e) { throw new RepositoryException(e); } } public Directory newDirectory(String name) throws RepositoryException { - checkName(name); - String childFullPath = fullPath + '/' + name; try { service.synchronizeWithWriteLock(id, childFullPath); @@ -169,8 +155,8 @@ throw new ResourceAlreadyExists(childFullPath); } - return new SvnNewDirectoryHelper(id, childFullPath, newDir, name, - svnCm, this); + return new SvnNewDirectoryHelper(id, childFullPath, newDir, + svnCm, this, name); } catch (SvnOperationFailed e) { throw new RepositoryException(e); } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHeadNode.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHeadNode.java 2005-11-11 16:00:04 UTC (rev 1559) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHeadNode.java 2005-11-11 22:53:22 UTC (rev 1560) @@ -48,9 +48,9 @@ return content; } - public SvnHeadNode(String id, String fullPath, File file, String name, + public SvnHeadNode(String id, String fullPath, File file, SvnContentManager svnCm) { - super(id, fullPath, file, name, svnCm); + super(id, fullPath, file, svnCm); content = null; } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHistoricNode.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHistoricNode.java 2005-11-11 16:00:04 UTC (rev 1559) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnHistoricNode.java 2005-11-11 22:53:22 UTC (rev 1560) @@ -49,7 +49,7 @@ public SvnHistoricNode(String id, String fullPath, File file, String name, SvnContentManager svnCm, Date commitDate, String logMessage, long revisionAbsolute, int revisionRelative) { - super(id, fullPath, file, name, svnCm); + super(id, fullPath, file, svnCm); this.logMessage = logMessage; this.commitDate = commitDate; Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewDirectory.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewDirectory.java 2005-11-11 16:00:04 UTC (rev 1559) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewDirectory.java 2005-11-11 22:53:22 UTC (rev 1560) @@ -35,9 +35,9 @@ * @author Damon Sicore (da...@si...) */ public class SvnNewDirectory extends SvnDirectory { - public SvnNewDirectory(String id, String fullPath, File file, String name, + public SvnNewDirectory(String id, String fullPath, File file, SvnContentManager svnCm) { - super(id, fullPath, file, name, svnCm); + super(id, fullPath, file, svnCm); } @Override Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewDirectoryHelper.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewDirectoryHelper.java 2005-11-11 16:00:04 UTC (rev 1559) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewDirectoryHelper.java 2005-11-11 22:53:22 UTC (rev 1560) @@ -24,6 +24,7 @@ import java.io.File; import java.util.List; +import org.jboss.shotoku.AbstractResource; import org.jboss.shotoku.Directory; import org.jboss.shotoku.Node; import org.jboss.shotoku.NodeList; @@ -40,20 +41,18 @@ private Directory currentDirectory; public SvnNewDirectoryHelper(String id, String fullPath, File file, - String name, SvnContentManager svnCm, Directory parentDirectory) { - super(parentDirectory, name); - currentDirectory = new SvnNewDirectory(id, fullPath, file, name, svnCm); + SvnContentManager svnCm, Directory parentDirectory, + String requestedName) { + super(parentDirectory, requestedName); + currentDirectory = new SvnNewDirectory(id, fullPath, file, svnCm); + currentResource = currentDirectory; } - public void save(String logMessage) throws RepositoryException { - currentDirectory.save(logMessage); + protected AbstractResource getNormalResource() { currentDirectory = parentDirectory.getDirectory(name); + return currentDirectory; } - public void delete() throws RepositoryException { - currentDirectory.delete(); - } - public List<Directory> getDirectories() throws RepositoryException { return currentDirectory.getDirectories(); } @@ -63,14 +62,6 @@ return currentDirectory.getDirectory(name); } - public String getLogMessage() throws RepositoryException { - return currentDirectory.getLogMessage(); - } - - public String getName() { - return currentDirectory.getName(); - } - public Node getNode(String name) throws RepositoryException, ResourceDoesNotExist { return currentDirectory.getNode(name); @@ -79,15 +70,7 @@ public NodeList getNodes() throws RepositoryException { return currentDirectory.getNodes(); } - - public Directory getParent() throws RepositoryException { - return currentDirectory.getParent(); - } - - public String getProperty(String name) throws RepositoryException { - return currentDirectory.getProperty(name); - } - + public boolean hasIndex(String name) throws RepositoryException { return currentDirectory.hasIndex(name); } @@ -105,8 +88,4 @@ public void setIndex(String name, boolean index) throws RepositoryException { currentDirectory.setIndex(name, index); } - - public void setProperty(String name, String value) { - currentDirectory.setProperty(name, value); - } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNode.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNode.java 2005-11-11 16:00:04 UTC (rev 1559) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNode.java 2005-11-11 22:53:22 UTC (rev 1560) @@ -37,9 +37,9 @@ public class SvnNewNode extends SvnHeadNode { private NodeContent content; - public SvnNewNode(String id, String fullPath, File file, String name, + public SvnNewNode(String id, String fullPath, File file, SvnContentManager svnCm) { - super(id, fullPath, file, name, svnCm); + super(id, fullPath, file, svnCm); content = new NodeContent(); } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNodeHelper.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNodeHelper.java 2005-11-11 16:00:04 UTC (rev 1559) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewNodeHelper.java 2005-11-11 22:53:22 UTC (rev 1560) @@ -26,6 +26,7 @@ import java.io.OutputStream; import java.util.Date; +import org.jboss.shotoku.AbstractResource; import org.jboss.shotoku.Directory; import org.jboss.shotoku.History; import org.jboss.shotoku.Node; @@ -38,25 +39,23 @@ public class SvnNewNodeHelper extends SvnNewResourceHelper implements Node { private Node currentNode; - public SvnNewNodeHelper(String id, String fullPath, File file, String name, - SvnContentManager svnCm, Directory parentDirectory) { - super(parentDirectory, name); - currentNode = new SvnNewNode(id, fullPath, file, name, svnCm); + public SvnNewNodeHelper(String id, String fullPath, File file, + SvnContentManager svnCm, Directory parentDirectory, + String requestedName) { + super(parentDirectory, requestedName); + currentNode = new SvnNewNode(id, fullPath, file, svnCm); + currentResource = currentNode; } - - public void save(String logMessage) throws RepositoryException { - currentNode.save(logMessage); + + protected AbstractResource getNormalResource() { currentNode = parentDirectory.getNode(name); + return currentNode; } public void copyToFile(String fileName) throws RepositoryException { currentNode.copyToFile(fileName); } - public void delete() throws RepositoryException { - currentNode.delete(); - } - public String getContent() throws RepositoryException { return currentNode.getContent(); } @@ -81,30 +80,14 @@ return currentNode.getLength(); } - public String getLogMessage() throws RepositoryException { - return currentNode.getLogMessage(); - } - public String getMimeType() { return currentNode.getMimeType(); } - public String getName() { - return currentNode.getName(); - } - public OutputStream getOutputStream() { return currentNode.getOutputStream(); } - public Directory getParent() throws RepositoryException { - return currentNode.getParent(); - } - - public String getProperty(String name) throws RepositoryException { - return currentNode.getProperty(name); - } - public int getRevisionNumber() throws RepositoryException { return currentNode.getRevisionNumber(); } @@ -121,10 +104,6 @@ currentNode.setContent(content); } - public void setProperty(String name, String value) { - currentNode.setProperty(name, value); - } - public Date getLastModificationDate() throws RepositoryException { return currentNode.getLastModificationDate(); } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewResourceHelper.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewResourceHelper.java 2005-11-11 16:00:04 UTC (rev 1559) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNewResourceHelper.java 2005-11-11 22:53:22 UTC (rev 1560) @@ -21,7 +21,9 @@ */ package org.jboss.shotoku.svn; +import org.jboss.shotoku.AbstractResource; import org.jboss.shotoku.Directory; +import org.jboss.shotoku.exceptions.RepositoryException; /** * A base class for new resource helpers - their function is tu tunnel all @@ -32,12 +34,57 @@ * @author Adam Warski (ad...@as...) * @author Damon Sicore (da...@si...) */ -public abstract class SvnNewResourceHelper { +public abstract class SvnNewResourceHelper implements AbstractResource { protected Directory parentDirectory; protected String name; + protected AbstractResource currentResource; public SvnNewResourceHelper(Directory parentDirectory, String name) { this.parentDirectory = parentDirectory; this.name = name; } + + protected abstract AbstractResource getNormalResource(); + + public void save(String logMessage) throws RepositoryException { + String[] nameParts = name.split("[/]"); + Directory lastParent = parentDirectory; + for (int i=0; i<nameParts.length-1; i++) { + if (!"".equals(nameParts[i])) { + lastParent = lastParent.newDirectory(nameParts[i]); + lastParent.save(logMessage); + } + } + + currentResource.save(logMessage); + currentResource = getNormalResource(); + } + + public String getFullName() { + return currentResource.getFullName(); + } + + public void delete() throws RepositoryException { + currentResource.delete(); + } + + public String getLogMessage() throws RepositoryException { + return currentResource.getLogMessage(); + } + + public String getName() { + return currentResource.getName(); + } + + public Directory getParent() throws RepositoryException { + return currentResource.getParent(); + } + + public String getProperty(String name) throws RepositoryException { + return currentResource.getProperty(name); + } + + public void setProperty(String name, String value) { + currentResource.setProperty(name, value); + } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNode.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNode.java 2005-11-11 16:00:04 UTC (rev 1559) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnNode.java 2005-11-11 22:53:22 UTC (rev 1560) @@ -45,9 +45,9 @@ SvnNode.class.getResourceAsStream("/mime-types.txt")); } - public SvnNode(String id, String fullPath, File file, String name, + public SvnNode(String id, String fullPath, File file, SvnContentManager svnCm) { - super(id, fullPath, file, name, svnCm); + super(id, fullPath, file, svnCm); } public History getHistory() { Added: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java 2005-11-11 16:00:04 UTC (rev 1559) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/SlashNamesTest.java 2005-11-11 22:53:22 UTC (rev 1560) @@ -0,0 +1,66 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.shotoku.test; + +import org.jboss.shotoku.Directory; +import org.jboss.shotoku.Node; + +/** + * @author Adam Warski (ad...@as...) + * @author Damon Sicore (da...@si...) + */ +public class SlashNamesTest extends ShotokuTest { + private final static String TEST_DIR = "slash-test-dir"; + private final static String TEST_NESTED_DIR = "a/b/c"; + private final static String TEST_NESTED_NODE = "h/j/k"; + private final static String TEST_CONTENT = "T"; + + public void setUp() { + cm.getRootDirectory().newDirectory(TEST_DIR).save(TEST_DIR); + } + + public void testNested() { + Directory base = cm.getDirectory(TEST_DIR); + Directory nested1 = base.newDirectory(TEST_NESTED_DIR); + Node nested2 = base.newNode(TEST_NESTED_NODE); + + assertTrue((TEST_DIR + "/" + TEST_NESTED_DIR).equals(nested1.getFullName())); + assertTrue((TEST_DIR + "/" + TEST_NESTED_NODE).equals(nested2.getFullName())); + + nested1.save(""); + + nested2.setContent(TEST_CONTENT); + nested2.save(""); + + // We should be able to get the directories and node. + base.getDirectory("a").getDirectory("b").getDirectory("c"); + base.getDirectory(TEST_NESTED_DIR); + + assertTrue(TEST_CONTENT.equals(base.getDirectory("h"). + getDirectory("j").getNode("k").getContent())); + assertTrue(TEST_CONTENT.equals(base.getNode(TEST_NESTED_NODE).getContent())); + } + + public void tearDown() { + cm.getDirectory(TEST_DIR).delete(); + } +} |
From: <jbo...@li...> - 2005-11-11 16:00:12
|
Author: dam...@jb... Date: 2005-11-11 11:00:04 -0500 (Fri, 11 Nov 2005) New Revision: 1559 Added: trunk/labs/javassist/ trunk/labs/jbossaop/ trunk/labs/jbossas/ trunk/labs/jbosscache/ trunk/labs/jbossejb3/ trunk/labs/jbosside/ trunk/labs/jbossiiop/ trunk/labs/jbossjbpm/ trunk/labs/jbossmail/ trunk/labs/jbossmc/ trunk/labs/jbossmessaging/ trunk/labs/jbossportal/ trunk/labs/jbossremoting/ trunk/labs/jbossseam/ trunk/labs/jbosssecurity/ trunk/labs/jbossserialization/ trunk/labs/jbosswiki/ trunk/labs/jbossws/ trunk/labs/shotoku/ trunk/labs/tomcat/ Log: Adding project dirs. |
From: <jbo...@li...> - 2005-11-11 15:40:50
|
Author: dam...@jb... Date: 2005-11-11 10:40:44 -0500 (Fri, 11 Nov 2005) New Revision: 1558 Added: trunk/labs/jgroups/ Log: Added home for jgroups. yay. |
From: <jbo...@li...> - 2005-11-11 08:55:39
|
Author: aron.gombas Date: 2005-11-11 03:55:34 -0500 (Fri, 11 Nov 2005) New Revision: 1556 Modified: trunk/labs/kosmos/deploy-portlet-liferay-portal.xml Log: Liferay deploy script slightly updated Modified: trunk/labs/kosmos/deploy-portlet-liferay-portal.xml =================================================================== --- trunk/labs/kosmos/deploy-portlet-liferay-portal.xml 2005-11-11 08:50:21 UTC (rev 1555) +++ trunk/labs/kosmos/deploy-portlet-liferay-portal.xml 2005-11-11 08:55:34 UTC (rev 1556) @@ -4,7 +4,11 @@ <project basedir="." default="redeploy" name="Kosmos Portlet on Liferay Portal"> <description>Kosmos Portlet Module deploy-file</description> - <!-- TODO this is fairly useless at the moment, because the Liferay deployment is quite complicated! refer to the manual instead --> + <!-- + TODO this is fairly useless at the moment, because the Liferay deployment is quite complicated! refer to the manual instead! + also, instead of running this, it should really call the original "portlet-deployer-3.5.0.xml"! + and should preprocess the JSP's to fix the font-size problem. + --> <property name="module.name" value="portlet"/> <property name="container.name" value="liferay-portal"/> <import file="build/deploy.xml"/> |
From: <jbo...@li...> - 2005-11-11 08:50:29
|
Author: aron.gombas Date: 2005-11-11 03:50:21 -0500 (Fri, 11 Nov 2005) New Revision: 1555 Modified: trunk/labs/kosmos/xdocs/reference/reference-manual.xml Log: "Deployment" section in the man rewritten Modified: trunk/labs/kosmos/xdocs/reference/reference-manual.xml =================================================================== --- trunk/labs/kosmos/xdocs/reference/reference-manual.xml 2005-11-11 07:00:55 UTC (rev 1554) +++ trunk/labs/kosmos/xdocs/reference/reference-manual.xml 2005-11-11 08:50:21 UTC (rev 1555) @@ -722,10 +722,11 @@ want to use these, you will need to install Ant. The default target of each script is <literal>redeploy</literal>, which deletes the old deployment (if there exists) and deploys a - new clean one. - Of course, you can still deploy manually if Ant is not available in + new clean one.</para> + <para>Of course, you can still deploy manually if Ant is not available in your environment. Even in this case, it's a good idea to - look through the deploy scripts.</para> + look through the deploy scripts and then to follow the + step-by-step guide provided in the next sections.</para> </listitem> @@ -733,30 +734,28 @@ <para>The server component requires standard servlet containers (or a single container) for proper running. - The most trivial option is to use the Apache - Tomcat container, which you can found at - <ulink url="http://jakarta.apache.org/tomcat"> - http://jakarta.apache.org/tomcat</ulink>.</para> + The most trivial option is to use the + <ulink url="http://jakarta.apache.org/tomcat">Apache Tomcat</ulink> container.</para> </listitem> <listitem> <para>The portlets needs a JSR-168-compliant portlet - container. One possible open source choice is JBoss Portal ( - <ulink url="http://www.jboss.org/products/jbossportal">http://www.jboss.org/products/jbossportal</ulink>) - deployed into a JBoss Application server instance ( - <ulink url="http://www.jboss.org/products/jbossas">http://www.jboss.org/products/jbossas</ulink>).</para> + container. One possible open source choice is + <ulink url="http://www.jboss.org/products/jbossportal">JBoss Portal</ulink> + deployed into a <ulink url="http://www.jboss.org/products/jbossas">JBoss Application server</ulink> + instance.</para> </listitem> <listitem> <para>For storing the dynamically generated content (e.g. chart - images), you need a WebDAV server implementation. One option - is to use Jakarta Slide (available at - <ulink url="http://jakarta.apache.org/slide">http://jakarta.apache.org/slide</ulink>), - but Subversion provides a WebDAV interface, too.</para> + images), you need a <ulink url="http://www.webdav.org/">WebDAV</ulink> server implementation. One option + is to use <ulink url="http://jakarta.apache.org/slide">Jakarta Slide</ulink>, + but <ulink url="http://subversion.tigris.org">Subversion</ulink> + provides a WebDAV interface, too.</para> </listitem> @@ -858,8 +857,11 @@ <listitem> - <para>Install eXo as written in its <ulink url="http://www.exoplatform.com/portal/faces/public/exo/home/community/wiki">documentation</ulink>. - You can find eXo at <ulink url="http://www.exoplatform.com">http://www.exoplatform.com</ulink>.</para> + <para>Install <ulink url="http://www.exoplatform.com">eXo Platform</ulink> + as written in its <ulink url="http://www.exoplatform.com/portal/faces/public/exo/home/community/wiki">documentation</ulink>. + We recommend using the bundle distribution, because that contains both the + Apache Tomcat servlet container and the eXo Platform portlet container + in a single package.</para> </listitem> @@ -884,7 +886,7 @@ <listitem> - <para>Run the portlet deploy script as: + <para>Deploy the portlet web application by running the portlet deployment script as: <programlisting>ant -f deploy-portlet-exo.xml</programlisting> </para> @@ -892,7 +894,7 @@ <listitem> - <para>Lauch eXo, open the default portal page + <para>Launch eXo, open the default portal page (e.g. <literal>http://localhost:8080/portal</literal>), and login with the default account (<literal>admin</literal> and <literal>exo</literal>).</para> Go to page <literal>edit</literal> mode @@ -918,8 +920,8 @@ <listitem> - <para>Install Gridsphere as written in its <ulink url="http://www.gridsphere.org/gridsphere/docs/UsersGuide/UsersGuide.html">manual</ulink>. - You can find Gridsphere at <ulink url="http://www.gridsphere.org">http://www.gridsphere.org</ulink>.</para> + <para>Install <ulink url="http://www.gridsphere.org">Gridsphere</ulink> as written + in its <ulink url="http://www.gridsphere.org/gridsphere/docs/UsersGuide/UsersGuide.html">manual</ulink>.</para> </listitem> @@ -933,7 +935,7 @@ <listitem> <para>You can deploy the server component into the Apache Tomcat - instance used by Gridsphere, by running the server deploy script: + instance used by Gridsphere simply by running the server deploy script: <programlisting>ant -f deploy-server-tomcat.xml</programlisting> Please don't forget to set the <literal>CATALINA_HOME</literal> environment variable before. @@ -943,7 +945,7 @@ <listitem> - <para>Run the portlet deploy script as: + <para>Deploy the portlet web application by running the portlet deploy script as: <programlisting>ant -f deploy-portlet-gridsphere.xml</programlisting> As an additional step, copy <filename>$GRIDSPHERE_HOME/build/lib/gridsphere-ui-tags.jar</filename> to <filename>$CATALINA_HOME/webapps/kosmos-portlet.war/WEB-INF/lib</filename>. @@ -953,11 +955,11 @@ <listitem> - <para>Lauch Gridsphere, open the default portal page + <para>Launch Gridsphere, open the default portal page (e.g. <literal>http://localhost:8080/gridsphere</literal>), and login with the default account (<literal>root</literal> and empty password). After this, there are couple of extra steps - that you can do using the Gridsphere admin portlets: + that you have to do using the Gridsphere admin portlets: <orderedlist> <listitem> @@ -1012,16 +1014,20 @@ <listitem> <para>Deploy <ulink url="http://jakarta.apache.org/slide">Jakarta Slide</ulink> to JBoss AS and configure it as - written in the appropriate manuals. Test if you can access - the Slide repositories through a WebDAV navigator. If you - use Windows XP, it is able to map a WebDAV repository as - a folder to your filesystem.</para> + written in the appropriate manuals. We have included the Slide web application archive (<filename>slide.war</filename>) + in the binary distribution package of Kosmos, under the <filename>/etc</filename> folder. + In most situations, it's enough to copy this file to the deployment folder + of the servlet container or the application server.</para> + <para>As a quick test, check whether you can access the Slide repositories through a WebDAV navigator. + If you use Windows XP, it is able to map a WebDAV repository as + a folder to your filesystem. Otherwise try to open the repository in your + browser using the <literal>http://localhost:8080/slide</literal> URL.</para> </listitem> <listitem> - <para>Install JBoss Portal as written in its manual. Test + <para>Install JBoss Portal as written in its manual. Check if there are no error messages in the JBoss AS logfile.</para> @@ -1037,7 +1043,7 @@ <listitem> - <para>Run the portlet deploy script as: + <para>Deploy the portlet web application by running the portlet deploy script as: <programlisting>ant -f deploy-portlet-jboss-portal.xml</programlisting> </para> @@ -1045,7 +1051,7 @@ <listitem> - <para>Lauch JBoss AS and check the default portal page + <para>Launch JBoss AS and check the default portal page (e.g. <literal>http://localhost:8080/portal</literal>), whether you can see the <literal>Kosmos</literal> page in the page list.</para> @@ -1071,12 +1077,10 @@ <listitem> - <para>Install Liferay Portal as written in its manual. We recommend - using the bundle distribution, because that contains both the + <para>Install <ulink url="http://www.liferay.com/web/guest/products">Liferay Portal</ulink> + as written in its manual. We recommend using the bundle distribution, because that contains both the Apache Tomcat servlet container and the Liferay Portal portlet container - in a single package. - You can find Liferay at <ulink url="http://www.liferay.com/web/guest/products"> - http://www.liferay.com/web/guest/products</ulink>.</para> + in a single package.</para> </listitem> @@ -1090,7 +1094,7 @@ <listitem> <para>You can deploy the server component into the Apache Tomcat - instance used by Liferay, by running the server deploy script: + instance used by Liferay simply by running the server deploy script: <programlisting>ant -f deploy-server-tomcat.xml</programlisting> Please don't forget to set the <literal>CATALINA_HOME</literal> environment variable before. @@ -1113,13 +1117,13 @@ <orderedlist> <listitem> - <para>You have to downgrade the <filename>$LIFERAY_HOME/webapps/kosmos-portlet/WEB-INF/lib/commons-logging-1.0.4.jar</filename> to <filename>commons-logging-1.0.3.jar</filename> (downloadable from <ulink url="http://www.ibiblio.org/maven/commons-logging/jars/">http://www.ibiblio.org/maven/commons-logging/jars/</ulink>) if Liferay throws a <literal>java.lang.NoSuchMethodError: org.apache.log4j.Category.log(Ljava/lang/String;Lorg/apache/log4j/Level;Ljava/lang/Object;Ljava/lang/Throwable;)V</literal>. - The same exception can be thrown also for the kosmos-servlet web-application, the fix is the same: downgrade the same JAR also in <filename>$LIFERAY_HOME/webapps/kosmos-server/WEB-INF/lib</filename>. + <para>You have to downgrade the <filename>$LIFERAY_HOME/webapps/kosmos-portlet/WEB-INF/lib/ext/commons-logging-1.0.4.jar</filename> to <filename>commons-logging-1.0.3.jar</filename> (downloadable from <ulink url="http://www.ibiblio.org/maven/commons-logging/jars/">http://www.ibiblio.org/maven/commons-logging/jars/</ulink>) if Liferay throws a <literal>java.lang.NoSuchMethodError: org.apache.log4j.Category.log(Ljava/lang/String;Lorg/apache/log4j/Level;Ljava/lang/Object;Ljava/lang/Throwable;)V</literal>. + The same exception might be thrown also for the kosmos-servlet and the kosmos-portlet web-applications, the fix is the same: downgrade the same JAR also in <filename>$LIFERAY_HOME/webapps/kosmos-server/WEB-INF/lib</filename> and <filename>$LIFERAY_HOME/webapps/kosmos-portlet/WEB-INF/lib</filename>, respectively. </para> </listitem> <listitem> - <para>You have to delete <filename>$LIFERAY_HOME/common/endorsed/lib/xml-apis.jar</filename> if Liferay throws a <literal>javax.servlet.ServletException: Provider org.apache.xalan.processor.TransformerFactoryImpl not found</literal> exception + <para>You have to delete <filename>$LIFERAY_HOME/common/endorsed/xml-apis.jar</filename> if Liferay throws a <literal>javax.servlet.ServletException: Provider org.apache.xalan.processor.TransformerFactoryImpl not found</literal> exception </para> </listitem> @@ -1141,19 +1145,22 @@ <listitem> - <para>Lauch Liferay, open the default portal page - (e.g. <literal>http://localhost:8080</literal>), + <para>Launch Liferay, open the default portal page + (e.g. <literal>http://localhost:8080</literal>) and login with the default account (<literal>te...@li...</literal> - and <literal>test</literal>) and check whether you can see the - Kosmos portlets selectable in the combox boxes at the bottom of - the portal pages.</para> + and <literal>test</literal>).</para> + <para>Open the portlet administration portlet and assign some + roles to the Kosmos portlets (e.g. <literal>User</literal> and + <literal>Guest</literal>). Also, set the JIRA and Subversion monitoring + portlets to <literal>wide</literal> style, all the others to + <literal>narrow</literal>. Create a new page or go to an existing page, + and check whether you can see the Kosmos portlets selectable in the + combo boxes at the bottom of the portal pages.</para> </listitem> </orderedlist> - It is possible also to hot-deploy the components while JBoss AS - is running. </para> </section> @@ -1169,12 +1176,10 @@ <listitem> - <para>Install Pluto as written in its manual. We recommend - using the bundle distribution, because that contains both the + <para>Install <ulink url="http://portals.apache.org/pluto">Pluto</ulink> as written in its manual. + We recommend using the bundle distribution, because that contains both the Apache Tomcat servlet container and the Pluto portlet container - in a single package. - You can find Pluto at <ulink url="http://portals.apache.org/pluto"> - http://portals.apache.org/pluto</ulink> site.</para> + in a single package.</para> </listitem> @@ -1188,7 +1193,7 @@ <listitem> <para>You can deploy the server component into the Apache Tomcat - instance used by Pluto, by running the server deploy script: + instance used by Pluto simply by running the server deploy script: <programlisting>ant -f deploy-server-tomcat.xml</programlisting> Please don't forget to set the <literal>CATALINA_HOME</literal> environment variable before. @@ -1207,7 +1212,7 @@ menu!</para> <para>If for some reason you decided to do an automated deployment - instead of using the administrative portlet, run the portlet deploy script as: + instead of using the administrative portlet, deploy the portlet web application by running the portlet deploy script as: <programlisting>ant -f deploy-portlet-pluto.xml</programlisting> After this, you have to manually update the following Pluto configuration files: |