Search in sources :

Example 1 with RepositoryObjectAccessException

use of org.pentaho.di.repository.pur.RepositoryObjectAccessException in project pentaho-kettle by pentaho.

the class TrashBrowseController method renameRepositoryObject.

@Override
protected void renameRepositoryObject(final UIRepositoryObject repoObject) throws XulException {
    // final Document doc = document;
    XulPromptBox prompt = promptForName(repoObject);
    prompt.addDialogCallback(new XulDialogCallback<String>() {

        public void onClose(XulComponent component, Status status, String value) {
            if (status == Status.ACCEPT) {
                final String newName = value;
                try {
                    repoObject.setName(newName);
                } catch (KettleException ke) {
                    if (ke.getCause() instanceof RepositoryObjectAccessException) {
                        moveDeletePrompt(ke, repoObject, new XulDialogCallback<Object>() {

                            public void onClose(XulComponent sender, Status returnCode, Object retVal) {
                                if (returnCode == Status.ACCEPT) {
                                    try {
                                        ((UIEERepositoryDirectory) repoObject).setName(newName, true);
                                    } catch (Exception e) {
                                        if (mainController == null || !mainController.handleLostRepository(e)) {
                                            displayExceptionMessage(BaseMessages.getString(PKG, e.getLocalizedMessage()));
                                        }
                                    }
                                }
                            }

                            public void onError(XulComponent sender, Throwable t) {
                                if (mainController == null || !mainController.handleLostRepository(t)) {
                                    throw new RuntimeException(t);
                                }
                            }
                        });
                    } else {
                        if (mainController == null || !mainController.handleLostRepository(ke)) {
                            throw new RuntimeException(ke);
                        }
                    }
                } catch (Exception e) {
                    if (mainController == null || !mainController.handleLostRepository(e)) {
                        // convert to runtime exception so it bubbles up through the UI
                        throw new RuntimeException(e);
                    }
                }
            }
        }

        public void onError(XulComponent component, Throwable err) {
            if (mainController == null || !mainController.handleLostRepository(err)) {
                throw new RuntimeException(err);
            }
        }
    });
    prompt.open();
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObjectAccessException(org.pentaho.di.repository.pur.RepositoryObjectAccessException) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) IDeletedObject(org.pentaho.di.ui.repository.pur.services.ITrashService.IDeletedObject) XulComponent(org.pentaho.ui.xul.XulComponent) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObjectAccessException(org.pentaho.di.repository.pur.RepositoryObjectAccessException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)

Aggregations

KettleException (org.pentaho.di.core.exception.KettleException)1 RepositoryObjectAccessException (org.pentaho.di.repository.pur.RepositoryObjectAccessException)1 IDeletedObject (org.pentaho.di.ui.repository.pur.services.ITrashService.IDeletedObject)1 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)1 UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)1 XulComponent (org.pentaho.ui.xul.XulComponent)1 XulException (org.pentaho.ui.xul.XulException)1 XulPromptBox (org.pentaho.ui.xul.components.XulPromptBox)1