Java Examples for com.izforge.izpack.installer.AutomatedInstallData
The following java examples will help you to understand the usage of com.izforge.izpack.installer.AutomatedInstallData. These source code samples are taken from different open source projects.
Example 1
| Project: izpack-with-ips-master File: Unix_Shortcut.java View source code |
/**
* Creates and stores the shortcut-files.
*
* @see com.izforge.izpack.util.os.Shortcut#save()
*/
public void save() throws Exception {
String target = null;
String shortCutDef = this.replace();
boolean rootUser4All = this.getUserType() == Shortcut.ALL_USERS;
boolean create4All = this.getCreateForAll();
// Create The Desktop Shortcuts
if ("".equals(this.itsGroupName) && (this.getLinkType() == Shortcut.DESKTOP)) {
this.itsFileName = target;
AutomatedInstallData idata;
idata = AutomatedInstallData.getInstance();
// read the userdefined / overridden / wished Shortcut Location
// This can be an absolute Path name or a relative Path to the InstallPath
File shortCutLocation = null;
File ApplicationShortcutPath;
String ApplicationShortcutPathName = idata.getVariable("ApplicationShortcutPath");
if (null != ApplicationShortcutPathName && !ApplicationShortcutPathName.equals("")) {
ApplicationShortcutPath = new File(ApplicationShortcutPathName);
if (ApplicationShortcutPath.isAbsolute()) {
// I know :-) Can be m"ORed" elegant :)
if (!ApplicationShortcutPath.exists() && ApplicationShortcutPath.mkdirs() && ApplicationShortcutPath.canWrite())
shortCutLocation = ApplicationShortcutPath;
if (ApplicationShortcutPath.exists() && ApplicationShortcutPath.isDirectory() && ApplicationShortcutPath.canWrite())
shortCutLocation = ApplicationShortcutPath;
} else {
File relativePath = new File(idata.getInstallPath() + FS + ApplicationShortcutPath);
relativePath.mkdirs();
shortCutLocation = new File(relativePath.toString());
}
} else
shortCutLocation = new File(idata.getInstallPath());
// write the App ShortCut
File writtenDesktopFile = writeAppShortcutWithOutSpace(shortCutLocation.toString(), this.itsName, shortCutDef);
uninstaller.addFile(writtenDesktopFile.toString(), true);
if (xdgDesktopIconCmd != null) {
createExtXdgDesktopIconCmd(shortCutLocation);
// / TODO: DELETE the ScriptFiles
myInstallScript.appendln(new String[] { myXdgDesktopIconCmd, "install", "--novendor", StringTool.escapeSpaces(writtenDesktopFile.toString()) });
ShellScript myUninstallScript = new ShellScript();
myUninstallScript.appendln(new String[] { myXdgDesktopIconCmd, "uninstall", "--novendor", StringTool.escapeSpaces(writtenDesktopFile.toString()) });
uninstaller.addUninstallScript(myUninstallScript.getContentAsString());
} else {
// otherwise copy to my desktop and add to uninstaller
File myDesktopFile;
do {
myDesktopFile = new File(myHome + FS + "Desktop" + writtenDesktopFile.getName() + "-" + System.currentTimeMillis() + DESKTOP_EXT);
} while (myDesktopFile.exists());
copyTo(writtenDesktopFile, myDesktopFile);
uninstaller.addFile(myDesktopFile.toString(), true);
}
// If I'm root and this Desktop.ShortCut should be for all other users
if (rootUser4All && create4All) {
if (xdgDesktopIconCmd != null) {
installDesktopFileToAllUsersDesktop(writtenDesktopFile);
} else // OLD ( Backward-Compatible/hardwired-"Desktop"-Foldername Styled Mechanic )
{
copyDesktopFileToAllUsersDesktop(writtenDesktopFile);
}
}
} else // This is - or should be only a Link in the [K?]-Menu
{
if (rootUser4All && create4All) {
{
// write the icon pixmaps into /usr/share/pixmaps
File theIcon = new File(this.getIconLocation());
File commonIcon = new File("/usr/share/pixmaps/" + theIcon.getName());
try {
copyTo(theIcon, commonIcon);
uninstaller.addFile(commonIcon.toString(), true);
} catch (Exception cnc) {
Debug.log("Could Not Copy: " + theIcon + " to " + commonIcon + "( " + cnc.getMessage() + " )");
}
// write *.desktop
this.itsFileName = target;
File writtenFile = writeAppShortcut("/usr/share/applications/", this.itsName, shortCutDef);
setWrittenFileName(writtenFile.getName());
uninstaller.addFile(writtenFile.toString(), true);
}
} else // create local XDG shortcuts
{
// System.out.println("Creating gnome shortcut");
String localApps = myHome + "/.local/share/applications/";
String localPixmaps = myHome + "/.local/share/pixmaps/";
// System.out.println("Creating "+localApps);
try {
java.io.File f = new java.io.File(localApps);
f.mkdirs();
f = new java.io.File(localPixmaps);
f.mkdirs();
} catch (Exception ignore) {
Debug.log("Failed creating " + localApps + " or " + localPixmaps);
}
// write the icon pixmaps into ~/share/pixmaps
File theIcon = new File(this.getIconLocation());
File commonIcon = new File(localPixmaps + theIcon.getName());
try {
copyTo(theIcon, commonIcon);
uninstaller.addFile(commonIcon.toString(), true);
} catch (Exception cnc) {
Debug.log("Could Not Copy: " + theIcon + " to " + commonIcon + "( " + cnc.getMessage() + " )");
}
// write *.desktop in the local folder
this.itsFileName = target;
File writtenFile = writeAppShortcut(localApps, this.itsName, shortCutDef);
setWrittenFileName(writtenFile.getName());
uninstaller.addFile(writtenFile.toString(), true);
}
}
}Example 2
| Project: tigase-server-master File: TigaseConfigLoadPanel.java View source code |
String loadConfig(AutomatedInstallData idata) {
// Try to read the config file.
File configPath = null;
StringBuilder config = new StringBuilder();
try {
if (idata.getVariable("searchTigaseHome") == null || idata.getVariable("searchTigaseHome").isEmpty()) {
configPath = new File(idata.getVariable("INSTALL_PATH"), "etc/init.properties");
} else {
configPath = new File(idata.getVariable("searchTigaseHome"), "etc/init.properties");
}
if (configPath.exists()) {
Properties props = new Properties();
props.load(new FileReader(configPath));
Debug.trace("Loading init.properties file...");
for (String name : props.stringPropertyNames()) {
config.append(name + " = " + props.getProperty(name) + "\n");
}
Debug.trace(config);
Debug.trace("Done.");
Debug.trace("Loading variables....");
for (String name : TigaseConfigConst.tigaseIzPackMap.keySet()) {
String varName = TigaseConfigConst.tigaseIzPackMap.get(name);
if (varName != null) {
Debug.trace("Loading: " + varName + " = " + props.getProperty(name));
if (varName.equals(TigaseConfigConst.DEBUG)) {
if (props.getProperty(name) != null) {
parseDebugs(props.getProperty(name), idata);
Debug.trace("Loaded: " + varName + " = " + props.getProperty(name));
} else {
Debug.trace("Missing configuration for " + varName);
}
continue;
}
if (varName.equals(TigaseConfigConst.PLUGINS)) {
if (props.getProperty(name) != null) {
parsePlugins(props.getProperty(name), idata);
Debug.trace("Loaded: " + varName + " = " + props.getProperty(name));
} else {
Debug.trace("Missing configuration for " + varName);
}
continue;
}
if (varName.equals(TigaseConfigConst.USER_DB_URI)) {
if (props.getProperty(name) != null) {
parseUserDbUri(props.getProperty(name), idata);
Debug.trace("Loaded: " + varName + " = " + props.getProperty(name));
} else {
Debug.trace("Missing configuration for " + varName);
}
continue;
}
if (varName.equals(TigaseConfigConst.DB_TYPE)) {
if (props.getProperty(name) != null) {
String dbType = TigaseConfigConst.userDBUriMap.get(props.getProperty(name));
if (dbType == null) {
dbType = "Other";
}
idata.setVariable(TigaseConfigConst.DB_TYPE, dbType);
Debug.trace("Loaded: " + varName + " = " + dbType);
} else {
Debug.trace("Missing configuration for " + varName);
}
continue;
}
if (varName.equals(TigaseConfigConst.AUTH_HANDLE)) {
if (props.getProperty(name) != null) {
idata.setVariable(TigaseConfigConst.AUTH_HANDLE, props.getProperty(name));
Debug.trace("Loaded: " + varName + " = " + props.getProperty(name));
} else {
Debug.trace("Missing configuration for " + varName);
}
continue;
}
if (varName.equals(TigaseConfigConst.MUC_COMP)) {
if ((props.getProperty("--comp-name-1") != null && props.getProperty("--comp-name-1").equals("muc")) || (props.getProperty("--comp-name-2") != null && props.getProperty("--comp-name-2").equals("muc"))) {
idata.setVariable(TigaseConfigConst.MUC_COMP, "on");
}
Debug.trace("Loaded: " + varName + " = " + idata.getVariable(TigaseConfigConst.MUC_COMP));
continue;
}
if (varName.equals(TigaseConfigConst.PUBSUB_COMP)) {
if ((props.getProperty("--comp-name-1") != null && props.getProperty("--comp-name-1").equals("pubsub")) || (props.getProperty("--comp-name-2") != null && props.getProperty("--comp-name-2").equals("pubsub"))) {
idata.setVariable(TigaseConfigConst.PUBSUB_COMP, "on");
}
Debug.trace("Load: " + "--comp-name-" + " = " + "pubsub");
continue;
}
if (varName.equals(TigaseConfigConst.AUTH_DB_URI)) {
if (props.getProperty(name) != null) {
parseAuthDbUri(props.getProperty(name), idata);
Debug.trace("Loaded: " + varName + " = " + props.getProperty(name));
} else {
Debug.trace("Missing configuration for " + varName);
}
continue;
}
if (props.getProperty(name) != null) {
idata.setVariable(varName, props.getProperty(name));
}
}
}
Debug.trace("Done.");
} else {
config.append("The config file: " + configPath + " seems to not exist...");
}
} catch (Exception err) {
StringBuilder errorConfig = new StringBuilder();
errorConfig.append("Error : could not load the config file: " + configPath + "\n");
errorConfig.append(err.toString() + "\n");
for (StackTraceElement ste : err.getStackTrace()) {
errorConfig.append(ste.toString() + "\n");
}
return errorConfig.toString();
}
return config.toString();
}Example 3
| Project: geronimo-master File: GeronimoConfigProcessor.java View source code |
protected boolean isPackSelected(AutomatedInstallData idata, String packName) {
boolean fRet = false;
int iSize = idata.selectedPacks.size();
if (iSize > 0) {
for (int i = 0; i < iSize; ++i) {
Pack p = (Pack) idata.selectedPacks.get(i);
if (p.name.equals(packName)) {
fRet = true;
}
}
}
return fRet;
}Example 4
| Project: addis-master File: JavaLocationListener.java View source code |
public void afterInstallerInitialization(AutomatedInstallData data) throws Exception {
// TODO Auto-generated method stub
}