oscom-lenya-notimes/pubs/ina/java/src/org/oscom/cocoon/acting LatestPublicationDateAction.java,NONE,1.1
Michael Wechner <[email protected]> Mon, 19 May 2003 23:35:46 +0200
| Newsgroups | gmane.comp.cms.wyona.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /usr/local/repositories/oscom-lenya-notimes/pubs/ina/java/src/org/oscom/cocoon/acting In directory erbium:/tmp/cvs-serv5456/pubs/ina/java/src/org/oscom/cocoon/acting Added Files: LatestPublicationDateAction.java Log Message: packages renamed --- NEW FILE: LatestPublicationDateAction.java --- /* * $Id: LatestPublicationDateAction.java,v 1.1 2003/05/19 21:35:43 michi Exp $ * <License> * The Apache Software License * * Copyright (c) 2002 lenya. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. All advertising materials mentioning features or use of this software must * display the following acknowledgment: "This product includes software developed * by lenya (http://www.lenya.org)" * * 4. The name "lenya" must not be used to endorse or promote products derived from * this software without prior written permission. For written permission, please * contact [email protected] * * 5. Products derived from this software may not be called "lenya" nor may "lenya" * appear in their names without prior written permission of lenya. * * 6. Redistributions of any form whatsoever must retain the following acknowledgment: * "This product includes software developed by lenya (http://www.lenya.org)" * * THIS SOFTWARE IS PROVIDED BY lenya "AS IS" WITHOUT ANY WARRANTY EXPRESS OR IMPLIED, * INCLUDING THE WARRANTY OF NON-INFRINGEMENT AND THE IMPLIED WARRANTIES OF MERCHANTI- * BILITY AND FITNESS FOR A PARTICULAR PURPOSE. lenya WILL NOT BE LIABLE FOR ANY DAMAGES * SUFFERED BY YOU AS A RESULT OF USING THIS SOFTWARE. IN NO EVENT WILL lenya BE LIABLE * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR LOST PROFITS EVEN IF lenya HAS * BEEN ADVISED OF THE POSSIBILITY OF THEIR OCCURRENCE. lenya WILL NOT BE LIABLE FOR ANY * THIRD PARTY CLAIMS AGAINST YOU. * * Lenya includes software developed by the Apache Software Foundation, W3C, * DOM4J Project, BitfluxEditor and Xopus. * </License> */ package org.oscom.cocoon.acting; import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.acting.AbstractAction; import org.apache.cocoon.environment.Request; import java.io.File; import java.lang.Integer; import java.text.DecimalFormat; import java.util.HashMap; import java.util.Calendar; import org.oscom.MostRecentPublicationDate; /** * An action that executes a task. * * @author <a href="mailto:[email protected]">Christian Egli</a> */ public class LatestPublicationDateAction extends AbstractAction { /** * DOCUMENT ME! * * @param redirector DOCUMENT ME! * @param sourceResolver DOCUMENT ME! * @param objectModel DOCUMENT ME! * @param str DOCUMENT ME! * @param parameters DOCUMENT ME! * * @return DOCUMENT ME! * * @throws java.lang.Exception DOCUMENT ME! */ public java.util.Map act(org.apache.cocoon.environment.Redirector redirector, org.apache.cocoon.environment.SourceResolver sourceResolver, java.util.Map objectModel, String str, Parameters parameters) throws java.lang.Exception { // Get Source org.apache.cocoon.environment.Source inputSource = sourceResolver.resolve(""); String publicationPath = inputSource.getSystemId(); // Remove "file:" protocol publicationPath = publicationPath.substring(5); getLogger().info("publicationPath: " + publicationPath); if (publicationPath.endsWith("/")) { publicationPath = publicationPath.substring(0, publicationPath.length() - 1); } getLogger().info("publicationPath: " + publicationPath); // int lastSlashIndex = publicationPath.lastIndexOf("/"); // String publicationId = publicationPath.substring(lastSlashIndex + 1); // getLogger().info("#######id " + publicationId); // publicationPath = publicationPath.substring(0, lastSlashIndex + 1); // getLogger().info("######### " + publicationPath); // String contextPath = publicationPath.substring(0, // publicationPath.length() - publicationPrefix.length()); // getLogger().info("######### " + contextPath); // publicationPath += publicationId; String articlesPath = publicationPath + File.separator + "content" + File.separator + "authoring" + File.separator + "articles"; Calendar cal = MostRecentPublicationDate.getInstance().getMostRecentPublicationDate(new File(articlesPath)); if (cal == null) { return null; } getLogger().info("cal: " + cal); DecimalFormat decimalFormatter = new DecimalFormat("00"); HashMap actionMap = new HashMap(); actionMap.put("year", new Integer(cal.get(Calendar.YEAR)).toString()); actionMap.put("month", decimalFormatter.format(cal.get(Calendar.MONTH))); actionMap.put("day", decimalFormatter.format(cal.get(Calendar.DAY_OF_MONTH))); return actionMap; } }