root / import / ext3D / trunk / install-extension3d / IzPack / sample / src / myCompany / tools / install / listener / ChmodCompilerListener.java @ 15280
History | View | Annotate | Download (2.88 KB)
1 |
/*
|
---|---|
2 |
* $Id: ChmodCompilerListener.java,v 1.1 2006/06/14 07:29:07 cesar Exp $
|
3 |
* IzPack
|
4 |
* Copyright (C) 2004 Klaus Bartz
|
5 |
*
|
6 |
* File : ChmodCompilerListener.java
|
7 |
* Description : Example for custom action for packaging time.
|
8 |
* Author's email : klaus.bartz@coi.de
|
9 |
* Author's Website : http://www.coi.de/
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
24 |
*/
|
25 |
|
26 |
package com.myCompany.tools.install.listener; |
27 |
import java.util.HashMap; |
28 |
import java.util.Iterator; |
29 |
import java.util.Map; |
30 |
import java.util.Vector; |
31 |
|
32 |
import net.n3.nanoxml.XMLElement; |
33 |
import com.izforge.izpack.compiler.CompilerException; |
34 |
import com.izforge.izpack.event.SimpleCompilerListener; |
35 |
|
36 |
|
37 |
/**
|
38 |
* <p>CompilerListener for file and directory permissions.</p>
|
39 |
*
|
40 |
* @author Klaus Bartz
|
41 |
*
|
42 |
*/
|
43 |
public class ChmodCompilerListener extends SimpleCompilerListener |
44 |
{ |
45 |
|
46 |
|
47 |
/* (non-Javadoc)
|
48 |
* @see com.izforge.izpack.compiler.CompilerListener#reviseAdditionalDataMap(java.util.Map, net.n3.nanoxml.XMLElement)
|
49 |
*/
|
50 |
public Map reviseAdditionalDataMap(Map existentDataMap, XMLElement element) |
51 |
throws CompilerException
|
52 |
{ |
53 |
Map retval = existentDataMap != null ? |
54 |
existentDataMap : new HashMap(); |
55 |
Vector dataList = element.getChildrenNamed("additionaldata"); |
56 |
Iterator iter = null; |
57 |
if( dataList == null || dataList.size() == 0 ) |
58 |
return( existentDataMap);
|
59 |
iter = dataList.iterator(); |
60 |
while( iter.hasNext() )
|
61 |
{ |
62 |
XMLElement data = (XMLElement) iter.next(); |
63 |
String [] relevantKeys = { "permission.dir", "permission.file"}; |
64 |
for( int i = 0; i < relevantKeys.length; ++i ) |
65 |
{ |
66 |
String key = data.getAttribute("key"); |
67 |
if( key.equalsIgnoreCase(relevantKeys[i]))
|
68 |
{ |
69 |
String value = data.getAttribute("value"); |
70 |
if (value == null || value.length() == 0) |
71 |
continue;
|
72 |
try
|
73 |
{ |
74 |
int radix = value.startsWith("0") ? 8 : 10; |
75 |
retval.put(key,Integer.valueOf(value, radix));
|
76 |
} catch (NumberFormatException x) |
77 |
{ |
78 |
throw new CompilerException("'" + relevantKeys[i] + "' must be an integer"); |
79 |
} |
80 |
} |
81 |
} |
82 |
} |
83 |
return retval;
|
84 |
} |
85 |
} |