RE: Getting Error while extending DLAdminNavigationDisplayContext(Liferay v

thumbnail
Vikash Chandrol, modified 5 Years ago. Junior Member Posts: 30 Join Date: 4/18/13 Recent Posts
Currently, I am trying to remove the navigation item from document and media portlet but after deploying my plugin getting below errorBelow code, I have written
import com.liferay.document.library.web.internal.display.context.DLAdminNavigationDisplayContext;
import com.liferay.frontend.taglib.clay.servlet.taglib.util.NavigationItem;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.model.Role;
import com.liferay.portal.kernel.portlet.LiferayPortletRequest;
import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.WebKeys;import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class DLAdminNavigationContext extends DLAdminNavigationDisplayContext {
    private ThemeDisplay themeDisplay;
    private static final Log LOGGER = LogFactoryUtil.getLog(DLAdminNavigationContext.class);
    public DLAdminNavigationContext(LiferayPortletRequest liferayPortletRequest,
            LiferayPortletResponse liferayPortletResponse) {
        super(liferayPortletRequest, liferayPortletResponse);
        this.themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);
    }    
      @Override public List<NavigationItem> getNavigationItems() {
      LOGGER.info("START : getNavigationItems");
      if(!isContentAdmin(themeDisplay)) { return
              super.getNavigationItems(); 
      }else { 
          List<NavigationItem>  customNavigations=new ArrayList<NavigationItem>(); 
          for(NavigationItem navigationItem:super.getNavigationItems()) 
          { 
                  LOGGER.info("NAV ITERATE..");
                  Iterator<String> itr=navigationItem.keySet().iterator(); 
                  boolean hasMeta=false;
                  while(itr.hasNext()) {
                          String key= (String) itr.next();
                          LOGGER.info("navigationItem :"+key); 
                          if(key.toLowerCase().contains("meta")){ hasMeta=true;break;   }
                  } 
                 if(!hasMeta){ customNavigations.add(navigationItem);  }
         } return customNavigations; 
       } 
      }
      private boolean isContentAdmin(ThemeDisplay themeDisplay) {
            List<Role> roles=themeDisplay.getUser().getRoles();
            boolean isContentAdmin=false;
            for (Role role : roles) {
                    String name=role.getName().toLowerCase();
                    if (name.contains("content-admin") ) {
                        isContentAdmin = true;
                        break;
                    }
             
            }
            return isContentAdmin;
        }
}

build.gradle

dependencies {
    compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "4.4.0"
    compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "4.0.8"
    compile group: "com.liferay.portal", name: "com.liferay.util.java", version: "4.0.0"
    compileOnly group: "javax.portlet", name: "portlet-api", version: "3.0.0"
    compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
    compile group: "javax.servlet.jsp", name: "javax.servlet.jsp-api", version: "2.3.1"
    compileOnly group: "jstl", name: "jstl", version: "1.2"
    compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
    compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning", version: "1.1.0"
    compileOnly group: "org.osgi", name: "org.osgi.core", version: "6.0.0"
    compileOnly group: "com.liferay", name: "com.liferay.document.library.repository.authorization.api", version: "3.0.2"
    compileOnly group: "com.liferay", name: "com.liferay.document.library.service", version: "4.0.14"
    compileOnly group: "com.liferay", name: "com.liferay.document.library.api", version: "5.1.6"
    compileOnly group: "com.liferay", name: "com.liferay.dynamic.data.mapping.api", version: "5.2.0"
    compileOnly group: "com.liferay", name: "com.liferay.dynamic.data.mapping.taglib", version: "4.1.2"
    compile group: 'com.liferay', name: 'com.liferay.document.library.web', version: '4.0.21'
    compile group: 'com.liferay', name: 'com.liferay.frontend.taglib.clay', version: '2.1.6'
}

bnd.bnd

Bundle-Name: CustomActions
Bundle-SymbolicName: CustomActions
Bundle-Version: 1.0.0
Export-Package: com.custom.action

Getting Below Error

​​​​​​​ERROR [fileinstall-D:/server/osgi/modules][LogService:93] Error while starting bundle: file:/D:/server/osgi/modules/CustomActions.jar 
org.osgi.framework.BundleException: Could not resolve module: CustomActions [1140]_  Unresolved requirement: Import-Package: com.liferay.document.library.web.internal.display.context_ [Sanitized]
    at org.eclipse.osgi.container.Module.start(Module.java:444)
    at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1264)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1237)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1226)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:515)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316)

Could you please help me out on this.
thumbnail
Vikash Chandrol, modified 5 Years ago. Junior Member Posts: 30 Join Date: 4/18/13 Recent Posts
guys, please support.