Foros de discusión
Web Content - Tags Issue
dave ch, modificado hace 11 años.
Web Content - Tags Issue
Regular Member Mensajes: 161 Fecha de incorporación: 7/02/12 Mensajes recientes
Hi all,
I am publishing my content using Web Content portlet from Control Panel. While publishing I am also adding Tags from Categorization Option which is on the right hand side(Web content --> Select a web content --> Categorization Option on right hand side). Now when I am adding Tags, Tags should keep as is they entered. I want to Prevent them converted into lowercase.
When the Tags are displaying in the Asset Publisher portlet they are in Lower Case. I want to Prevent them converted into lowercase. How should I achieve this?
Any help will be appreciated.
Thanks
Dave
I am publishing my content using Web Content portlet from Control Panel. While publishing I am also adding Tags from Categorization Option which is on the right hand side(Web content --> Select a web content --> Categorization Option on right hand side). Now when I am adding Tags, Tags should keep as is they entered. I want to Prevent them converted into lowercase.
When the Tags are displaying in the Asset Publisher portlet they are in Lower Case. I want to Prevent them converted into lowercase. How should I achieve this?
Any help will be appreciated.
Thanks
Dave
Samuel Kong, modificado hace 11 años.
RE: Web Content - Tags Issue
Liferay Legend Mensajes: 1902 Fecha de incorporación: 10/03/08 Mensajes recientes
Take a look at the Overriding a Portal Service section of the Development Guide. You'll need to create a hook to override AssetTagLocalService since the all lowercase version is stored in the database. (disclaimer: this might cause some things to break. I'm not sure)
dave ch, modificado hace 11 años.
RE: Web Content - Tags Issue
Regular Member Mensajes: 161 Fecha de incorporación: 7/02/12 Mensajes recientes
Hi Samuel ,
Thanks for the quick reply.
I just want to know what are all the methods i need to override to keep the tags, as is they entered. I want to Prevent them converted into lowercase.
Any help will be appriciated.
Thanks
dave
Thanks for the quick reply.
I just want to know what are all the methods i need to override to keep the tags, as is they entered. I want to Prevent them converted into lowercase.
Any help will be appriciated.
Thanks
dave
Hitoshi Ozawa, modificado hace 11 años.
RE: Web Content - Tags Issue
Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
Look at
\portal-impl\src\com\liferay\portlet\asset\service\impl\AssetTagLocalServiceImpl.java
There are two rows with the following statement:
name = name.toLowerCase();
\portal-impl\src\com\liferay\portlet\asset\service\impl\AssetTagLocalServiceImpl.java
There are two rows with the following statement:
name = name.toLowerCase();
dave ch, modificado hace 11 años.
RE: Web Content - Tags Issue
Regular Member Mensajes: 161 Fecha de incorporación: 7/02/12 Mensajes recientes
Hi Hitoshi,
So I need to use Ext instead of Hook to override AssetTagLocalServiceImpl.java. , if i am not wrong.
Thanks,
dave
So I need to use Ext instead of Hook to override AssetTagLocalServiceImpl.java. , if i am not wrong.
Thanks,
dave
Samuel Kong, modificado hace 11 años.
RE: Web Content - Tags Issue
Liferay Legend Mensajes: 1902 Fecha de incorporación: 10/03/08 Mensajes recientes
No, Use a hook instead. You should generally avoid using an ext-plugin unless you have no other choices.
dave ch, modificado hace 11 años.
RE: Web Content - Tags Issue
Regular Member Mensajes: 161 Fecha de incorporación: 7/02/12 Mensajes recientesSamuel Kong]No, Use a hook instead. You should generally avoid using an ext-plugin unless you have no other choices.
Hi Samuel,
I tried to override AssetTagLocalServiceImpl.java class using hook, but i was unsuccessful.
I have created a Test-hook and tried to override this by writting the below code in liferay-hook.xml
<service>
<service-type>com.liferay.portlet.asset.service.AssetTagLocalService</service-type>
<service-impl>com.liferay.sample.hook.MyAssetTagLocalServiceImpl</service-impl>
</service>
and end with getting some exceptions. Seems to be it is not possible to override this class using hook.
Regards
Dave
dave ch, modificado hace 11 años.
RE: Web Content - Tags Issue
Regular Member Mensajes: 161 Fecha de incorporación: 7/02/12 Mensajes recientes
The exception i am getting is:
10:10:50,728 ERROR [pool-2-thread-4][HotDeployImpl:191] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering hook for servicehook-hook
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering hook for servicehook-hook
at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:46)
at com.liferay.portal.deploy.hot.HookHotDeployListener.invokeDeploy(HookHotDeployListener.java:276)
at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:188)
at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:96)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:27)
at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:151)
at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(PluginContextListener.java:141)
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:42)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:64)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:56)
at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:52)
at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(PluginContextListener.java:103)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1099)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1621)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: com.liferay.portlet.asset.service.impl.AssetTagLocalServiceImpl
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
at com.liferay.portal.deploy.hot.HookHotDeployListener.doInvokeDeploy(HookHotDeployListener.java:601)
at com.liferay.portal.deploy.hot.HookHotDeployListener.invokeDeploy(HookHotDeployListener.java:273)
... 24 more
Samuel Kong, modificado hace 11 años.
RE: Web Content - Tags Issue
Liferay Legend Mensajes: 1902 Fecha de incorporación: 10/03/08 Mensajes recientes
I just tested using 6.1.1 and a hook will work. You probably have something not configured correctly in your hook. Check out https://github.com/liferay/liferay-plugins/tree/6.1.x/portlets/test-hook-portlet for a working example.
dave ch, modificado hace 11 años.
RE: Web Content - Tags Issue
Regular Member Mensajes: 161 Fecha de incorporación: 7/02/12 Mensajes recientes
Hi Samuel,
This is the method i want to override using hook of AssetTagLocalServiceImpl :
But, then from where do i get the instance variables like: userPersistence, counterLocalService, assetTagPersistence, assetTagPersistence.
Kindly suggest.
Thanks,
Dave
This is the method i want to override using hook of AssetTagLocalServiceImpl :
public AssetTag addTag(
long userId, String name, String[] tagProperties,
ServiceContext serviceContext)
throws PortalException, SystemException {
// Tag
User user = userPersistence.findByPrimaryKey(userId);
long groupId = serviceContext.getScopeGroupId();
if (tagProperties == null) {
tagProperties = new String[0];
}
Date now = new Date();
long tagId = counterLocalService.increment();
AssetTag tag = assetTagPersistence.create(tagId);
tag.setGroupId(groupId);
tag.setCompanyId(user.getCompanyId());
tag.setUserId(user.getUserId());
tag.setUserName(user.getFullName());
tag.setCreateDate(now);
tag.setModifiedDate(now);
name = name.trim();
name = name.toLowerCase();
if (hasTag(groupId, name)) {
throw new DuplicateTagException(
"A tag with the name " + name + " already exists");
}
validate(name);
tag.setName(name);
assetTagPersistence.update(tag, false);
// Resources
if (serviceContext.isAddGroupPermissions() ||
serviceContext.isAddGuestPermissions()) {
addTagResources(
tag, serviceContext.isAddGroupPermissions(),
serviceContext.isAddGuestPermissions());
}
else {
addTagResources(
tag, serviceContext.getGroupPermissions(),
serviceContext.getGuestPermissions());
}
// Properties
for (int i = 0; i < tagProperties.length; i++) {
String[] tagProperty = StringUtil.split(
tagProperties[i], CharPool.COLON);
String key = StringPool.BLANK;
if (tagProperty.length > 0) {
key = GetterUtil.getString(tagProperty[0]);
}
String value = StringPool.BLANK;
if (tagProperty.length > 1) {
value = GetterUtil.getString(tagProperty[1]);
}
if (Validator.isNotNull(key)) {
assetTagPropertyLocalService.addTagProperty(
userId, tagId, key, value);
}
}
return tag;
}
But, then from where do i get the instance variables like: userPersistence, counterLocalService, assetTagPersistence, assetTagPersistence.
Kindly suggest.
Thanks,
Dave
dave ch, modificado hace 11 años.
RE: Web Content - Tags Issue (Respuesta)
Regular Member Mensajes: 161 Fecha de incorporación: 7/02/12 Mensajes recientes
Hi,
Finally got the solution by changing these injected variables:
userPersistence---to--- UserLocalServiceUtil
counterLocalService---to--- CounterLocalServiceUtil
assetTagPersistence---to--- AssetTagLocalServiceUtil
assetTagPropertyLocalService---to---AssetTagPropertyLocalServiceUtil
assetEntryLocalService---to---AssetEntryLocalServiceUtil
Regards
Dave
Finally got the solution by changing these injected variables:
userPersistence---to--- UserLocalServiceUtil
counterLocalService---to--- CounterLocalServiceUtil
assetTagPersistence---to--- AssetTagLocalServiceUtil
assetTagPropertyLocalService---to---AssetTagPropertyLocalServiceUtil
assetEntryLocalService---to---AssetEntryLocalServiceUtil
Regards
Dave