use of com.intellij.ide.wizard.CommitStepException in project android by JetBrains.
the class NewKeyForm method loadKeystoreAndKey.
private void loadKeystoreAndKey(String keystoreLocation, String keystorePassword, String keyAlias, String keyPassword) throws CommitStepException {
FileInputStream fis = null;
try {
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
fis = new FileInputStream(new File(keystoreLocation));
keyStore.load(fis, keystorePassword.toCharArray());
myKeyStore = keyStore;
KeyStore.PrivateKeyEntry entry = (KeyStore.PrivateKeyEntry) keyStore.getEntry(keyAlias, new KeyStore.PasswordProtection(keyPassword.toCharArray()));
if (entry == null) {
throw new CommitStepException(AndroidBundle.message("android.extract.package.cannot.find.key.error", keyAlias));
}
PrivateKey privateKey = entry.getPrivateKey();
Certificate certificate = entry.getCertificate();
if (privateKey == null || certificate == null) {
throw new CommitStepException(AndroidBundle.message("android.extract.package.cannot.find.key.error", keyAlias));
}
myPrivateKey = privateKey;
myCertificate = (X509Certificate) certificate;
} catch (Exception e) {
throw new CommitStepException("Error: " + e.getMessage());
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException ignored) {
}
}
}
}
use of com.intellij.ide.wizard.CommitStepException in project android by JetBrains.
the class ApkStep method _commit.
@Override
public void _commit(boolean finishChosen) throws CommitStepException {
final String apkPath = myApkPathField.getText().trim();
if (apkPath.length() == 0) {
throw new CommitStepException(AndroidBundle.message("android.extract.package.specify.apk.path.error"));
}
AndroidFacet facet = myWizard.getFacet();
PropertiesComponent properties = PropertiesComponent.getInstance(myWizard.getProject());
properties.setValue(ChooseModuleStep.MODULE_PROPERTY, facet != null ? facet.getModule().getName() : "");
properties.setValue(getApkPathPropertyName(), apkPath);
File folder = new File(apkPath).getParentFile();
if (folder == null) {
throw new CommitStepException(AndroidBundle.message("android.cannot.create.file.error", apkPath));
}
try {
if (!folder.exists()) {
folder.mkdirs();
}
} catch (Exception e) {
throw new CommitStepException(e.getMessage());
}
final CompileScope compileScope = CompilerManager.getInstance(myWizard.getProject()).createModuleCompileScope(facet.getModule(), true);
AndroidCompileUtil.setReleaseBuild(compileScope);
properties.setValue(RUN_PROGUARD_PROPERTY, Boolean.toString(myProguardCheckBox.isSelected()));
if (myProguardCheckBox.isSelected()) {
final List<String> proguardOsCfgPaths = myProGuardConfigFilesPanel.getOsPaths();
if (proguardOsCfgPaths.isEmpty()) {
throw new CommitStepException(AndroidBundle.message("android.extract.package.specify.proguard.cfg.path.error"));
}
final String proguardPathsStr = mergeProguardCfgPathsToOneString(proguardOsCfgPaths);
properties.setValue(PROGUARD_CFG_PATHS_PROPERTY, proguardPathsStr);
for (String path : proguardOsCfgPaths) {
if (!new File(path).isFile()) {
throw new CommitStepException("Cannot find file " + path);
}
}
compileScope.putUserData(AndroidCompileUtil.PROGUARD_CFG_PATHS_KEY, proguardPathsStr);
}
myWizard.setCompileScope(compileScope);
myWizard.setApkPath(apkPath);
}
use of com.intellij.ide.wizard.CommitStepException in project android by JetBrains.
the class ChooseModuleStep method commitForNext.
@Override
protected void commitForNext() throws CommitStepException {
if (myCheckModulePanel.hasError()) {
throw new CommitStepException(AndroidBundle.message("android.project.contains.errors.error"));
}
AndroidFacet selectedFacet = getSelectedFacet();
assert selectedFacet != null;
myWizard.setFacet(selectedFacet);
}
use of com.intellij.ide.wizard.CommitStepException in project android by JetBrains.
the class ModuleWizardStepAdapterTest method onWizardFinishedLogsExceptions.
@Test
public void onWizardFinishedLogsExceptions() throws CommitStepException {
Logger testLogger = mock(Logger.class);
ModuleWizardStepAdapter.setLog(testLogger);
ModuleWizardStepAdapter.AdapterModel model = new ModuleWizardStepAdapter.AdapterModel(myToWrap);
doThrow(new CommitStepException("Test Message")).when(myToWrap).onWizardFinished();
model.handleFinished();
verify(testLogger).error("Test Message");
ModuleWizardStepAdapter.setLog(null);
}
use of com.intellij.ide.wizard.CommitStepException in project intellij-community by JetBrains.
the class BeanStep method _commit.
public void _commit(boolean finishChosen) throws CommitStepException {
final boolean newBindToNewBean = myRbBindToNewBean.isSelected();
if (myData.myBindToNewBean != newBindToNewBean) {
resetBindings();
}
myData.myBindToNewBean = newBindToNewBean;
if (myData.myBindToNewBean) {
// new bean
final String oldShortClassName = myData.myShortClassName;
final String oldPackageName = myData.myPackageName;
final String shortClassName = myTfShortClassName.getText().trim();
if (shortClassName.length() == 0) {
throw new CommitStepException(UIDesignerBundle.message("error.please.specify.class.name.of.the.bean.to.be.created"));
}
final PsiManager psiManager = PsiManager.getInstance(myData.myProject);
if (!PsiNameHelper.getInstance(psiManager.getProject()).isIdentifier(shortClassName)) {
throw new CommitStepException(UIDesignerBundle.message("error.X.is.not.a.valid.class.name", shortClassName));
}
final String packageName = myTfWithBtnChoosePackage.getText().trim();
if (packageName.length() != 0 && JavaPsiFacade.getInstance(psiManager.getProject()).findPackage(packageName) == null) {
throw new CommitStepException(UIDesignerBundle.message("error.package.with.name.X.does.not.exist", packageName));
}
myData.myShortClassName = shortClassName;
myData.myPackageName = packageName;
// check whether new class already exists
{
final String fullClassName = packageName.length() != 0 ? packageName + "." + shortClassName : shortClassName;
final Module module = ModuleUtil.findModuleForFile(myData.myFormFile, myData.myProject);
if (JavaPsiFacade.getInstance(psiManager.getProject()).findClass(fullClassName, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module)) != null) {
throw new CommitStepException(UIDesignerBundle.message("error.cannot.create.class.X.because.it.already.exists", fullClassName));
}
}
if (!Comparing.equal(oldShortClassName, shortClassName) || !Comparing.equal(oldPackageName, packageName)) {
// After bean class changed we need to reset all previously set bindings
resetBindings();
}
} else {
// existing bean
final String oldFqClassName = myData.myBeanClass != null ? myData.myBeanClass.getQualifiedName() : null;
final String newFqClassName = myTfWitgBtnChooseClass.getText().trim();
if (newFqClassName.length() == 0) {
throw new CommitStepException(UIDesignerBundle.message("error.please.specify.fully.qualified.name.of.bean.class"));
}
final PsiClass aClass = JavaPsiFacade.getInstance(myData.myProject).findClass(newFqClassName, GlobalSearchScope.allScope(myData.myProject));
if (aClass == null) {
throw new CommitStepException(UIDesignerBundle.message("error.class.with.name.X.does.not.exist", newFqClassName));
}
myData.myBeanClass = aClass;
if (!Comparing.equal(oldFqClassName, newFqClassName)) {
// After bean class changed we need to reset all previously set bindings
resetBindings();
}
}
}
Aggregations