Search in sources :

Example 91 with InvocationTargetException

use of java.lang.reflect.InvocationTargetException in project OpenAM by OpenRock.

the class EntitiesModelImpl method setAgentDefaultValues.

private void setAgentDefaultValues(Map values) throws AMConsoleException {
    Set setAgentType = (Set) values.get(RADIO_AGENT_TYPE);
    if ((setAgentType != null) && !setAgentType.isEmpty()) {
        String agentType = (String) setAgentType.iterator().next();
        if (agentType.equals(RADIO_AGENT_TYPE_WSC)) {
            Set agentValues = new HashSet(6);
            agentValues.add("SecurityMech=urn:sun:wss:security:null:Anonymous");
            agentValues.add("useDefaultStore=true");
            agentValues.add("Type=wsc");
            values.put(AGENT_ATTRIBUTE_LIST, agentValues);
        } else if (agentType.equals(RADIO_AGENT_TYPE_WSP)) {
            try {
                Class clazz = Class.forName("com.sun.identity.wss.security.SecurityMechanism");
                Method mtd = clazz.getDeclaredMethod("getAllWSPSecurityMechanisms", (Class) null);
                Method mtdGetURI = clazz.getDeclaredMethod("getURI", (Class) null);
                List securityMech = (List) mtd.invoke(null, (Class) null);
                StringBuffer securityMechStr = new StringBuffer();
                boolean first = true;
                for (Iterator i = securityMech.iterator(); i.hasNext(); ) {
                    Object mech = i.next();
                    if (first) {
                        first = false;
                    } else {
                        securityMechStr.append(",");
                    }
                    securityMechStr.append((String) mtdGetURI.invoke(mech, (Class) null));
                }
                Set agentValues = new HashSet(6);
                agentValues.add("SecurityMech=" + securityMechStr);
                agentValues.add("useDefaultStore=true");
                agentValues.add("Type=wsp");
                values.put(AGENT_ATTRIBUTE_LIST, agentValues);
            } catch (ClassNotFoundException e) {
                throw new AMConsoleException(e);
            } catch (NoSuchMethodException e) {
                throw new AMConsoleException(e);
            } catch (IllegalAccessException e) {
                throw new AMConsoleException(e);
            } catch (InvocationTargetException e) {
                throw new AMConsoleException(e);
            }
        }
        values.remove(RADIO_AGENT_TYPE);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) Iterator(java.util.Iterator) List(java.util.List) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashSet(java.util.HashSet)

Example 92 with InvocationTargetException

use of java.lang.reflect.InvocationTargetException in project OpenAM by OpenRock.

the class CookieUtils method addCookieToResponse.

/**
     * Add cookie to HttpServletResponse as custom header
     * 
     * @param response
     * @param cookie 
     */
public static void addCookieToResponse(HttpServletResponse response, Cookie cookie) {
    if (cookie == null) {
        return;
    }
    if (!isCookieHttpOnly()) {
        response.addCookie(cookie);
        return;
    }
    if (setHttpOnlyMethod != null) {
        try {
            setHttpOnlyMethod.invoke(cookie, true);
            response.addCookie(cookie);
            return;
        } catch (IllegalAccessException iae) {
            debug.warning("IllegalAccessException while trying to add HttpOnly cookie: " + iae.getMessage());
        } catch (InvocationTargetException ite) {
            debug.error("An error occurred while trying to add HttpOnly cookie", ite);
        }
    }
    StringBuilder sb = new StringBuilder(150);
    sb.append(cookie.getName()).append("=").append(cookie.getValue());
    String path = cookie.getPath();
    if (path != null && path.length() > 0) {
        sb.append(";path=").append(path);
    } else {
        sb.append(";path=/");
    }
    String domain = cookie.getDomain();
    if (domain != null && domain.length() > 0) {
        sb.append(";domain=").append(domain);
    }
    int age = cookie.getMaxAge();
    if (age > -1) {
        Date date = new Date(System.currentTimeMillis() + age * 1000l);
        SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss zzz", Locale.UK);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        sb.append(";max-age=").append(age);
        // set Expires as < IE 8 does not support max-age
        sb.append(";Expires=").append(sdf.format(date));
    }
    if (CookieUtils.isCookieSecure() || cookie.getSecure()) {
        sb.append(";secure");
    }
    sb.append(";httponly");
    if (debug.messageEnabled()) {
        debug.message("CookieUtils:addCookieToResponse adds " + sb);
    }
    response.addHeader("Set-Cookie", sb.toString());
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) InvocationTargetException(java.lang.reflect.InvocationTargetException) Date(java.util.Date)

Example 93 with InvocationTargetException

use of java.lang.reflect.InvocationTargetException in project tdi-studio-se by Talend.

the class MultiSchemasUI method fetchCodes.

@SuppressWarnings("restriction")
private void fetchCodes() {
    try {
        final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
        dialog.run(true, false, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Fetch...", IProgressMonitor.UNKNOWN);
                monitor.setCanceled(false);
                final CsvArray csvArray = processor.getCsvArray();
                Display.getDefault().syncExec(new Runnable() {

                    public void run() {
                        SchemasKeyData schemasModel = null;
                        boolean checked = (csvArray != null && csvArray.getRows().size() > 0);
                        CSVArrayAndSeparator uniqueCsvArray = null;
                        if (useMultiSaparators.getSelection()) {
                            getMultiSchemaManager().setKeyValues(keyValuesText.getText());
                        }
                        if (multiSchemasFilePreview.getSelectColumnIndex() < 0 && multiSchemaManager.getSelectedColumnIndex() != 0) {
                            uniqueCsvArray = getMultiSchemaManager().retrieveCsvArrayInUniqueModel(getProcessDescription(), checked, multiSchemaManager.getSelectedColumnIndex(), useMultiSaparators.getSelection());
                            schemasModel = getMultiSchemaManager().createSchemasTree(uniqueCsvArray, multiSchemaManager.getSelectedColumnIndex());
                        } else {
                            uniqueCsvArray = getMultiSchemaManager().retrieveCsvArrayInUniqueModel(getProcessDescription(), checked, multiSchemasFilePreview.getSelectColumnIndex(), useMultiSaparators.getSelection());
                            schemasModel = getMultiSchemaManager().createSchemasTree(uniqueCsvArray, multiSchemasFilePreview.getSelectColumnIndex());
                            getMultiSchemaManager().setSelectedColumnIndex(multiSchemasFilePreview.getSelectColumnIndex());
                            schemaTreeViewer.setInput(schemasModel);
                            getUIManager().packSchemaTreeFirstColumn(schemaTreeViewer);
                            clearSchemaDetail();
                            checkDialog();
                        }
                    }
                });
                monitor.done();
            }
        });
    } catch (InvocationTargetException e) {
        ExceptionHandler.process(e);
    } catch (InterruptedException e) {
        ExceptionHandler.process(e);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CsvArray(org.talend.core.utils.CsvArray) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) CSVArrayAndSeparator(org.talend.designer.filemultischemas.data.CSVArrayAndSeparator) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 94 with InvocationTargetException

use of java.lang.reflect.InvocationTargetException in project tdi-studio-se by Talend.

the class ImportItemUtil method importItemRecord.

private void importItemRecord(ResourcesManager manager, ItemRecord itemRecord, boolean overwrite, IPath destinationPath, final Set<String> overwriteDeletedItems, final Set<String> idDeletedBeforeImport, String contentType, final IProgressMonitor monitor) {
    //$NON-NLS-1$
    monitor.subTask(Messages.getString("ImportItemWizardPage.Importing") + itemRecord.getItemName());
    resolveItem(manager, itemRecord);
    if (!itemRecord.isValid()) {
        return;
    }
    int num = 0;
    for (Object obj : itemRecord.getResourceSet().getResources()) {
        if (!(obj instanceof PropertiesProjectResourceImpl)) {
            if (obj instanceof XMIResourceImpl) {
                num++;
                if (num > 2) {
                    // 2 so that metadata migration for 4.1 works
                    try {
                        throw new InvocationTargetException(new PersistenceException("The source file of " + itemRecord.getLabel() + " has error,Please check it!"));
                    } catch (InvocationTargetException e) {
                        ExceptionHandler.process(e);
                    }
                    return;
                }
            }
        }
    }
    final Item item = itemRecord.getItem();
    if (item != null) {
        ProxyRepositoryFactory repFactory = ProxyRepositoryFactory.getInstance();
        ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
        IPath path = new Path(item.getState().getPath());
        if (destinationPath != null && itemType.name().equals(contentType)) {
            path = destinationPath.append(path);
        }
        try {
            FolderItem folderItem = repFactory.getFolderItem(ProjectManager.getInstance().getCurrentProject(), itemType, path);
            if (folderItem == null) {
                // if this folder does not exists (and it's parents), it will check if the folder was originally
                // deleted in source project.
                // if yes, it will set back the delete status to the folder, to keep the same as the original
                // project when import.
                // Without this code, deleted folders of items imported will not be in the recycle bin after import.
                // delete status is set finally in the function checkDeletedFolders
                IPath curPath = path;
                EList deletedFoldersFromOriginalProject = itemRecord.getItemProject().getDeletedFolders();
                while (folderItem == null && !curPath.isEmpty() && !curPath.isRoot()) {
                    if (deletedFoldersFromOriginalProject.contains(new Path(itemType.getFolder()).append(curPath.toPortableString()).toPortableString())) {
                        if (!foldersCreated.containsKey(itemType)) {
                            foldersCreated.put(itemType, new HashSet<String>());
                        }
                        foldersCreated.get(itemType).add(curPath.toPortableString());
                    }
                    if (curPath.segments().length > 0) {
                        curPath = curPath.removeLastSegments(1);
                        folderItem = repFactory.getFolderItem(ProjectManager.getInstance().getCurrentProject(), itemType, curPath);
                    }
                }
            }
            repFactory.createParentFoldersRecursively(ProjectManager.getInstance().getCurrentProject(), itemType, path, true);
        } catch (Exception e) {
            logError(e);
            //$NON-NLS-1$
            path = new Path("");
        }
        try {
            Item tmpItem = item;
            // delete existing items before importing, this should be done
            // once for a different id
            String id = itemRecord.getProperty().getId();
            IRepositoryViewObject lastVersion = itemRecord.getExistingItemWithSameId();
            if (lastVersion != null && overwrite && !itemRecord.isLocked() && (itemRecord.getState() == State.ID_EXISTED || itemRecord.getState() == State.NAME_EXISTED || itemRecord.getState() == State.NAME_AND_ID_EXISTED) && !deletedItems.contains(id)) {
                if (!overwriteDeletedItems.contains(id)) {
                    // bug 10520.
                    ERepositoryStatus status = repFactory.getStatus(lastVersion);
                    if (status == ERepositoryStatus.DELETED) {
                        // restore first.
                        repFactory.restoreObject(lastVersion, path);
                    }
                    overwriteDeletedItems.add(id);
                }
                /* only delete when name exsit rather than id exist */
                if (itemRecord.getState().equals(ItemRecord.State.NAME_EXISTED) || itemRecord.getState().equals(ItemRecord.State.NAME_AND_ID_EXISTED)) {
                    if (!idDeletedBeforeImport.contains(id)) {
                        // TDI-19535 (check if exists, delete all items with same id)
                        List<IRepositoryViewObject> allVersionToDelete = repFactory.getAllVersion(ProjectManager.getInstance().getCurrentProject(), lastVersion.getId(), false);
                        String importingLabel = itemRecord.getProperty().getLabel();
                        String existLabel = lastVersion.getProperty().getLabel();
                        for (IRepositoryViewObject currentVersion : allVersionToDelete) {
                            repFactory.forceDeleteObjectPhysical(lastVersion, currentVersion.getVersion(), isNeedDeleteOnRemote(importingLabel, existLabel));
                        }
                        idDeletedBeforeImport.add(id);
                    }
                }
                lastVersion = null;
            // List<IRepositoryObject> list = cache.findObjectsByItem(itemRecord);
            // if (!list.isEmpty()) {
            // // this code will delete all version of item with same
            // // id
            // repFactory.forceDeleteObjectPhysical(list.get(0));
            // deletedItems.add(id);
            // }
            }
            User author = itemRecord.getProperty().getAuthor();
            if (author != null) {
                if (!repFactory.setAuthorByLogin(tmpItem, author.getLogin())) {
                    // author will be
                    tmpItem.getProperty().setAuthor(null);
                // the logged
                // user in
                // create method
                }
            }
            if (item instanceof JobletProcessItem) {
                hasJoblets = true;
            }
            if (tmpItem instanceof ProcessItem && !statAndLogsSettingsReloaded && !implicitSettingsReloaded) {
                ProcessItem processItem = (ProcessItem) tmpItem;
                ParametersType paType = processItem.getProcess().getParameters();
                boolean statsPSettingRemoved = false;
                // for commanline import project setting
                if (itemRecord.isRemoveProjectStatslog()) {
                    if (paType != null) {
                        String paramName = "STATANDLOG_USE_PROJECT_SETTINGS";
                        EList listParamType = paType.getElementParameter();
                        for (int j = 0; j < listParamType.size(); j++) {
                            ElementParameterType pType = (ElementParameterType) listParamType.get(j);
                            if (pType != null && paramName.equals(pType.getName())) {
                                pType.setValue(Boolean.FALSE.toString());
                                statsPSettingRemoved = true;
                                break;
                            }
                        }
                    }
                }
                // 14446: item apply project setting param if use project setting
                String statslogUsePSetting = null;
                String implicitUsePSetting = null;
                if (paType != null) {
                    EList listParamType = paType.getElementParameter();
                    for (int j = 0; j < listParamType.size(); j++) {
                        ElementParameterType pType = (ElementParameterType) listParamType.get(j);
                        if (pType != null) {
                            if (!statsPSettingRemoved && "STATANDLOG_USE_PROJECT_SETTINGS".equals(pType.getName())) {
                                statslogUsePSetting = pType.getValue();
                            }
                            if ("IMPLICITCONTEXT_USE_PROJECT_SETTINGS".equals(pType.getName())) {
                                implicitUsePSetting = pType.getValue();
                            }
                            if (statsPSettingRemoved && implicitUsePSetting != null || !statsPSettingRemoved && implicitUsePSetting != null && statslogUsePSetting != null) {
                                break;
                            }
                        }
                    }
                }
                if (statslogUsePSetting != null && Boolean.parseBoolean(statslogUsePSetting) && !statAndLogsSettingsReloaded) {
                    CorePlugin.getDefault().getDesignerCoreService().reloadParamFromProjectSettings(paType, "STATANDLOG_USE_PROJECT_SETTINGS");
                    statAndLogsSettingsReloaded = true;
                }
                if (implicitUsePSetting != null && Boolean.parseBoolean(implicitUsePSetting) && !implicitSettingsReloaded) {
                    CorePlugin.getDefault().getDesignerCoreService().reloadParamFromProjectSettings(paType, "IMPLICITCONTEXT_USE_PROJECT_SETTINGS");
                    implicitSettingsReloaded = true;
                }
            }
            if (lastVersion == null || itemRecord.getState().equals(ItemRecord.State.ID_EXISTED)) {
                // import has not been developed to cope with migration in mind
                // so some model may not be able to load like the ConnectionItems
                // in that case items needs to be copied before migration
                // here we check that the loading of the item failed before calling the create method
                boolean isConnectionEmptyBeforeMigration = tmpItem instanceof ConnectionItem && ((ConnectionItem) tmpItem).getConnection().eResource() == null && !itemRecord.getMigrationTasksToApply().isEmpty();
                repFactory.create(tmpItem, path, true);
                if (isConnectionEmptyBeforeMigration) {
                    // copy the file before migration, this is bad because it
                    // should not refer to Filesytem
                    // but this is a quick hack and anyway the migration task only works on files
                    // IPath itemPath = itemRecord.getPath().removeFileExtension().addFileExtension(
                    // FileConstants.ITEM_EXTENSION);
                    InputStream is = manager.getStream(itemRecord.getPath().removeFileExtension().addFileExtension(FileConstants.ITEM_EXTENSION));
                    try {
                        URI propertyResourceURI = EcoreUtil.getURI(((ConnectionItem) tmpItem).getProperty());
                        URI relativePlateformDestUri = propertyResourceURI.trimFileExtension().appendFileExtension(FileConstants.ITEM_EXTENSION);
                        URL fileURL = FileLocator.toFileURL(new java.net.URL(//$NON-NLS-1$
                        "platform:/resource" + relativePlateformDestUri.toPlatformString(true)));
                        OutputStream os = new FileOutputStream(fileURL.getFile());
                        try {
                            FileCopyUtils.copyStreams(is, os);
                        } finally {
                            os.close();
                        }
                    } finally {
                        is.close();
                    }
                    repFactory.unloadResources(tmpItem.getProperty());
                } else {
                    // connections from migrations (from 4.0.x or previous version) doesn't support reference or
                    // screenshots
                    // so no need to call this code.
                    // It's needed to avoid to call the save method mainly just before or after the copy of the old
                    // connection since it will
                    copyScreenshotFile(manager, itemRecord);
                    boolean haveRef = copyReferenceFiles(manager, tmpItem, itemRecord.getPath());
                    if (haveRef) {
                        repFactory.save(tmpItem, true);
                    }
                }
                itemRecord.setImportPath(path.toPortableString());
                itemRecord.setRepositoryType(itemType);
                itemRecord.setItemId(itemRecord.getProperty().getId());
                itemRecord.setItemVersion(itemRecord.getProperty().getVersion());
                itemRecord.setImported(true);
                cache.addToCache(tmpItem);
            } else if (VersionUtils.compareTo(lastVersion.getProperty().getVersion(), tmpItem.getProperty().getVersion()) < 0) {
                repFactory.forceCreate(tmpItem, path);
                itemRecord.setImportPath(path.toPortableString());
                itemRecord.setItemId(itemRecord.getProperty().getId());
                itemRecord.setRepositoryType(itemType);
                itemRecord.setItemVersion(itemRecord.getProperty().getVersion());
                itemRecord.setImported(true);
                cache.addToCache(tmpItem);
            } else {
                PersistenceException e = new PersistenceException(Messages.getString("ImportItemUtil.persistenceException", //$NON-NLS-1$
                tmpItem.getProperty()));
                itemRecord.addError(e.getMessage());
                logError(e);
            }
            if (tmpItem != null) {
                // RelationshipItemBuilder.getInstance().addOrUpdateItem(tmpItem, true);
                if (tmpItem.getState() != null) {
                    if (itemType != null) {
                        final Set<String> folders = restoreFolder.getFolders(itemType);
                        if (folders != null) {
                            for (String folderPath : folders) {
                                if (folderPath != null && folderPath.equals(path.toString())) {
                                    FolderItem folderItem = repFactory.getFolderItem(ProjectManager.getInstance().getCurrentProject(), itemType, path);
                                    if (folderItem != null) {
                                        folderItem.getState().setDeleted(false);
                                        while (!(folderItem.getParent() instanceof Project)) {
                                            folderItem = (FolderItem) folderItem.getParent();
                                            if (folderItem.getType() == FolderType.SYSTEM_FOLDER_LITERAL) {
                                                break;
                                            }
                                            folderItem.getState().setDeleted(false);
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            itemRecord.addError(e.getMessage());
            logError(e);
        }
    }
    String label = itemRecord.getLabel();
    EList<Resource> resources = itemRecord.getResourceSet().getResources();
    Iterator<Resource> iterator = resources.iterator();
    while (iterator.hasNext()) {
        Resource res = iterator.next();
        // it can't be unloaded just after create the item.
        if (res != null && !(res instanceof ByteArrayResource)) {
            res.unload();
            iterator.remove();
        }
    }
    TimeMeasure.step("importItemRecords", "Import item: " + label);
    applyMigrationTasks(itemRecord, monitor);
    TimeMeasure.step("importItemRecords", "applyMigrationTasks: " + label);
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) User(org.talend.core.model.properties.User) ConnectionItem(org.talend.core.model.properties.ConnectionItem) URL(java.net.URL) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) FileOutputStream(java.io.FileOutputStream) OutputStream(java.io.OutputStream) URI(org.eclipse.emf.common.util.URI) PropertiesProjectResourceImpl(org.talend.core.repository.model.PropertiesProjectResourceImpl) URL(java.net.URL) ReferenceFileItem(org.talend.core.model.properties.ReferenceFileItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ContextItem(org.talend.core.model.properties.ContextItem) SnippetItem(org.talend.core.model.properties.SnippetItem) Item(org.talend.core.model.properties.Item) LinkDocumentationItem(org.talend.core.model.properties.LinkDocumentationItem) FolderItem(org.talend.core.model.properties.FolderItem) RoutineItem(org.talend.core.model.properties.RoutineItem) TDQItem(org.talend.core.model.properties.TDQItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) FileItem(org.talend.core.model.properties.FileItem) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IPath(org.eclipse.core.runtime.IPath) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) CwmResource(org.talend.model.emf.CwmResource) TalendXMIResource(org.talend.commons.runtime.model.emf.TalendXMIResource) ByteArrayResource(org.talend.core.model.properties.helper.ByteArrayResource) Resource(org.eclipse.emf.ecore.resource.Resource) ByteArrayResource(org.talend.core.model.properties.helper.ByteArrayResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) MalformedURLException(java.net.MalformedURLException) PersistenceException(org.talend.commons.exception.PersistenceException) ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) Project(org.talend.core.model.properties.Project) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) FolderItem(org.talend.core.model.properties.FolderItem) EList(org.eclipse.emf.common.util.EList) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) FileOutputStream(java.io.FileOutputStream) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) EObject(org.eclipse.emf.ecore.EObject) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType) XMIResourceImpl(org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl)

Example 95 with InvocationTargetException

use of java.lang.reflect.InvocationTargetException in project tdi-studio-se by Talend.

the class ImportItemWizardPage method updateItemsList.

public void updateItemsList(final String path, boolean isneedUpdate) {
    if (!isneedUpdate) {
        if (path.equals(lastPath)) {
            return;
        }
    }
    lastPath = path;
    if (path == null || path.length() == 0) {
        selectedItems = new ArrayList<ItemRecord>();
        checkTreeViewer.refresh(true);
        // get the top item to check if tree is empty, if not then uncheck everything
        TreeItem topItem = checkTreeViewer.getTree().getTopItem();
        if (topItem != null) {
            checkTreeViewer.setSubtreeChecked(topItem.getData(), false);
        }
        // else not root element, tree is already empty
        checkValidItems();
        return;
    }
    final boolean dirSelected = this.itemFromDirectoryRadio.getSelection();
    try {
        getContainer().run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) {
                // monitor.beginTask(DataTransferMessages.WizardProjectsImportPage_SearchingMessage, 100);
                //$NON-NLS-1$
                monitor.beginTask(Messages.getString("DataTransferMessages.WizardProjectsImportPage_SearchingMessage"), 100);
                File directory = new File(path);
                monitor.worked(10);
                if (!dirSelected && ArchiveFileManipulations.isTarFile(path)) {
                    sourceTarFile = getSpecifiedTarSourceFile(path);
                    if (sourceTarFile == null) {
                        return;
                    }
                    TarLeveledStructureProvider provider = new TarLeveledStructureProvider(sourceTarFile);
                    manager = ResourcesManagerFactory.getInstance().createResourcesManager(provider);
                    if (!manager.collectPath2Object(provider.getRoot())) {
                        return;
                    }
                } else if (!dirSelected && ArchiveFileManipulations.isZipFile(path)) {
                    sourceFile = getSpecifiedZipSourceFile(path);
                    if (sourceFile == null) {
                        return;
                    }
                    ZipLeveledStructureProvider provider = new ZipLeveledStructureProvider(sourceFile);
                    manager = ResourcesManagerFactory.getInstance().createResourcesManager(provider);
                    if (!manager.collectPath2Object(provider.getRoot())) {
                        return;
                    }
                } else if (dirSelected && directory.isDirectory()) {
                    manager = ResourcesManagerFactory.getInstance().createResourcesManager();
                    if (!manager.collectPath2Object(directory)) {
                        return;
                    }
                } else {
                    monitor.worked(60);
                }
                monitor.done();
            }
        });
    } catch (InvocationTargetException e) {
        IDEWorkbenchPlugin.log(e.getMessage(), e);
    } catch (InterruptedException e) {
    // Nothing to do if the user interrupts.
    }
    populateItems();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TarLeveledStructureProvider(org.eclipse.ui.internal.wizards.datatransfer.TarLeveledStructureProvider) TreeItem(org.eclipse.swt.widgets.TreeItem) ZipLeveledStructureProvider(org.eclipse.ui.internal.wizards.datatransfer.ZipLeveledStructureProvider) ZipFile(java.util.zip.ZipFile) TarFile(org.eclipse.ui.internal.wizards.datatransfer.TarFile) File(java.io.File) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)4781 Method (java.lang.reflect.Method)2031 IOException (java.io.IOException)550 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)492 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)407 ArrayList (java.util.ArrayList)402 List (java.util.List)248 CoreException (org.eclipse.core.runtime.CoreException)247 File (java.io.File)238 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)236 Constructor (java.lang.reflect.Constructor)233 Field (java.lang.reflect.Field)220 Test (org.junit.Test)209 Map (java.util.Map)205 HashMap (java.util.HashMap)202 DBException (org.jkiss.dbeaver.DBException)169 IStatus (org.eclipse.core.runtime.IStatus)136 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)97 Arrays (java.util.Arrays)96 Status (org.eclipse.core.runtime.Status)94