Search in sources :

Example 1 with ServiceContainer

use of com.liferay.ide.project.core.modules.ServiceContainer in project liferay-ide by liferay.

the class TargetPlatformUtil method getThirdPartyBundleList.

@SuppressWarnings("unchecked")
public static ServiceContainer getThirdPartyBundleList(String serviceName) throws Exception {
    Bundle bundle = ProjectCore.getDefault().getBundle();
    URL url = FileLocator.toFileURL(bundle.getEntry("OSGI-INF/liferay-thirdparty-bundles.json"));
    File tpFile = new File(url.getFile());
    ObjectMapper mapper = new ObjectMapper();
    Map<String, List<String>> map = mapper.readValue(tpFile, Map.class);
    List<String> serviceBundle = map.get(serviceName);
    if (ListUtil.isNotEmpty(serviceBundle)) {
        return new ServiceContainer(serviceBundle.get(0), serviceBundle.get(1), serviceBundle.get(2));
    }
    return null;
}
Also used : ServiceContainer(com.liferay.ide.project.core.modules.ServiceContainer) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) URL(java.net.URL) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 2 with ServiceContainer

use of com.liferay.ide.project.core.modules.ServiceContainer in project liferay-ide by liferay.

the class TargetPlatformUtil method _getBundleAndVersion.

@SuppressWarnings("unchecked")
private static ServiceContainer _getBundleAndVersion(File tpFile, String serviceName) throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    Map<String, List<String>> map = mapper.readValue(tpFile, Map.class);
    List<String> serviceBundle = map.get(serviceName);
    if (ListUtil.isNotEmpty(serviceBundle)) {
        return new ServiceContainer(serviceBundle.get(0), serviceBundle.get(1), serviceBundle.get(2));
    }
    return null;
}
Also used : ServiceContainer(com.liferay.ide.project.core.modules.ServiceContainer) ArrayList(java.util.ArrayList) List(java.util.List) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 3 with ServiceContainer

use of com.liferay.ide.project.core.modules.ServiceContainer in project liferay-ide by liferay.

the class TargetPlatformUtil method _getServicesNameList.

@SuppressWarnings("unchecked")
private static ServiceContainer _getServicesNameList(File tpFile) throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    Map<String, String[]> map = mapper.readValue(tpFile, Map.class);
    String[] services = map.keySet().toArray(new String[0]);
    return new ServiceContainer(Arrays.asList(services));
}
Also used : ServiceContainer(com.liferay.ide.project.core.modules.ServiceContainer) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 4 with ServiceContainer

use of com.liferay.ide.project.core.modules.ServiceContainer in project liferay-ide by liferay.

the class NewLiferayComponentModelListenerOperation method getComponentDependency.

@Override
protected List<String[]> getComponentDependency() throws CoreException {
    List<String[]> componentDependency = super.getComponentDependency();
    try {
        ServiceContainer serviceBundle = TargetPlatformUtil.getServiceBundle(serviceName);
        if (serviceBundle != null) {
            Version retriveVersion = new Version(serviceBundle.getBundleVersion());
            componentDependency.add(new String[] { serviceBundle.getBundleGroup(), serviceBundle.getBundleName(), retriveVersion.getMajor() + "." + retriveVersion.getMinor() + ".0" });
        }
    } catch (Exception e) {
    }
    return componentDependency;
}
Also used : ServiceContainer(com.liferay.ide.project.core.modules.ServiceContainer) Version(org.osgi.framework.Version) CoreException(org.eclipse.core.runtime.CoreException)

Example 5 with ServiceContainer

use of com.liferay.ide.project.core.modules.ServiceContainer in project liferay-ide by liferay.

the class LiferayDependencyQuickFix method _processImportNotFoundProposals.

private List<IJavaCompletionProposal> _processImportNotFoundProposals(IInvocationContext context, IProblemLocation problem) {
    ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot());
    if (selectedNode == null) {
        return null;
    }
    ImportDeclaration importDeclaration = (ImportDeclaration) ASTNodes.getParent(selectedNode, ASTNode.IMPORT_DECLARATION);
    if (importDeclaration == null) {
        return null;
    }
    String importName = importDeclaration.getName().toString();
    List<String> serviceWrapperList;
    List<String> servicesList;
    List<IJavaCompletionProposal> proposals = new ArrayList<>();
    try {
        serviceWrapperList = TargetPlatformUtil.getServiceWrapperList().getServiceList();
        servicesList = TargetPlatformUtil.getServicesList().getServiceList();
        if (serviceWrapperList.contains(importName)) {
            ServiceContainer bundle = TargetPlatformUtil.getServiceWrapperBundle(importName);
            proposals.add(_createDepProposal(context, bundle));
        }
        if (servicesList.contains(importName)) {
            ServiceContainer bundle = TargetPlatformUtil.getServiceBundle(importName);
            proposals.add(_createDepProposal(context, bundle));
        }
        if (TargetPlatformUtil.getThirdPartyBundleList(importName) != null) {
            ServiceContainer bundle = TargetPlatformUtil.getThirdPartyBundleList(importName);
            proposals.add(_createDepProposal(context, bundle));
        }
    } catch (Exception e) {
        ProjectCore.logError("Error processing import not found proposals", e);
    }
    return proposals;
}
Also used : ServiceContainer(com.liferay.ide.project.core.modules.ServiceContainer) ASTNode(org.eclipse.jdt.core.dom.ASTNode) ImportDeclaration(org.eclipse.jdt.core.dom.ImportDeclaration) ArrayList(java.util.ArrayList) IJavaCompletionProposal(org.eclipse.jdt.ui.text.java.IJavaCompletionProposal) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

ServiceContainer (com.liferay.ide.project.core.modules.ServiceContainer)9 ArrayList (java.util.ArrayList)4 CoreException (org.eclipse.core.runtime.CoreException)4 ASTNode (org.eclipse.jdt.core.dom.ASTNode)4 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)3 IOException (java.io.IOException)2 List (java.util.List)2 ImportDeclaration (org.eclipse.jdt.core.dom.ImportDeclaration)2 Name (org.eclipse.jdt.core.dom.Name)2 IJavaCompletionProposal (org.eclipse.jdt.ui.text.java.IJavaCompletionProposal)2 Version (org.osgi.framework.Version)2 File (java.io.File)1 URL (java.net.URL)1 Bundle (org.osgi.framework.Bundle)1