use of org.talend.core.model.general.ILibrariesService in project tdq-studio-se by Talend.
the class CorePlugin method initProxyRepository.
/**
* DOC zshen Comment method "initProxyRepository".
*/
public ReturnCode initProxyRepository() {
ReturnCode rc = new ReturnCode();
Project project = null;
RepositoryContext repositoryContext = (RepositoryContext) org.talend.core.runtime.CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
if (repositoryContext != null) {
project = repositoryContext.getProject();
User user = repositoryContext.getUser();
ReponsitoryContextBridge.initialized(project.getEmfProject(), user);
} else {
// else project is null, then we are in TOP only
Location instanceLoc = Platform.getInstanceLocation();
try {
if (instanceLoc.isLocked()) {
// $NON-NLS-1$
rc.setMessage(DefaultMessagesImpl.getString("CorePlugin.workspaceInUse"));
rc.setOk(false);
return rc;
} else {
instanceLoc.lock();
}
} catch (IOException e) {
log.error(e, e);
}
ProxyRepositoryFactory proxyRepository = ProxyRepositoryFactory.getInstance();
IRepositoryFactory repository = RepositoryFactoryProvider.getRepositoriyById(RepositoryConstants.REPOSITORY_LOCAL_ID);
if (repository == null) {
// $NON-NLS-1$
log.fatal(DefaultMessagesImpl.getString("CorePlugin.noLocalRepositoryFound"));
// $NON-NLS-1$
rc.setMessage(DefaultMessagesImpl.getString("CorePlugin.noLocalRepositoryFound"));
rc.setOk(false);
return rc;
}
proxyRepository.setRepositoryFactoryFromProvider(repository);
try {
proxyRepository.checkAvailability();
proxyRepository.initialize();
XmiResourceManager xmiResourceManager = proxyRepository.getRepositoryFactoryFromProvider().getResourceManager();
IProject rootProject = ResourceManager.getRootProject();
if (rootProject.getFile(FileConstants.LOCAL_PROJECT_FILENAME).exists()) {
// Initialize TDQ EMF model packages.
new EMFUtil();
project = new Project(xmiResourceManager.loadProject(rootProject));
} else {
// $NON-NLS-1$
String username = "talend@talend.com";
// $NON-NLS-1$
String password = "talend@talend.com";
User user = PropertiesFactoryImpl.eINSTANCE.createUser();
user.setLogin(username);
user.setPassword(password.getBytes());
String projectName = ResourceManager.getRootProjectName();
String projectDesc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName).getComment();
Project projectInfor = ProjectHelper.createProject(projectName, projectDesc, ECodeLanguage.JAVA.getName(), user);
// MOD zshen create project by proxyRepository
checkFileName(projectInfor.getLabel(), RepositoryConstants.PROJECT_PATTERN);
project = proxyRepository.getRepositoryFactoryFromProvider().createProject(user, password, projectInfor);
}
if (project != null) {
initRepositoryContext(project);
// add status
// $NON-NLS-1$
String defaultTechnicalStatusList = "DEV development;TEST testing;PROD production";
List<Status> statusList = StatusHelper.parse(defaultTechnicalStatusList);
proxyRepository.setTechnicalStatus(statusList);
// 'maven_user_settings.xml').before set, must check user setting first.
if (org.talend.commons.utils.platform.PluginChecker.isOnlyTopLoaded()) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMavenUIService.class)) {
IMavenUIService mavenUIService = (IMavenUIService) GlobalServiceRegister.getDefault().getService(IMavenUIService.class);
if (mavenUIService != null) {
mavenUIService.checkUserSettings(new NullProgressMonitor());
mavenUIService.updateMavenResolver(false);
mavenUIService.addMavenConfigurationChangeListener();
}
}
// deploy libraries and maven index here
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
ILibrariesService librariesService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
if (librariesService != null) {
librariesService.syncLibraries();
// TDQ-9529 check libararies install status at here,so that
// "Optional third-party libraries" is displayed in the "Additional Talend Package"
// dialog.
librariesService.checkLibraries();
}
}
}
CWMPlugin.getDefault().createLibFolderIfNotExist();
// TDQ-11348 the readOnlyUser property is false for TOP.
// $NON-NLS-1$
System.getProperties().put("ReadOnlyUser", new Boolean(false).toString());
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
rc.setMessage(e.getMessage());
rc.setOk(false);
return rc;
}
}
return rc;
}
use of org.talend.core.model.general.ILibrariesService in project tbd-studio-se by Talend.
the class DistributionVersionModule method getModulesNeeded.
public List<ModuleNeeded> getModulesNeeded() {
if (modulesNeeded.isEmpty()) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
ILibrariesService libService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
modulesNeeded.addAll(libService.getModuleNeeded(moduleGroup.getModuleName(), true));
}
}
return modulesNeeded;
}
use of org.talend.core.model.general.ILibrariesService in project tbd-studio-se by Talend.
the class AbstractDynamicDistributionTemplate method unregistPluginExtensions.
@Override
public boolean unregistPluginExtensions(boolean reloadLibCache) {
if (registedPluginAdapter != null) {
synchronized (registedPluginAdapterLock) {
if (registedPluginAdapter != null) {
try {
DynamicServiceUtil.removeContribution(registedPluginAdapter.getPlugin());
registedPluginAdapter = null;
if (reloadLibCache) {
ILibrariesService libService = ILibrariesService.get();
if (libService != null) {
libService.resetModulesNeeded();
}
}
HadoopDistributionsHelper.updatePluginExtensionCacheVersion();
return true;
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
}
return false;
}
use of org.talend.core.model.general.ILibrariesService in project tbd-studio-se by Talend.
the class HadoopConfsUtils method buildAndDeployConfsJar.
public static void buildAndDeployConfsJar(HadoopClusterConnectionItem connectionItem, String contextGroup, String dir, String jarName) {
try {
File parentFile = new File(getConfsJarTempFolder());
File jarFile = new File(parentFile, jarName);
File rootDir = new File(dir);
JarBuilder jarBuilder = new JarBuilder(rootDir, jarFile);
jarBuilder.setIncludeDir(null);
jarBuilder.setExcludeDir(null);
jarBuilder.buildJar();
byte[] confFileByteArray = FileUtils.readFileToByteArray(jarFile);
HadoopClusterConnection connection = (HadoopClusterConnection) connectionItem.getConnection();
if (connection.isContextMode()) {
if (contextGroup == null) {
// $NON-NLS-1$
throw new Exception("contextGroup cannot be null in context mode!");
}
connection.getConfFiles().put(contextGroup, confFileByteArray);
} else {
connection.setConfFile(confFileByteArray);
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
ILibrariesService service = GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
if (service != null) {
// Only deploy a new jar, no need to reset all
service.deployLibrary(jarFile.toURI().toURL());
addToDeployedCache(connectionItem, jarName);
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
use of org.talend.core.model.general.ILibrariesService in project tbd-studio-se by Talend.
the class HadoopConfsUtils method createAndDeployConfJar.
private static void createAndDeployConfJar(HadoopClusterConnectionItem connectionItem, String confJarId, String confJarName) throws IOException {
// If the conf jar has been deployed before then no need to deploy again.
if (containsInDeployedCache(connectionItem, confJarName)) {
return;
}
byte[] confFileBA = null;
HadoopClusterConnection connection = (HadoopClusterConnection) connectionItem.getConnection();
if (connection.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(connection.getContextId());
if (contextItem != null) {
EMap<String, byte[]> confFiles = connection.getConfFiles();
EList<ContextType> contexts = contextItem.getContext();
for (ContextType contextType : contexts) {
String contextName = contextType.getName();
byte[] bs = confFiles.get(contextName);
if (confJarId.endsWith(contextName) && bs != null) {
confFileBA = bs;
break;
}
}
}
if (confFileBA == null) {
// either conf jar name is wrong or it is a old item.
// then take the old hadoop conf file content.
confFileBA = connection.getConfFile();
}
} else {
confFileBA = connection.getConfFile();
}
if (confFileBA != null) {
File confsTempFolder = new File(getConfsJarTempFolder());
File confFile = new File(confsTempFolder, confJarName);
FileUtils.writeByteArrayToFile(confFile, confFileBA);
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
ILibraryManagerService libService = GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
if (libService != null && libService.isJarNeedToBeDeployed(confFile)) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
ILibrariesService service = GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
if (service != null) {
// Only deploy a new jar, no need to reset all
service.deployLibrary(confFile.toURI().toURL());
addToDeployedCache(connectionItem, confJarName);
}
}
}
}
}
}
Aggregations