state.manifest = JarReader.readJarEntry(token,
info.jarFilename, MIDletSuite.JAR_MANIFEST);
if (state.manifest == null) {
postInstallMsgBackToProvider(
OtaNotifier.INVALID_JAR_MSG);
throw new
InvalidJadException(InvalidJadException.CORRUPT_JAR,
MIDletSuite.JAR_MANIFEST);
}
} catch (OutOfMemoryError e) {
try {
postInstallMsgBackToProvider(
OtaNotifier.INSUFFICIENT_MEM_MSG);
} catch (Throwable t) {
if (Logging.REPORT_LEVEL <= Logging.WARNING) {
Logging.report(Logging.WARNING, LogChannels.LC_AMS,
"Throwable during posting the install message");
}
}
throw new
InvalidJadException(InvalidJadException.TOO_MANY_PROPS);
} catch (IOException ioe) {
postInstallMsgBackToProvider(
OtaNotifier.INVALID_JAR_MSG);
throw new
InvalidJadException(InvalidJadException.CORRUPT_JAR,
MIDletSuite.JAR_MANIFEST);
}
state.jarProps = new ManifestProperties();
try {
// JarFile jarFile = new JarFile(new java.io.File(info.jarFilename));
// Manifest manifest = jarFile.getManifest();
// state.jarProps.readFromAttributes(manifest.getMainAttributes());
state.jarProps.load(new ByteArrayInputStream(state.manifest));
state.manifest = null;
} catch (OutOfMemoryError e) {
state.manifest = null;
try {
postInstallMsgBackToProvider(
OtaNotifier.INSUFFICIENT_MEM_MSG);
} catch (Throwable t) {
if (Logging.REPORT_LEVEL <= Logging.WARNING) {
Logging.report(Logging.WARNING, LogChannels.LC_AMS,
"Throwable while posting install message ");
}
}
throw new
InvalidJadException(InvalidJadException.TOO_MANY_PROPS);
} catch (InvalidJadException ije) {
state.manifest = null;
try {
postInstallMsgBackToProvider(
OtaNotifier.INVALID_JAR_MSG);
} catch (Throwable t) {
// ignore
}
throw ije;
}
for (int i = 1; ; i++) {
midlet = state.getAppProperty("MIDlet-" + i);
if (midlet == null) {
break;
}
/*
* Verify the MIDlet class is present in the JAR
* An exception thrown if not.
* Do the proper install notify on an exception
*/
try {
midletInfo = new MIDletInfo(midlet);
verifyMIDlet(midletInfo.classname);
} catch (InvalidJadException ije) {
if (ije.getReason() == InvalidJadException.INVALID_VALUE) {
postInstallMsgBackToProvider(
OtaNotifier.INVALID_JAD_MSG);
} else {
postInstallMsgBackToProvider(
OtaNotifier.INVALID_JAR_MSG);
}
throw ije;
}
}
// move on to the next step after a warning
state.nextStep++;
// Check Manifest entries against .jad file
if (info.jadUrl != null) {
if (bytesDownloaded != info.expectedJarSize) {
postInstallMsgBackToProvider(
OtaNotifier.JAR_SIZE_MISMATCH_MSG);
throw new InvalidJadException(
InvalidJadException.JAR_SIZE_MISMATCH);
}
if (!info.suiteName.equals(state.jarProps.getProperty(
MIDletSuite.SUITE_NAME_PROP))) {
postInstallMsgBackToProvider(
OtaNotifier.ATTRIBUTE_MISMATCH_MSG);
throw new InvalidJadException(
InvalidJadException.SUITE_NAME_MISMATCH);
}
if (!info.suiteVersion.equals(
state.jarProps.getProperty(MIDletSuite.VERSION_PROP))) {
postInstallMsgBackToProvider(
OtaNotifier.ATTRIBUTE_MISMATCH_MSG);
throw new InvalidJadException(
InvalidJadException.VERSION_MISMATCH,
new String(info.suiteVersion + "," + state.jarProps.getProperty(MIDletSuite.VERSION_PROP)));
}
if (!info.suiteVendor.equals(
state.jarProps.getProperty(MIDletSuite.VENDOR_PROP))) {
postInstallMsgBackToProvider(
OtaNotifier.ATTRIBUTE_MISMATCH_MSG);
throw new InvalidJadException(
InvalidJadException.VENDOR_MISMATCH);
}
} else {
info.expectedJarSize = bytesDownloaded;
info.suiteName = state.jarProps.getProperty(
MIDletSuite.SUITE_NAME_PROP);
if (info.suiteName == null || info.suiteName.length() == 0) {
postInstallMsgBackToProvider(
OtaNotifier.INVALID_JAR_MSG);
throw new InvalidJadException(
InvalidJadException.MISSING_SUITE_NAME);
}
info.suiteVendor = state.jarProps.getProperty(
MIDletSuite.VENDOR_PROP);
if (info.suiteVendor == null ||
info.suiteVendor.length() == 0) {
postInstallMsgBackToProvider(
OtaNotifier.INVALID_JAR_MSG);
throw new InvalidJadException(
InvalidJadException.MISSING_VENDOR);
}
info.suiteVersion = state.jarProps.getProperty(
MIDletSuite.VERSION_PROP);
if (info.suiteVersion == null ||
info.suiteVersion.length() == 0) {
postInstallMsgBackToProvider(
OtaNotifier.INVALID_JAR_MSG);
throw new InvalidJadException(
InvalidJadException.MISSING_VERSION);
}
try {
checkVersionFormat(info.suiteVersion);
} catch (NumberFormatException nfe) {
postInstallMsgBackToProvider(
OtaNotifier.INVALID_JAR_MSG);
throw new InvalidJadException(
InvalidJadException.INVALID_VERSION);
}
// if already installed, check the domain of the JAR URL