Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Luigi Molinaro
start workflow programmatically after uploaded file in the DL
20 luglio 2012 4.31
Risposta

Luigi Molinaro

Punteggio: New Member

Messaggi: 13

Data di Iscrizione: 29 maggio 2012

Messaggi recenti

1
2DLFolder dlFolder = DLFolderLocalServiceUtil.getFolder(themeDisplay.getScopeGroupId(), 0, "Test");
3ServiceContext serviceContext = ServiceContextFactory.getInstance(DLFileEntry.class.getName(),
4actionRequest);
5fileEntry = DLFileEntryServiceUtil.addFileEntry(dlFolder.getGroupId(), dlFolder.getRepositoryId(), dlFolder.getFolderId() ,file.getName(),"" ,title,"test", null, dlFolder.getDefaultFileEntryTypeId(), null, file, null, file.getUsableSpace(), serviceContext);


I have just selected workflow definition for document library portlet, but will not start when I add a file programmatically using this code, adds it to the folder as a draft, not as pending.
Pinkesh Gandhi
RE: start workflow programmatically after uploaded file in the DL
20 luglio 2012 4.59
Risposta

Pinkesh Gandhi

Punteggio: Regular Member

Messaggi: 100

Data di Iscrizione: 26 gennaio 2012

Messaggi recenti

Hi Luiqi,

To fulfill your requirement, you can use 'WorkflowHandlerRegistryUtil' class and can call one of the 'startWorkflowInstance(...)' method of it to start workflow through your code.

Hope this will helps you.

Let me know if you have any query for the same.
Luigi Molinaro
RE: start workflow programmatically after uploaded file in the DL
23 luglio 2012 3.10
Risposta

Luigi Molinaro

Punteggio: New Member

Messaggi: 13

Data di Iscrizione: 29 maggio 2012

Messaggi recenti

Hi Pinkesh,
thanks, for replay!

1
2DLFolder dlFolder = DLFolderLocalServiceUtil.getFolder(themeDisplay.getScopeGroupId(), 0, "Uploads");
3              dlFolder = DLFolderLocalServiceUtil.getFolder(themeDisplay.getScopeGroupId(), dlFolder.getFolderId(), String.valueOf(themeDisplay.getUserId()));
4              ServiceContext serviceContext = ServiceContextFactory.getInstance(DLFileEntry.class.getName(),
5                      actionRequest);
6             
7              fileEntry = DLFileEntryServiceUtil.addFileEntry(dlFolder.getGroupId(), dlFolder.getRepositoryId(), dlFolder.getFolderId() ,file.getName(),"" ,title,"prooova", null, dlFolder.getDefaultFileEntryTypeId(), null, file, null, file.getUsableSpace(), serviceContext);
8              WorkflowHandlerRegistryUtil.startWorkflowInstance(themeDisplay.getCompanyId(), dlFolder.getGroupId(), themeDisplay.getUserId(), DLFileEntry.class.getName(),fileEntry.getFileEntryId(), fileEntry, serviceContext);


I have try whit this code, but not work!

the document is in Folder, but as draft, not as pending.
in the task of user assigned from workflow not appear null.

in the attachment the error generated.
Allegati: error (15,0k)
Pinkesh Gandhi
RE: start workflow programmatically after uploaded file in the DL
23 luglio 2012 3.41
Risposta

Pinkesh Gandhi

Punteggio: Regular Member

Messaggi: 100

Data di Iscrizione: 26 gennaio 2012

Messaggi recenti

Hi Luigi Molinaro,

Can you please put a debugging or sop statement after each and every code statement, as I've doubt that the error which you attached here is comes on the execution of line fileEntry = DLFileEntryServiceUtil.addFileEntry(...); so it is not going to execute the line for startWorkflowInstance(...).

And I suggest one more thing that, please use DLFileEntryLocalServiceUtil instead of DLFileEntryServiceUtil.

Try it out and let me know if you have any query.
Luigi Molinaro
RE: start workflow programmatically after uploaded file in the DL
23 luglio 2012 5.05
Risposta

Luigi Molinaro

Punteggio: New Member

Messaggi: 13

Data di Iscrizione: 29 maggio 2012

Messaggi recenti

Hi Pinkesh,
 1
 2 DLFolder dlFolder = DLFolderLocalServiceUtil.getFolder(themeDisplay.getScopeGroupId(), 0, "Uploads");
 3              dlFolder = DLFolderLocalServiceUtil.getFolder(themeDisplay.getScopeGroupId(), dlFolder.getFolderId(), String.valueOf(themeDisplay.getUserId()));
 4              ServiceContext serviceContext = ServiceContextFactory.getInstance(DLFileEntry.class.getName(),
 5                      actionRequest);
 6              System.out.println("HERE11111111111");
 7              fileEntry = DLFileEntryLocalServiceUtil.addFileEntry(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), dlFolder.getRepositoryId(), dlFolder.getFolderId(), file.getName(), "", title, "prova", null, dlFolder.getDefaultFileEntryTypeId(), null, file, null, file.getTotalSpace(), serviceContext);
 8//              fileEntry = DLFileEntryServiceUtil.addFileEntry(dlFolder.getGroupId(), dlFolder.getRepositoryId(), dlFolder.getFolderId() ,file.getName(),"" ,title,"prooova", null, dlFolder.getDefaultFileEntryTypeId(), null, file, null, file.getUsableSpace(), serviceContext);
 9              System.out.println("HERE");
10              WorkflowHandlerRegistryUtil.startWorkflowInstance(themeDisplay.getCompanyId(), dlFolder.getGroupId(), themeDisplay.getUserId(), DLFileEntry.class.getName(),fileEntry.getFileEntryId(), fileEntry, serviceContext);
11              System.out.println("HERE---------");


emoticon nada de nada!
Allegati: error (15,0k)
Pinkesh Gandhi
RE: start workflow programmatically after uploaded file in the DL
23 luglio 2012 7.28
Risposta

Pinkesh Gandhi

Punteggio: Regular Member

Messaggi: 100

Data di Iscrizione: 26 gennaio 2012

Messaggi recenti

Again can you please try with following code snippet

 1
 2long defaultRepoId = DLFolderConstants.getDataRepositoryId(themeDisplay.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
 3            Folder folder = DLAppLocalServiceUtil.getFolder(defaultRepoId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Uploads");
 4            System.out.println("HERE11111111111");
 5            folder = DLAppLocalServiceUtil.getFolder(defaultRepoId, folder.getFolderId(), "Uploads");
 6            
 7            System.out.println("HERE22222222222");
 8   
 9            
10            FileEntry fileEntry = DLAppLocalServiceUtil.addFileEntry(themeDisplay.getUserId(), folder.getRepositoryId(), folder.getFolderId(), file.getName(), MimeTypesUtil.getContentType(file), title, "prooova", StringPool.BLANK, file, new ServiceContext());
11//               
12            System.out.println("HERE");
13            
14            serviceContext =  ServiceContextFactory.getInstance(FileEntry.class.getName(), actionRequest);
15            
16            WorkflowHandlerRegistryUtil.startWorkflowInstance(themeDisplay.getCompanyId(), dlFolder.getGroupId(), themeDisplay.getUserId(), FileEntry.class.getName(),fileEntry.getFileEntryId(), fileEntry, serviceContext);
17            System.out.println("HERE---------");


I hope it helps you.
Luigi Molinaro
RE: start workflow programmatically after uploaded file in the DL
23 luglio 2012 7.06
Risposta

Luigi Molinaro

Punteggio: New Member

Messaggi: 13

Data di Iscrizione: 29 maggio 2012

Messaggi recenti

 1
 2long defaultRepoId = DLFolderConstants.getDataRepositoryId(themeDisplay.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
 3            Folder folder = DLAppLocalServiceUtil.getFolder(defaultRepoId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Uploads");
 4            System.out.println("HERE11111111111");
 5             folder = DLAppLocalServiceUtil.getFolder(defaultRepoId, folder.getFolderId(), String.valueOf(themeDisplay.getUserId()));
 6           [u][b] dlFolder = DLFolderLocalServiceUtil.getFolder(themeDisplay.getScopeGroupId(), 0, String.valueOf(themeDisplay.getUserId()));    [/b][/u]   
 7            System.out.println("HERE22222222222");
 8   
 9            
10            FileEntry fileEntry = DLAppLocalServiceUtil.addFileEntry(themeDisplay.getUserId(), folder.getRepositoryId(), folder.getFolderId(), file.getName(), MimeTypesUtil.getContentType(file), title, "prooova", StringPool.BLANK, file, new ServiceContext());
11//               
12            System.out.println("HERE");
13            
14            serviceContext =  ServiceContextFactory.getInstance(FileEntry.class.getName(), actionRequest);
15            
16            WorkflowHandlerRegistryUtil.startWorkflowInstance(themeDisplay.getCompanyId(), dlFolder.getGroupId(), themeDisplay.getUserId(), FileEntry.class.getName(),fileEntry.getFileEntryId(), fileEntry, serviceContext);
17            System.out.println("HERE---------");

I had an error, but removing the line above underline, it's work!! emoticon

I also still an error, but no matter ... so it works! emoticon

thanks a lot Pinkesh
Allegati: error (13,3k)
Pinkesh Gandhi
RE: start workflow programmatically after uploaded file in the DL
23 luglio 2012 7.25
Risposta

Pinkesh Gandhi

Punteggio: Regular Member

Messaggi: 100

Data di Iscrizione: 26 gennaio 2012

Messaggi recenti

Hi Luigi,

By looking into error file you attached here, one thing I've noticed that you haven't deployed any workflow engine in your system and that's why that error comes.
So I suggest, please deploy any suitable workflow engine in your liferay system and then after do such kind of workflow related stuffs.

Hope now you get more clarity on workflow.

Let me know if you have any query.
Luigi Molinaro
RE: start workflow programmatically after uploaded file in the DL
23 luglio 2012 7.57
Risposta

Luigi Molinaro

Punteggio: New Member

Messaggi: 13

Data di Iscrizione: 29 maggio 2012

Messaggi recenti

I I have deployed the kaleo workflow engine, (default).
however works. thanks.
I have other one question for you.
how can i call an static function written in an my class from script the workflow?
For exemple:
 1
 2<state><!-- create -->
 3        <name>created</name>
 4        <metadata>
 5            <![CDATA[{"xy":[38,187]}]]>
 6        </metadata>
 7        <actions>
 8            <action>
 9                <name>provaa</name>
10                <script>
11                    <![CDATA[
12                        [u][b]mok.Utility.staticFunction("moook",workflowContext);[/b][/u]
13                    ]]>
14                </script>
15                <script-language>javascript</script-language>
16                <execution-type>onEntry</execution-type>
17            </action>
18        </actions>
19        <initial>true</initial>
20        <transitions>
21            <transition>
22                <name>review</name>
23                <target>reviewPortal</target>
24                <default>true</default>
25            </transition>
26        </transitions>
27    </state>
Pinkesh Gandhi
RE: start workflow programmatically after uploaded file in the DL
23 luglio 2012 23.34
Risposta

Pinkesh Gandhi

Punteggio: Regular Member

Messaggi: 100

Data di Iscrizione: 26 gennaio 2012

Messaggi recenti

I am not sure but as per my knowledge, directly it is not possible.
To make it possible you have to make the jar of your utility class which contains static method and put it into tomcat/lib/ext folder.

I hope this may helps you.
Luigi Molinaro
RE: start workflow programmatically after uploaded file in the DL
24 luglio 2012 2.04
Risposta

Luigi Molinaro

Punteggio: New Member

Messaggi: 13

Data di Iscrizione: 29 maggio 2012

Messaggi recenti

I tried different ways, but don't works.
Don't worry, this problem not important.
Thanks very much.
Pinkesh Gandhi
RE: start workflow programmatically after uploaded file in the DL
24 luglio 2012 2.50
Risposta

Pinkesh Gandhi

Punteggio: Regular Member

Messaggi: 100

Data di Iscrizione: 26 gennaio 2012

Messaggi recenti

It should work as your class will be loaded globally and it would be available to all web application for use.

Any ways, if you are comfortable with your current solution then ok. emoticon
Mohammad Azharuddin
RE: start workflow programmatically after uploaded file in the DL
31 dicembre 2012 1.18
Risposta

Mohammad Azharuddin

Punteggio: Expert

Messaggi: 475

Data di Iscrizione: 17 settembre 2012

Messaggi recenti

Hi Luigi Molinaro
I was facing same problem.Update File Entry after adding file with same data
try this code
DLFileEntry dlFileEntry=DLFileEntryLocalServiceUtil.addFileEntry(userId,10179, repId, folId, fileName+".png", MimeTypesUtil.getContentType(fileInfo.getFile()), fileTitle, fileDesc, "sss",
entryType.getFileEntryTypeId()
,fieldsMap
,fileInfo.getFile()
,null
,fileInfo.getFile().length()
,serviceContext);

DLFileEntryLocalServiceUtil.updateFileEntry(userId, dlFileEntry.getFileEntryId(), fileName+".png", MimeTypesUtil.getContentType(fileInfo.getFile()), fileTitle, fileDesc, comment, true, dlFileEntry.getFileEntryTypeId(), fieldsMap, fileInfo.getFile(), null, fileInfo.getFile().length(), serviceContext);



Or follow this link -----file upload
Alexis Araya
RE: start workflow programmatically after uploaded file in the DL
3 giugno 2014 13.17
Risposta

Alexis Araya

Punteggio: Junior Member

Messaggi: 36

Data di Iscrizione: 8 ottobre 2013

Messaggi recenti

You can show an example?
My portlet generates the income to a document library.
but in trying to build the workflow, not found me


Luigi Molinaro:
 1
 2long defaultRepoId = DLFolderConstants.getDataRepositoryId(themeDisplay.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
 3            Folder folder = DLAppLocalServiceUtil.getFolder(defaultRepoId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Uploads");
 4            System.out.println("HERE11111111111");
 5             folder = DLAppLocalServiceUtil.getFolder(defaultRepoId, folder.getFolderId(), String.valueOf(themeDisplay.getUserId()));
 6           [u][b] dlFolder = DLFolderLocalServiceUtil.getFolder(themeDisplay.getScopeGroupId(), 0, String.valueOf(themeDisplay.getUserId()));    [/b][/u]   
 7            System.out.println("HERE22222222222");
 8   
 9            
10            FileEntry fileEntry = DLAppLocalServiceUtil.addFileEntry(themeDisplay.getUserId(), folder.getRepositoryId(), folder.getFolderId(), file.getName(), MimeTypesUtil.getContentType(file), title, "prooova", StringPool.BLANK, file, new ServiceContext());
11//               
12            System.out.println("HERE");
13            
14            serviceContext =  ServiceContextFactory.getInstance(FileEntry.class.getName(), actionRequest);
15            
16            WorkflowHandlerRegistryUtil.startWorkflowInstance(themeDisplay.getCompanyId(), dlFolder.getGroupId(), themeDisplay.getUserId(), FileEntry.class.getName(),fileEntry.getFileEntryId(), fileEntry, serviceContext);
17            System.out.println("HERE---------");

I had an error, but removing the line above underline, it's work!! emoticon

I also still an error, but no matter ... so it works! emoticon

thanks a lot Pinkesh