2016-04-07 36 views
1
ile

DocumentAndMedia'dan bir kanca yaptım. Com.liferay.portlet.documentlibrary.action.EditFileEntryAction = com.mycompany.acciones.Test yazdım portal.properties ben dosya giriş görünümünde gördüğümde dosya dosya alabilirim. Bazı ekstra özellikler almak için FileEntry dosyasını org.apache.chemistry.opencmis.client.runtime.DocumentImpl dosyasına fileEntry.getModel() dosyasından yüklemek istiyorum ancak bir istisna atılıyor.Liferay DocumentAndMedia CMIS

Testi Eylem Sınıf

package com.mycompany.acciones; 

import javax.portlet.*; 
import org.apache.chemistry.opencmis.client.runtime.*; 
import com.liferay.portal.kernel.repository.model.*; 
import com.liferay.portal.kernel.struts.*; 
import com.liferay.portal.kernel.util.*; 

public class Test extends BaseStrutsPortletAction{ 

    public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { 

     originalStrutsPortletAction.processAction(originalStrutsPortletAction, portletConfig, actionRequest, actionResponse); 
    } 

    @Override 
    public String render(StrutsPortletAction originalStrutsPortletAction,PortletConfig portletConfig,RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { 

     String ret = originalStrutsPortletAction.render(null, portletConfig, renderRequest, renderResponse); 
     renderRequest.setAttribute(WebKeys.PORTLET_DECORATE, Boolean.TRUE); 

     FileEntry fileEntry = (FileEntry)renderRequest.getAttribute("DOCUMENT_LIBRARY_FILE_ENTRY"); 

     // Exception is throws here 
     DocumentImpl doc = (DocumentImpl)fileEntry.getModel();  

     String propertyName = doc.getProperties().get(0).getDisplayName(); 
     String propertyvalue = doc.getProperties().get(0).getValue(); 

     String propertyName2 = doc.getProperties().get(1).getDisplayName(); 
     String propertyvalue2 = doc.getProperties().get(1).getValue(); 

     return ret; 
    } 
} 

StackTrace

17:33:52,796 ERROR [http-bio-8080-exec-398][render_portlet_jsp:154] java.lang.ClassCastException: org.apache.chemistry.opencmis.client.runtime.DocumentImpl cannot be cast to org.apache.chemistry.opencmis.client.runtime.DocumentImpl 
    at com.mycompany.acciones.Test.render(Test.java:31) 
    at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:67) 
    at com.liferay.portal.struts.PortletActionAdapter.render(PortletActionAdapter.java:74) 
    at com.liferay.portal.struts.PortletAction.execute(PortletAction.java:111) 
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) 
    at com.liferay.portal.struts.PortletRequestProcessor.processActionPerform(PortletRequestProcessor.java:441) 
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) 
    at com.liferay.portal.struts.PortletRequestProcessor.process(PortletRequestProcessor.java:224) 
    at com.liferay.portlet.StrutsPortlet.include(StrutsPortlet.java:274) 
    at com.liferay.portlet.StrutsPortlet.doView(StrutsPortlet.java:153) 
    at com.liferay.portal.kernel.portlet.LiferayPortlet.doDispatch(LiferayPortlet.java:218) 
    at javax.portlet.GenericPortlet.render(GenericPortlet.java:233) 
    at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100) 
    at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64) 
    at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:548) 
    at com.liferay.portlet.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:607) 
    at com.liferay.portlet.InvokerPortletImpl.render(InvokerPortletImpl.java:359) 
    at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:1207) 
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 

cevap

0

bir sınıf kesinlikle suçlayıcı sınıf veya onun var o meşru (hatta kendisine) gerektiği başka sınıfa typecasted edilemiyorsa Classpath üzerinde iki kez superclass. Yinelenen için sınıf yolunuzu kontrol edin, çözün. Tomcat'in global sınıfında (tomcat/lib veya Liferay için tomcat/lib/ext) veya web uygulamanızda (WEB-INF/lib veya WEB-INF/classes'da) bir kütüphane olabilir. . Çoklu gereksiz olanları kurtulun aynı adı taşıyan bir sınıfın uygulamalarını

, yeniden var olduğu Veya hepsini bir arada (tekrar deneyin

+0

Cevabınız için çok teşekkür ederim. Benim için çalışıyor! Ben apache kimya libs (webapps/root/web-inf/lib) tomcat/lib/ext dosyasına taşımak ve cevabınız için teşekkürler myhook/web-inf/lib –

0

paket testi;.

import javax.portlet.ActionRequest; 
import javax.portlet.ActionResponse; 
import javax.portlet.PortletConfig; 
import javax.portlet.RenderRequest; 
import javax.portlet.RenderResponse; 

import com.liferay.portal.kernel.repository.model.FileEntry; 
import com.liferay.portal.kernel.struts.BaseStrutsPortletAction; 
import com.liferay.portal.kernel.struts.StrutsPortletAction; 
import com.liferay.portal.kernel.util.WebKeys; 
import com.liferay.portlet.documentlibrary.model.DLFileEntry; 

public class EditFileEntryAction extends BaseStrutsPortletAction { 

    public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { 

      originalStrutsPortletAction.processAction(originalStrutsPortletAction, portletConfig, actionRequest, actionResponse); 
     } 

     @Override 
     public String render(StrutsPortletAction originalStrutsPortletAction,PortletConfig portletConfig,RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { 

      String ret = originalStrutsPortletAction.render(null, portletConfig, renderRequest, renderResponse); 
      renderRequest.setAttribute(WebKeys.PORTLET_DECORATE, Boolean.TRUE); 

      FileEntry fileEntry = (FileEntry)renderRequest.getAttribute("DOCUMENT_LIBRARY_FILE_ENTRY"); 

      // Exception is throws here 
      DLFileEntry doc = (DLFileEntry)fileEntry.getModel();  


      return ret; 
     } 
} 

Bu benim için çalıştı, ancak döküm, DLPileEntry değil, DocumentImpl.

Neden org.apache.chemistry.opencmis.client.runtime.DocumentImpl dosyasına gereksinim duyuyorsunuz ve nasıl biliyorsunuz, getModel() bu türle birlikte geliyor nesne?

+0

'dan silmek zorunda kaldım. DocumentImpl kullanıyorum çünkü liferayımda cmis uygulamasını kullanıyorum. Bu nesneden DLFileEntry'nin sahip olmadığı bazı ekstra özelliklere ihtiyacım var. FileEntry.getModel() yöntemi bir nesne döndürür, ancak CmisFileEntry.getModel() bir cmis belgesini döndürür –

İlgili konular