what a great utility!
i did get tangled on Unplutofier access of ./WEB-INF/portlet.xml
i put in a q&d correction by going straight to
System.getProperty("user.dir") + "/WEB_INF/web.xml"
here is the code..
/*
Copyright (c) 2010 Gary S. Weaver
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package unplutofy.service;
import unplutofy.service.request.UnplutofyRequest;
import unplutofy.util.FileUtil;
import unplutofy.util.XmlUtil;
import unplutofy.util.JarUtil;
import java.io.IOException;
import java.io.File;
import java.util.jar.Manifest;
/**
* @author Gary S. Weaver
*/
public class Unplutofier {
public boolean debug=true;
public void unplutofy(UnplutofyRequest req) throws IOException {
// unjar war file into temp dir
File unwarDir =new java.io.File("temp"); //BAD
ASSUMPTION...FileUtil.createTempDirectory();
System.err.println("Created temporary dir '" +
unwarDir.getCanonicalPath() + "'");
System.err.println("Decompressing '" + req.getInputFile() + "'...");
Manifest manifest = JarUtil.unjar(new File(req.getInputFile()),
unwarDir);
// unplutofy
String webXmlPathname = unwarDir.getCanonicalPath() + File.separator +
"WEB-INF" + File.separator + "web.xml";
System.err.println("Reading " + webXmlPathname);
String webXml = FileUtil.readFileAsString(webXmlPathname);
String unwarDir_string=unwarDir.getCanonicalPath();
String separator=File.separator;
//use a StringBuffer to append each value
StringBuffer sb=new StringBuffer();
//get the current user directory..
unwarDir_string =java.lang.System.getProperty("user.dir");
sb.append(unwarDir_string);
if(debug==true) System.out.println("sb="+sb.toString());
sb.append(separator);
if(debug==true) System.out.println("sb="+sb.toString());
sb.append("\\WEB-INF");
if(debug==true) System.out.println("sb="+sb.toString());
sb.append(separator);
if(debug==true) System.out.println("sb="+sb.toString());
sb.append("portlet.xml");
if(debug==true) System.out.println("sb="+sb.toString());
String portletXmlPathname =sb.toString(); // unwarDir + separator +
"WEB-INF" + separator + "portlet.xml";
System.err.println("Reading " + portletXmlPathname);
String portletXml = FileUtil.readFileAsString(portletXmlPathname);
System.err.println("Parsing portlet-name");
String portletName = XmlUtil.readElementValue("portlet-name",
portletXml).trim();
System.err.println("Parsed portlet-name '" + portletName + "'");
System.err.println("Editing web.xml");
webXml = unplutofyWebxml(webXml, portletName);
System.err.println("Saving web.xml");
FileUtil.writeStringToFile(webXml, webXmlPathname);
// rejar war file up to output warpathname
System.err.println("Compressing '" + req.getOutputFile() + "'...");
// used http://www.regexplanet.com/simple/index.html to test, but
online tester uses \ vs \\ like required in string...
String[] excludeFilenamePatterns = {"MANIFEST.MF", "portlet.*\\.tld"};
JarUtil.jar(unwarDir, new File(req.getOutputFile()), manifest,
excludeFilenamePatterns);
// clean-up
unwarDir.delete();
System.err.println("Deleted temporary dir '" +
unwarDir.getCanonicalPath() + "'");
}
Thanks Gary!
Martin--
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung.
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est
interdite. Ce message sert à l'information seulement et n'aura pas n'importe
quel effet légalement obligatoire. Étant donné que les email peuvent facilement
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité
pour le contenu fourni.
From: [email protected]
Subject: Re: unplutofy - undoes Pluto assembly does to portlet wars
Date: Tue, 1 Jun 2010 12:18:38 -0400
To: [email protected]
Martin,
Drop the "-" - it is just:
git clone http://github.com/garysweaver/unplutofy.git
Thanks for trying it out!
Gary
On Jun 1, 2010, at 12:10 PM, Martin Gainty wrote:
Hi Guys-
My version of git does'nt support clone?
/GarySWeaver>git -clone http://github.com/garysweaver/unplutofy.git
Unknown option: -clone
usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]
[-p|--paginate|--no-pager] [--no-replace-objects]
[--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
[--help] COMMAND [ARGS]
/GarySWeaver>git --version
git version 1.7.0.2.msysgit.0
advice?
Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung.
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est
interdite. Ce message sert à l'information seulement et n'aura pas n'importe
quel effet légalement obligatoire. Étant donné que les email peuvent facilement
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité
pour le contenu fourni.
> From: [email protected]
> Subject: unplutofy - undoes Pluto assembly does to portlet wars
> Date: Tue, 1 Jun 2010 11:26:49 -0400
> To: [email protected]
>
> For anyone who is interested, I wrote a java-based utility (command-line
> script, ant task, maven plugin, and Java API) that will undo what Pluto
> assembly does to portlets. This is so that portlets that were pluto-fied
> previously (and had their web.xml modified and portlet.tld added) can be
> cleaned up and redeployed to the same or a different version of Pluto used by
> a portal.
>
> The project is here:
> http://github.com/garysweaver/unplutofy
>
> It assumes you have Git installed (to get the project from GitHub) and Maven
> 2 and Java 1.5+ SDK installed (to build it).
>
> As of today (2010/05/01), Unplutofy has only been tested with modifications
> made by Pluto 1.0.0-RC2 and Pluto 1.1.7, however it could easily be modified
> to support other versions of Pluto.
>
> Many would typically not need such a utility since if you have the version of
> the portlet prior to pluto-fication (Pluto assembly) or can rebuild it, then
> you could just do run whatever you need to in order to run Pluto assembly on
> that war. However, this utility saves the process of having to clean up the
> web.xml, etc. by hand, if you ever get into the situation where you have a
> deployed portlet that you need to clean up so that it can be redeployed.
>
> It is somewhat risky I suppose to remove all elements in the web.xml that
> look like those added by Pluto, but it assumes you have backups of existing
> portlets (since it is setup so that you can maintain the original and just
> create an un-pluto-fied version of it). Hopefully having this option will be
> of benefit to some.
>
> Please let me know if anything looks wrong with it or if you have any
> suggestions. Sorry that it hasn't been tested with Pluto 2.x yet.
>
> Thanks,
> Gary
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
Learn more.
_________________________________________________________________
The New Busy is not the old busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3