Search in sources :

Example 1 with ImportRepositoryContentAction

use of org.apache.sling.ide.eclipse.ui.internal.ImportRepositoryContentAction in project sling by apache.

the class ImportWizard method performFinish.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
	 */
public boolean performFinish() {
    if (!mainPage.isPageComplete()) {
        return false;
    }
    final IServer server = mainPage.getServer();
    IResource resource = mainPage.getResource();
    final IProject project = resource.getProject();
    final IPath projectRelativePath = resource.getProjectRelativePath();
    try {
        getContainer().run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                // following this change ( see org.apache.sling.ide.core.ResourceUtil )
                try {
                    ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {

                        @Override
                        public void run(IProgressMonitor monitor) throws CoreException {
                            try {
                                new ImportRepositoryContentAction(server, projectRelativePath, project, serializationManager).run(monitor);
                            } catch (SerializationException e) {
                                throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import failed", e));
                            } catch (InvocationTargetException e) {
                                throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import failed", e.getCause()));
                            } catch (InterruptedException e) {
                                Thread.currentThread().interrupt();
                            } finally {
                                serializationManager.destroy();
                            }
                        }
                    }, project, IWorkspace.AVOID_UPDATE, monitor);
                } catch (CoreException e) {
                    throw new InvocationTargetException(e);
                }
            }
        });
    } catch (InvocationTargetException e) {
        Throwable cause = e.getCause();
        mainPage.setErrorMessage("Import error : " + cause.getMessage() + " . Please see the error log for details.");
        Activator.getDefault().getPluginLogger().error("Repository import failed", cause);
        return false;
    } catch (OperationCanceledException | InterruptedException e) {
        Thread.currentThread().interrupt();
        return false;
    }
    return true;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) IServer(org.eclipse.wst.server.core.IServer) SerializationException(org.apache.sling.ide.serialization.SerializationException) IPath(org.eclipse.core.runtime.IPath) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IProject(org.eclipse.core.resources.IProject) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ImportRepositoryContentAction(org.apache.sling.ide.eclipse.ui.internal.ImportRepositoryContentAction) IResource(org.eclipse.core.resources.IResource)

Example 2 with ImportRepositoryContentAction

use of org.apache.sling.ide.eclipse.ui.internal.ImportRepositoryContentAction in project sling by apache.

the class ContentImportTest method runImport.

private void runImport(IProject contentProject) throws SerializationException, InvocationTargetException, InterruptedException, CoreException {
    ImportRepositoryContentAction action = new ImportRepositoryContentAction(wstServer.getServer(), Path.fromPortableString("/content/test-root"), contentProject, Activator.getDefault().getSerializationManager());
    action.run(new NullProgressMonitor());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ImportRepositoryContentAction(org.apache.sling.ide.eclipse.ui.internal.ImportRepositoryContentAction)

Aggregations

ImportRepositoryContentAction (org.apache.sling.ide.eclipse.ui.internal.ImportRepositoryContentAction)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 SerializationException (org.apache.sling.ide.serialization.SerializationException)1 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 Status (org.eclipse.core.runtime.Status)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 IServer (org.eclipse.wst.server.core.IServer)1