Compare commits

...

1 Commits

Author SHA1 Message Date
hwang
ccb4cb97d2 TDI-36720:"Edit Routine Libraries" can't import the external jar 2016-06-28 16:55:32 +08:00
3 changed files with 32 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
// ============================================================================
package org.talend.core.model.general;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.List;
@@ -59,6 +60,8 @@ public interface ILibrariesService extends IService {
public void deployLibrary(URL source) throws IOException;
public void deployLibrarys(URL[] source) throws IOException;
public void deployProjectLibrary(File source) throws IOException;
public void undeployLibrary(String jarName) throws IOException;

View File

@@ -22,11 +22,15 @@ import java.util.Set;
import org.apache.log4j.Logger;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.talend.commons.exception.BusinessException;
import org.talend.commons.exception.CommonExceptionHandler;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.utils.generation.JavaUtils;
import org.talend.commons.utils.io.FilesUtils;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.ILibraryManagerService;
@@ -129,6 +133,25 @@ public abstract class AbstractLibrariesService implements ILibrariesService {
Context ctx = CoreRuntimePlugin.getInstance().getContext();
return (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
}
@Override
public void deployProjectLibrary(File source) throws IOException{
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
ILibraryManagerService librairesService = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(
ILibraryManagerService.class);
if (librairesService != null) {
File sourceFile = new File(librairesService.getJarPath(source.getName()));
if(sourceFile.exists()){
IPath path = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(JavaUtils.JAVA_EXTENSION).append(JavaUtils.JAVA_LIB_DIRECTORY).append(source.getName());
File targetFile = path.toFile();
if(targetFile.exists()){
return;
}
FilesUtils.copyFile(sourceFile, targetFile);
}
}
}
}
private void resetAndRefreshLocal(final String names[]) {
resetModulesNeeded();

View File

@@ -12,6 +12,7 @@
// ============================================================================
package org.talend.librariesmanager.model.service;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.List;
@@ -227,4 +228,9 @@ public class LibrariesService implements ILibrariesService {
public Set<ModuleNeeded> getCodesModuleNeededs(ERepositoryObjectType type) {
return getLibrariesService().getCodesModuleNeededs(type);
}
@Override
public void deployProjectLibrary(File source) throws IOException{
this.getLibrariesService().deployProjectLibrary(source);
}
}