Ingratiate content api dotCMS using java

31 views
Skip to first unread message

santosh yadav

unread,
Aug 31, 2018, 5:43:17 AM8/31/18
to dotCMS User Group
Hi All,

Can any one tel me how to ingratiate content API of dotCMS content type using java with return function.

Nathan Keiter

unread,
Aug 31, 2018, 8:50:47 AM8/31/18
to dot...@googlegroups.com

Could you provide more information?

 

What version of dotCMS?

Integrate how?

Integrate what?

Define return function?

Java?

Velocity?

JSON, XML?

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/3b102e23-0ca6-439f-bcac-aff63b91f228%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

santosh yadav

unread,
Aug 31, 2018, 9:14:44 AM8/31/18
to dotCMS User Group
Hi, 
I am using dotCMS version 4.2.2
I have a content type name partNumber and i want to get partNumber data using dynamic plugin.

Nathan Keiter

unread,
Aug 31, 2018, 9:48:32 AM8/31/18
to dot...@googlegroups.com
The API you want is the contentlet API.

https://dotcms.com/docs/com/dotmarketing/portlets/contentlet/business/ContentletAPI.html#search(java.lang.String,%20int,%20int,%20java.lang.String,%20com.liferay.portal.model.User,%20boolean)<https://dotcms.com/docs/com/dotmarketing/portlets/contentlet/business/ContentletAPI.html#search(java.lang.String,%20int,%20int,%20java.lang.String,%20com.liferay.portal.model.User,%20boolean>

Personally, I wrap it in a function of a utility library class. Here is the function I use:


structureName in your case would be "partNumber";


Please note that my function defaults the user to systemUser! If you don't pass in a user, you could expose secure data. It is best practice to pass in the correct user or the current user.


public static List<Contentlet> findContentlet( String structureName, List<String> conditions, int limit, String sortBy, User user, boolean respectFrontendRoles ) throws DotDataException, DotSecurityException
{
List<Contentlet> contentletList = null;
String luceneQuery = "";

// dotCMS API's
ContentletAPI contentletAPI = APILocator.getContentletAPI();
UserAPI userAPI = APILocator.getUserAPI();
User systemUser = userAPI.getSystemUser();

if ( user == null )
{
user = systemUser;
}

luceneQuery = "+structureName:" + structureName;

if ( conditions != null && conditions.size() > 0 )
{
for ( String condition : conditions )
{
luceneQuery = luceneQuery + " " + condition;
}
}

luceneQuery = luceneQuery + " +deleted:false +working:true";

Logger.info( clazz, "luceneQuery: " + luceneQuery );

contentletList = contentletAPI.search( luceneQuery, limit, -1, sortBy, user, respectFrontendRoles );

return contentletList;
}


Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of santosh yadav <az.san...@gmail.com>
Sent: Friday, August 31, 2018 9:14 AM
To: dotCMS User Group
Subject: [dotcms] Re: Ingratiate content api dotCMS using java
--
http://dotcms.com<https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fdotcms.com&c=E,1,lpzJ7UuVEUC7lOT13f1YmUeZQlRItnK2aZS_s-nDRMj1p_uL0jp-G47ZEWbYI1gtaLcOC_K6M0ry5Izxd_sJfyeLKCpKNE0zw3zoOSrPURPwCRpGzw,,&typo=1> - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/440750d2-e32b-4274-888a-aaa19a02bf48%40googlegroups.com<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2fmsgid%2fdotcms%2f440750d2-e32b-4274-888a-aaa19a02bf48%2540googlegroups.com%3futm_medium%3demail%26utm_source%3dfooter&c=E,1,S5F5v3SIWzILSt3nrXHsSL82toWDNFtujJEgKqpjpBXcQI7cbjf-Hq5QwGk5JsTIB9zHE_8lv69tRHgXVrd-krsJFmLtEQG-nuMAw8lX3IRBv-vW&typo=1>.
For more options, visit https://groups.google.com/d/optout<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2foptout&c=E,1,6-NtMa-CGafk6_aavOSs4HZ_fs3FRn2Uw-G00mjJKEJWIT-5KVpNNHfbTT3NUb9-CCbakybizNx62JThtwem4E-7ZlHazRVGDQqTVxrzbfVQcg,,&typo=1>.

santosh yadav

unread,
Aug 31, 2018, 11:39:40 AM8/31/18
to dotCMS User Group
Hi,
I have got an error like following :


error: cannot find symbol
public static List<Contentlet> findContentlet( String structureName, List<String> conditions, int limit, String sortBy, User user, boolean respectFrontendRoles ) throws DotDataException, DotSe
curityException
                   ^
  symbol:   class Contentlet

 

On Friday, 31 August 2018 15:13:17 UTC+5:30, santosh yadav wrote:

Nathan Keiter

unread,
Aug 31, 2018, 11:44:19 AM8/31/18
to dot...@googlegroups.com
import com.dotmarketing.portlets.contentlet.model.Contentlet;


Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of santosh yadav <az.san...@gmail.com>
Sent: Friday, August 31, 2018 11:39 AM
To: dotCMS User Group
Subject: [dotcms] Re: Ingratiate content api dotCMS using java

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/3eb13a2a-01f2-4feb-912f-0d7857336212%40googlegroups.com<https://groups.google.com/d/msgid/dotcms/3eb13a2a-01f2-4feb-912f-0d7857336212%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

santosh yadav

unread,
Sep 4, 2018, 5:37:46 AM9/4/18
to dotCMS User Group
Hi,

I found following error


error: cannot find symbol
public List<Contentlet> findContentlet( String structureName, List<String> conditions, int limit, String sortBy, User user, boolean respectFrontendRoles ) throws DotDataException, DotSecurityE
xception
                                                                                                                                                                                    ^
  symbol:   class DotSecurityException




On Friday, 31 August 2018 15:13:17 UTC+5:30, santosh yadav wrote:

Jason Tesser

unread,
Sep 4, 2018, 7:19:44 AM9/4/18
to dot...@googlegroups.com
If you are saying it is throwing a dotsecurity error that is probably because you do not have permission it access to the content you are querying for

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/aebce1a2-4f3d-46d9-8a4e-d044dede3f8b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--



3059 Grand Avenue
Suite 410-B
Miami FL 33133
Main: 
305-900-2001 | Direct: 978.294.9429

santosh yadav

unread,
Sep 4, 2018, 9:56:56 AM9/4/18
to dotCMS User Group
Hi,

Can you provide me "class DotSecurityException".


On Friday, 31 August 2018 15:13:17 UTC+5:30, santosh yadav wrote:

Will Ezell

unread,
Sep 4, 2018, 10:22:37 AM9/4/18
to dot...@googlegroups.com
It is part of the standard dotcms.jar - make sure you have that on your compile/classpath

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--



3059 Grand Avenue
Suite 410-B
Miami FL 33133
Main: 
305-900-2001 | Direct: 978.294.9429

santosh yadav

unread,
Sep 5, 2018, 7:16:24 AM9/5/18
to dotCMS User Group
Hi 

I am facing a exception again and again like 

error: cannot find symbol DotSecurityException

can you give me this class file.

Thanks



On Friday, 31 August 2018 15:13:17 UTC+5:30, santosh yadav wrote:

Jason Tesser

unread,
Sep 5, 2018, 7:33:15 AM9/5/18
to dot...@googlegroups.com
Maybe you can send screenshots or give a bit more detail of exactly what is not working and what you are trying to do.  

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--



3059 Grand Avenue
Suite 410-B
Miami FL 33133
Main: 
305-900-2001 | Direct: 978.294.9429

santosh yadav

unread,
Sep 5, 2018, 7:41:30 AM9/5/18
to dotCMS User Group
Hi,
I am developing a plugin and want to get record of my content type using dynamic plugin with all relation ship.



On Friday, 31 August 2018 15:13:17 UTC+5:30, santosh yadav wrote:
Capture.JPG

Jason Tesser

unread,
Sep 5, 2018, 8:00:12 AM9/5/18
to dot...@googlegroups.com
So according to the screenshot you sent as Will mentioned your problem is the IDE setup.  It looks like you are not using dotCMS code bas as a dependency to compile against. 

we have OSGi plugins that include dotCMS code base from our Gradle/Maven Repo.  The branches represent different versions of dotCMS in the Repo 

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Nathan Keiter

unread,
Sep 5, 2018, 9:19:06 AM9/5/18
to dot...@googlegroups.com
So you need this:


import com.dotmarketing.exception.DotSecurityException;


And yes, configure your IDE. See this: https://doc.dotcms.com/docs/latest/setting-up-the-ide


Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of Jason Tesser <jason....@dotcms.com>
Sent: Wednesday, September 5, 2018 7:59 AM
To: dot...@googlegroups.com
Subject: Re: [dotcms] Re: Ingratiate content api dotCMS using java

So according to the screenshot you sent as Will mentioned your problem is the IDE setup. It looks like you are not using dotCMS code bas as a dependency to compile against.

Take a look here https://github.com/dotCMS/plugin-seeds/
we have OSGi plugins that include dotCMS code base from our Gradle/Maven Repo. The branches represent different versions of dotCMS in the Repo

On Wed, Sep 5, 2018 at 7:41 AM santosh yadav <az.san...@gmail.com<mailto:az.san...@gmail.com>> wrote:
Hi,
I am developing a plugin and want to get record of my content type using dynamic plugin with all relation ship.



On Friday, 31 August 2018 15:13:17 UTC+5:30, santosh yadav wrote:
Hi All,

Can any one tel me how to ingratiate content API of dotCMS content type using java with return function.


--
http://dotcms.com<https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fdotcms.com&c=E,1,2DSvmqpX83Gd2Z4G7M2L5xzeIjQnAazhoq9lhHaTbLqi1XG1QhfALwKPzeIBKAQuz5wYMpKp2-dvemB6MMbNVSbsEloL1K9oRRkB1u1lkbhF3-JhyQ,,&typo=1> - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/36e0eb4f-208d-474d-b66e-33e9bfef4566%40googlegroups.com<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2fmsgid%2fdotcms%2f36e0eb4f-208d-474d-b66e-33e9bfef4566%2540googlegroups.com%3futm_medium%3demail%26utm_source%3dfooter&c=E,1,V41hFcyV5HJ3gxl_Ocdorfrs0J86pdEggT1XCLjbgUnSXNppa4m65MNEo1mCNOS75AP7xc_sNZtEHl_JYuaT18hDVWs61FOEGJJ4jY9tHz5l-y7q1JqL7VQ,&typo=1>.
For more options, visit https://groups.google.com/d/optout<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2foptout&c=E,1,r2SQxs2C-Ip0dYQvRycDJKxF1_Lhi-QZdiKA6NUBuuTXl7dBXBScl9oU9W1JBBPN-FAbbdYp5SmcSChQX-qF2weV5ITk_2UGSWZL9c4Y4800U5GP9-HSDUMNkhs,&typo=1>.
--
[https://drive.google.com/a/dotcms.com/uc?id=0B4ssYEJmR0gHdEVrSXRxMmN0b0E&export=download]


3059 Grand Avenue
Suite 410-B
Miami FL 33133
Main: 305-900-2001 | Direct: 978.294.9429

jason....@dotcms.com<mailto:jason....@dotcms.com> | dotcms.com<https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fwww.dotcms.com%2f&c=E,1,jWSBpNziU5PQMmVA5GAydPU00WqbQDEyLO0LFn_DZxKFrffMno-atb_vLHPPm4ZDNLhdaKhLs5vbLS9CvJAkbvRAG4NY_Brxre9HxiEoXtDH3igRSEMA&typo=1>

--
http://dotcms.com<https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fdotcms.com&c=E,1,OgI0BNMWgSQOzggvkBfube8WTtKpFvonqWQ9rPAAUOc0b2Q4oRzxcu1XwgnfLlRDKEb5OUSWpDU9UCNZ6NnK4hFYLZMsr8zR4uWiBnc-gA,,&typo=1> - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAKKUxWeJ9FnE%3D%2B5zF74jRFiHwB91Q8h0e8AFGBEKYVCWKTEv2Q%40mail.gmail.com<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2fmsgid%2fdotcms%2fCAKKUxWeJ9FnE%253D%252B5zF74jRFiHwB91Q8h0e8AFGBEKYVCWKTEv2Q%2540mail.gmail.com%3futm_medium%3demail%26utm_source%3dfooter&c=E,1,gaOmEJsT_FeH-GJmXCNoTHVgc7VrJsXkih22IHhQWScnqvGZ2Pr7oSvzx6EWNX6V9uuJ0cKTc4dVtlQAluZySDVfhOcsGVbvzNNcb-EbOUhJPk9tjW9_yl200CZe&typo=1>.
For more options, visit https://groups.google.com/d/optout<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2foptout&c=E,1,lJmabygAlCp_9Dh1iAHQrtlvUDb-tItSF0MtkMyKZyfwYmDzs8w5npRKjSZ_2H3DpzDCs4yDutcVcyAobtFpE1FmwJ5hUPypcfspO-8vU8U,&typo=1>.

jonathan...@dotcms.com

unread,
Sep 5, 2018, 1:17:38 PM9/5/18
to dotCMS User Group
it looks like you are using Intellij idea. 
Usually the easiest way to create the project is just open the build.gradle and then click on "auto-import" in order to get the dependencies on the build.gradle automatically.
I would create the project again, if you have the dotcms on your dependencies in your build.gradle you should get all the dotcms classes that you are missing.
Reply all
Reply to author
Forward
0 new messages