Foros de discusión

Service Builder option for generating permission checks via InlineSQLHelper

Jan Tošovský, modificado hace 8 años.

Service Builder option for generating permission checks via InlineSQLHelper

Liferay Master Mensajes: 566 Fecha de incorporación: 22/07/10 Mensajes recientes
Dear All,

I'd like to let SB generate the following pattern in my persistence methods:
sql = InlineSQLHelperUtil.replacePermissionCheck(sql, MyEntity.class.getName(), "MyEntity.myEntityId", groupId);

My workaround now is to copy & paste generated code (several methods only) into my custom finder and adding this line manually.

I suppose there is some option as some portlets have something like this generated by default. Is it correct?

Thanks, Jan
thumbnail
David H Nebinger, modificado hace 8 años.

RE: Service Builder option for generating permission checks via InlineSQLHe

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Sort of.

SB actually generates code using freemarker templates. You can see the template for each page in com.liferay.portal.tools.servicebuilder.dependencies package.

I would copy the persistence_impl.ftl file and make your edit in there (be sure to use a unique name), and make sure it is in the class path for service builder when the script runs.

Then add the command line parameter "-Dservice.tpl.persistence_impl=package.path.to.your.file"

Any time you run service builder with this command, it will use your script and inject the code that you need.

Can take a little while to work out the details i.e. how do you modify the command to get this to work in the SDK or maven, how do you modify class path when SB is run so your template file is visible, etc., but this is the gist of the solution.

Note that this will not affect the Liferay IDE's handy build service icon in the service.xml editor.

Optionally you may just find it easier to create your own run command in the IDE to encapsulate all the details.