Etat HTTP 404 -
type Rapport d'�tat
message
description La ressource demand�e () n'est pas disponible.
Apache Tomcat/6.0.18
package org.teggoinfo.alfresco.bdintegration.action;
import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.sql.ResultSet;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.TempFileProvider;
import org.apache.axis.security.AuthenticatedUser;
import org.teggoinfo.alfresco.bdintegration.BDConnection;
import com.lowagie.text.BadElementException;
import com.lowagie.text.Cell;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.HeaderFooter;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
import de.schlichtherle.io.FileOutputStream;
public class ActionApogee extends ActionExecuterAbstractBase
{
private ContentService contentService;
private SearchService searchService;
private NodeService nodeService;
public static HeaderFooter createHeader() {
Paragraph para = new Paragraph();
para.add("Facture");
HeaderFooter header = new HeaderFooter(para,false);
header.setAlignment(HeaderFooter.ALIGN_CENTER);
return header;
}
public static Cell ajoutEnseignement(String cours,String prof, String salle, int type, int heure) {
Cell cell = new Cell("");
Paragraph p = new Paragraph();
p.add(cours +"\n"+prof+"\n"+salle);
cell.add(p);
cell.setColspan(type);
cell.setRowspan(heure/2);
cell.setHorizontalAlignment(Cell.ALIGN_CENTER);
cell.setVerticalAlignment(Cell.ALIGN_CENTER);
return cell;
}
public static Table createTable(int debut) throws BadElementException {
String sFin = Integer.toString(debut+4);
Table table = new Table(11);
table.setBorderWidth(2);
table.setBorderColor(new Color(0, 0, 255));
table.setPadding(5);
table.setSpacing(3);
Cell cell = createCell("Semaine du "+debut+" au "+ sFin +" décembre",11);
table.addCell(cell);
cell = createCell("Jours\n/\nHeure",1);
table.addCell(cell);
cell=createCell("Lundi "+Integer.toString(debut),2);
table.addCell(cell);
cell=createCell("Mardi "+Integer.toString(debut+1),2);
table.addCell(cell);
cell=createCell("Mercredi "+Integer.toString(debut+2),2);
table.addCell(cell);
cell=createCell("Jeudi "+Integer.toString(debut+3),2);
table.addCell(cell);
cell= createCell("Vendredi "+Integer.toString(debut+4),2);
table.addCell(cell);
return table;
}
private static Cell createCell(String sCell, int colspan) {
Cell cell = new Cell(sCell);
cell.setColspan(colspan);
cell.setHorizontalAlignment(Cell.ALIGN_CENTER);
cell.setVerticalAlignment(Cell.ALIGN_CENTER);
return cell;
}
private File genererFacture(ResultSet res, ResultSet res_client,String id)
{ Document document = new Document(PageSize.A4);
File tmp = TempFileProvider.createTempFile("fact_", ".pdf");
try
{ PdfWriter.getInstance(document, new FileOutputStream(tmp));
document.open();
float[] colsWidth1 = {1f,2f};
PdfPTable table1 = new PdfPTable(colsWidth1);
table1.setWidthPercentage(60);
/*PdfPCell c11 = new PdfPCell(new Paragraph("Client"));
table1.addCell(c11);
res_client.next();
table1.addCell(res.getString(1));
c11 = new PdfPCell(new Paragraph("Adresse Client"));
table1.addCell(c11);
table1.addCell(res.getString(2));
c11 = new PdfPCell(new Paragraph("Facture"));
table1.addCell(c11);
table1.addCell(res.getString(3));
c11 = new PdfPCell(new Paragraph("Date de la facture"));
table1.addCell(c11);
table1.addCell(res.getString(4));
*/
float[] colsWidth = {4f,1f,1f,1f};
PdfPTable table = new PdfPTable(colsWidth);
table.setWidthPercentage(90);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
PdfPCell c = new PdfPCell(new Paragraph("Désignation"));
c.setBackgroundColor(new Color(210,210,210));
table.addCell©;
PdfPCell c1 = new PdfPCell(new Paragraph("Quantité"));
c1.setBackgroundColor(new Color(210,210,210));
table.addCell(c1);
PdfPCell c2 = new PdfPCell(new Paragraph("Prix Unitaire"));
c2.setBackgroundColor(new Color(210,210,210));
table.addCell(c2);
PdfPCell c3 = new PdfPCell(new Paragraph("Montant"));
c3.setBackgroundColor(new Color(210,210,210));
table.addCell(c3);
int total=0;
while(res.next())
{ table.addCell(res.getString(1));
table.addCell(res.getString(2));
table.addCell(res.getString(3));
table.addCell(res.getString(4));
total = total + res.getInt(4);
}
PdfPCell c4 = new PdfPCell(new Paragraph("Total"));
c4.setBackgroundColor(new Color(210,210,210));
c4.setHorizontalAlignment(Cell.ALIGN_RIGHT);
c4.setColspan(3);
table.addCell(c4);
c3 = new PdfPCell(new Paragraph(""+total));
table.addCell(c3);
document.add(table1);
document.add(table);
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
catch (Exception e) {
}
document.close();
System.out.println("Document generated");
return tmp;
}
public static void main(String[] args) {
Document document = new Document(PageSize.A4);
try { File tmp = TempFileProvider.createTempFile("fact_", ".pdf");
PdfWriter.getInstance(document, new FileOutputStream(tmp));
document.open();
document.add(new Phrase("Hello World"));
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
// etape 5: Fermeture du document
document.close();
System.out.println("Document generated");
}
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
ContentReader cr = contentService.getReader(actionedUponNodeRef,ContentModel.TYPE_CONTENT );
String contenu = cr.getContentString();
String req = "select * "+
" from indi "+
" where id ="+contenu+
;
String req_client = "select *"+
" from indi "+
" where id ="+contenu+
" and nom='ayoub'";
File pdf = null;
Connection con= null;
Statement st= null;
try
{
String url = "jdbc:mysql://127.0.0.1:3306/rvn";
String user = "root";
String password = "";
String driver = "com.mysql.jdbc.Driver";
//Charger le driver
Class.forName(driver).newInstance();
//se connecter
conn = DriverManager.getConnection(url,user,password);
ResultSet res = dbc.selectReq(req);
ResultSet res_client = dbc.selectReq(req_client);
pdf = genererFacture(res, res_client,contenu);
}
catch (Exception e) {
}
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
org.alfresco.service.cmr.search.ResultSet resultSet = searchService.query(storeRef, SearchService.LANGUAGE_LUCENE, "PATH:\"/app:company_home/cm:CFAO\"");
System.out.println(resultSet.getNodeRef(0));
NodeRef companyHome = resultSet.getNodeRef(0);
String name_pdf = "RVN_"+contenu+".pdf";
Map<QName, Serializable> contentProps1 = new HashMap<QName, Serializable>();
contentProps1.put(ContentModel.PROP_NAME, name_pdf);
ChildAssociationRef association1 = nodeService.createNode(companyHome,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, name_pdf),
ContentModel.TYPE_CONTENT,
contentProps1);
NodeRef content1 = association1.getChildRef();
ContentWriter writer1 = contentService.getWriter(content1, ContentModel.PROP_CONTENT, true);
writer1.setMimetype(MimetypeMap.MIMETYPE_PDF);
writer1.setEncoding("UTF-8");
writer1.putContent(pdf);
}
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
}
public void setContentService(ContentService contentService) {
this.contentService = contentService;
}
public void setSearchService(SearchService searchService) {
this.searchService = searchService;
}
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}
}
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="bd_integration" class="org.alfresco.sample.ActionApogee" parent="action-executer" >
<property name="nodeService">
<ref bean="nodeService" />
</property>
<property name="contentService">
<ref bean="contentService" />
</property>
<property name="searchService">
<ref bean="searchService" />
</property>
</bean>
</beans>
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bd-integration' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\ActionApogee-context.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com/lowagie/text/DocumentException
Caused by: java.lang.NoClassDefFoundError: com/lowagie/text/DocumentException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.getDeclaredConstructor(Class.java:1985)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:54)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:756)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:721)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:384)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:719)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.ClassNotFoundException: com.lowagie.text.DocumentException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Please correct the errors below then click Finish.
* A system error happened during the operation: str parameter is mandatory
A system error happened during the operation: str parameter is mandatory
java.lang.IllegalArgumentException: str parameter is mandatory
at org.alfresco.service.namespace.QName.resolveToQName(QName.java:408)
at org.alfresco.web.bean.repository.Repository.resolveToQName(Repository.java:810)
at org.alfresco.web.bean.content.BaseContentWizard.saveContent(BaseContentWizard.java:426)
at org.alfresco.web.bean.content.CreateContentWizard.finishImpl(CreateContentWizard.java:135)
at org.alfresco.web.bean.dialog.BaseDialogBean$1.execute(BaseDialogBean.java:121)
at org.alfresco.web.bean.dialog.BaseDialogBean$1.execute(BaseDialogBean.java:118)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:227)
at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:127)
at org.alfresco.web.bean.content.CreateContentWizard.finish(CreateContentWizard.java:118)
at org.alfresco.web.bean.wizard.WizardManager.finish(WizardManager.java:580)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
at javax.faces.component.UICommand.broadcast(UICommand.java:109)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.