Moving portlet to the control panel section in liferay 7? - liferay

How can I add a custom portlet to the Control Panel section? I saw various tutorials but all are of liferay 6.2. How to accomplish it in liferay 7? Thanx in advance..

In Liferay 7, if you are using bundles (for example, created via the Blade tools), you can get it working with panel apps. A panel app maps a portlet to a position in the Control Panel.
Suppose you have a portlet generated by Blade, like the one below:
#Component(
immediate = true,
property = {
"com.liferay.portlet.display-category=category.sample",
"com.liferay.portlet.instanceable=false",
"javax.portlet.name=cpportlet",
"javax.portlet.display-name=Control Panel Portlet",
"javax.portlet.security-role-ref=power-user,user"
},
service = Portlet.class
)
public class CpPortlet extends GenericPortlet {
#Override
protected void doView(
RenderRequest renderRequest, RenderResponse renderResponse)
throws IOException, PortletException {
PrintWriter printWriter = renderResponse.getWriter();
printWriter.print("cp-portlet Portlet - Hello World!");
}
}
Now you just create another OSGi component implementing the PanelApp service:
#Component(
immediate = true,
property = {
"panel.app.order:Integer=10000", // Defines position in list
"panel.category.key=" + PanelCategoryKeys.SITE_ADMINISTRATION_CONTENT // To appear in the "Content" session
},
service = PanelApp.class
)
public class CpPanelApp extends BasePanelApp {
#Override
public String getPortletId() {
return "cpportlet"; // Same name of the portlet.
}
#Override
#Reference(
target = "(javax.portlet.name=cpportlet)",
unbind = "-"
)
public void setPortlet(Portlet portlet) {
super.setPortlet(portlet);
}
}
To compile that, you will depend on the "Application List app" API - It is there that we find the PanelApp class. So, just add this dependency to your build.gradle, as below:
dependencies {
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.0.0"
compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
compileOnly group: "org.osgi", name: "org.osgi.compendium", version: "5.0.0"
compileOnly group: "com.liferay", name: "com.liferay.application.list.api", version: "2.0.0" // Dependency added
}
Now deploy it and the portlet will appear in the listing:
This is just the basic idea — the documentation is very instructive about it.

You can define control-panel category by properties for Component:
com.liferay.portlet.control-panel-entry-category=<String>
com.liferay.portlet.control-panel-entry-weight=<double>
Please refer mapping listed here:
https://dev.liferay.com/develop/reference/-/knowledge_base/7-0/portlet-descriptor-to-osgi-service-property-map

Related

Xamarin ios: loaded the nib but the view outlet was not set

I’m new in xamarin ios and I need to add view in existing project. Project use mvvmcross framework.
I’ve done:
Created PerevozkiViewModelClass :MvxViewModel in Core project
Add UI View controller with storydoard (P.S. BaseView extends MvxViewController)
public partial class PerevozkiView : BaseView
{
public PerevozkiView() : base("PerevozkiView", null)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
var set = this.CreateBindingSet<PerevozkiView, PerevozkiViewModel>();
set.Apply();
}
}
Delete PerevozkiView.Storyboard
4.Add PerevozkiView.xib and in file owner specify PerevozkiView (I cant choose it from list, so I just hardcode “PerevozkiView as file owner)
After deploy in IOS simulator I’ve got exception:
Foundation.MonoTouchException
Сообщение = Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: -[UIViewController _loadViewFromNibNamed:bundle:] loaded the "PerevozkiView" nib but the view outlet was not set here in Main:
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, "AppDelegate");
}
}
I have no idea what is wrong. Pls help

How to manually configure OpenTracing Spring Web Instrumentation using xml

I've inherited a legacy Spring3 application, and I'm trying to add Lightstep instrumentation to it. I'm having trouble converting the instructions for manually configuration found here.
https://github.com/opentracing-contrib/java-spring-web
In short, I need to convert the code block below to the xml equivalent.
#Configuration
#Import({TracingHandlerInterceptor.class})
public class MVCConfiguration extends WebMvcConfigurerAdapter {
#Autowired
private Tracer tracer;
#Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new TracingHandlerInterceptor(tracer));
}
#Bean
public FilterRegistrationBean tracingFilter() {
TracingFilter tracingFilter = new TracingFilter(tracer);
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(tracingFilter);
filterRegistrationBean.addUrlPatterns("/*");
filterRegistrationBean.setOrder(Integer.MIN_VALUE);
filterRegistrationBean.setAsyncSupported(true);
return filterRegistrationBean;
}
}
I've successfully created my Lightstep Tracer bean using the following dependencies.
compile group: 'com.lightstep.tracer', name: 'lightstep-tracer-jre', version: '0.14.8'
compile group: 'com.lightstep.tracer', name: 'tracer-okhttp', version: '0.15.10'
//https://mvnrepository.com/artifact/io.opentracing.contrib/opentracing-spring-web-starter
compile group: 'io.opentracing.contrib', name: 'opentracing-spring-web-starter', version: '0.3.3'

Implementing permissions on Liferay 7.1

I'm trying to implement permissions (resources & models ones) on Liferay 7.1. I've noted that BaseModelPermissionChecker is now deprecated (so I should not make my permission classes extending it). So I tried to do as indicated in Liferay official tutorial
However, when deploying my osgi services, OSGI container indicates the following error (for model and resource permission):
ERROR [Refresh Thread: Equinox Container: 80bbc977-c7cb-0018-1000-82f21869d6ec][com_liferay_training_space_gradebook_service:97] [com.a.b.c.service.permission.MyEntityPermission(3887)] Field _portletResourcePermission in component class com.a.b.c.service.permission.MyEntityPermission must not be static.
Have you got that error ? Did I skip something ?
EDIT
Component created:
#Component(immediate = true, service = {})
public class BookResourcePermission {
public static final String ADD_BOOK = "ADD_BOOK";
#Reference(target = "(resource.name=com.x.y.mybook.model)", unbind = "-")
protected static void setPortletResourcePermission(PortletResourcePermission portletResourcePermission) {
_portletResourcePermission = portletResourcePermission;
}
public static boolean contains(PermissionChecker permissionChecker, long groupId, String actionId) {
return _portletResourcePermission.contains(permissionChecker, groupId, actionId);
}
private static PortletResourcePermission _portletResourcePermission;
}
Thanks !

Liferay control panel menu portlets

How does liferay list out the portlet to be shown in the control panel menu?
Can any body list the classes and JSP involved in the same?
Refer to file in your liferay source at location : \portal-web\docroot\html\portlet\control_panel_menu\view.jsp
You will get idea how liferay shows its control panel menu.
Link for code of this jsp.
All of the portlets are saved in the portlet table while we deploy them. Then once the control panel is accessed then liferay loads all of the portlet which are having the control panel entry in them. For better explanation see the below code in
com.liferay.portal.util.PortalImpl
#Override
public Set<Portlet> getControlPanelPortlets(long companyId, String category)
throws SystemException {
Set<Portlet> portletsSet = new TreeSet<Portlet>(
new PortletControlPanelWeightComparator());
if (Validator.isNull(category)) {
return portletsSet;
}
List<Portlet> portletsList = PortletLocalServiceUtil.getPortlets(
companyId);
for (Portlet portlet : portletsList) {
String portletCategory = portlet.getControlPanelEntryCategory();
if (category.equals(portletCategory) ||
(category.endsWith(StringPool.PERIOD) &&
StringUtil.startsWith(portletCategory, category))) {
portletsSet.add(portlet);
}
}
return portletsSet;
}
#Override
public List<Portlet> getControlPanelPortlets(
String category, ThemeDisplay themeDisplay)
throws SystemException {
Set<Portlet> portlets = getControlPanelPortlets(
themeDisplay.getCompanyId(), category);
return filterControlPanelPortlets(portlets, themeDisplay);
}
The above code is called from the
\portal-web\docroot\html\portlet\control_panel_menu\view.jsp
Map<String, List<Portlet>> siteAdministrationCategoriesMap = PortalUtil.getSiteAdministrationCategoriesMap(request);
Help taken from pankaj-kathiriya answer. Thanks for the same.

Url to get latest build # of CC.NET project?

I have CruiseControl.NET version 1.4.4.83, and I am wondering if there it provides a url where the only control is the lastest build # of a project, so that I can access that data using curl or something?
Something like http://buildserver/ccnet/server/VMSDEV2/project/MyProject/LatestBuild.aspx
All that it would have is:
0.0.0.31
Update:
Fixed the IPlugin issue with an attribute for the class:
[Exortech.NetReflector.ReflectorType("latestBuildNumberProjectPlugin")]
public class LatestBuildNumberProjectPlugin : ICruiseAction, IPlugin
{
public static readonly string ACTION_NAME;
private readonly IFarmService farmService;
private readonly ILinkFactory linkFactory;
static LatestBuildNumberProjectPlugin()
{
ACTION_NAME = "LatestBuildNumber";
}
public LatestBuildNumberProjectPlugin(IFarmService farmService, ILinkFactory linkFactory)
{
this.farmService = farmService;
this.linkFactory = linkFactory;
}
public IResponse Execute(ICruiseRequest cruiseRequest)
{
IProjectSpecifier projectSpecifier = cruiseRequest.ProjectSpecifier;
IBuildSpecifier[] mostRecentBuildSpecifiers = this.farmService.GetMostRecentBuildSpecifiers(projectSpecifier, 1);
if (mostRecentBuildSpecifiers.Length == 1)
{
var build = mostRecentBuildSpecifiers[0].BuildName;
var response = new HtmlFragmentResponse(build);
return response;
}
return new HtmlFragmentResponse("There are no complete builds for this project");
}
public INamedAction[] NamedActions
{
get
{
return new INamedAction[] { new ImmutableNamedAction(ACTION_NAME, this) };
}
}
public string LinkDescription
{
get { return "Latest Build Number"; }
}
}
And I've named my assembly:
ccnet.latestBuildNumberProjectPlugin.plugin.dll
And in the dashboard.config file, I've added the plugin ref:
<projectPlugins>
...
<latestBuildReportProjectPlugin />
...
</projectPlugins>
But apparently, var build = mostRecentBuildSpecifiers[0].BuildName; is not what I am looking for.
I believe it is possible to create packages to extend the CC.NET Dashboard (i.e. the website) and completely change the interface.
To help you get started, check the CC.NET documentation.
A few links that could be of help.
- Developing Web Dashboard Plugins
- Building Packages
- Configuring the Web Dashboard
HTH,
The link to the latest build is:
http://myserver.com/cc_net/server/local/project/myproject/ViewLatestBuildReport.aspx
it will expand in :
http://myserver.com/cc_net/server/local/project/myproject/build/log20100618165244Lbuild.45.xml/ViewBuildReport.aspx
Inside the html page, you have your build number.

Resources