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;
}
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;
}
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));
}
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;
}
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;
}
Aggregations