001
014
015 package com.liferay.portal.service.impl;
016
017 import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
018 import com.liferay.portal.kernel.exception.PortalException;
019 import com.liferay.portal.kernel.exception.SystemException;
020 import com.liferay.portal.kernel.jsonwebservice.JSONWebService;
021 import com.liferay.portal.kernel.jsonwebservice.JSONWebServiceMode;
022 import com.liferay.portal.kernel.log.Log;
023 import com.liferay.portal.kernel.log.LogFactoryUtil;
024 import com.liferay.portal.kernel.messaging.DestinationNames;
025 import com.liferay.portal.kernel.messaging.Message;
026 import com.liferay.portal.kernel.messaging.sender.DirectSynchronousMessageSender;
027 import com.liferay.portal.kernel.messaging.sender.SynchronousMessageSender;
028 import com.liferay.portal.kernel.util.PropsKeys;
029 import com.liferay.portal.kernel.util.ReleaseInfo;
030 import com.liferay.portal.model.ClassName;
031 import com.liferay.portal.service.PortalService;
032 import com.liferay.portal.service.base.PortalServiceBaseImpl;
033 import com.liferay.portal.util.PrefsPropsUtil;
034 import com.liferay.portal.util.PropsValues;
035
036
039 @JSONWebService(mode = JSONWebServiceMode.MANUAL)
040 public class PortalServiceImpl extends PortalServiceBaseImpl {
041
042 @Override
043 public String getAutoDeployDirectory() throws SystemException {
044 return PrefsPropsUtil.getString(
045 PropsKeys.AUTO_DEPLOY_DEPLOY_DIR,
046 PropsValues.AUTO_DEPLOY_DEPLOY_DIR);
047 }
048
049 @JSONWebService
050 @Override
051 public int getBuildNumber() {
052 return ReleaseInfo.getBuildNumber();
053 }
054
055 @Override
056 public void testAddClassName_Rollback(String classNameValue)
057 throws SystemException {
058
059 addClassName(classNameValue);
060
061 throw new SystemException();
062 }
063
064 @Override
065 public void testAddClassName_Success(String classNameValue)
066 throws SystemException {
067
068 addClassName(classNameValue);
069 }
070
071 @Override
072 public void testAddClassNameAndTestTransactionPortletBar_PortalRollback(
073 String transactionPortletBarText)
074 throws SystemException {
075
076 addClassName(PortalService.class.getName());
077
078 addTransactionPortletBar(transactionPortletBarText, false);
079
080 throw new SystemException();
081 }
082
083 @Override
084 public void testAddClassNameAndTestTransactionPortletBar_PortletRollback(
085 String transactionPortletBarText)
086 throws SystemException {
087
088 addClassName(PortalService.class.getName());
089
090 addTransactionPortletBar(transactionPortletBarText, true);
091 }
092
093 @Override
094 public void testAddClassNameAndTestTransactionPortletBar_Success(
095 String transactionPortletBarText)
096 throws SystemException {
097
098 addClassName(PortalService.class.getName());
099
100 addTransactionPortletBar(transactionPortletBarText, false);
101 }
102
103 @Override
104 public void testDeleteClassName() throws PortalException, SystemException {
105 classNamePersistence.removeByValue(PortalService.class.getName());
106 }
107
108 @Override
109 public int testGetBuildNumber() {
110 return portalService.getBuildNumber();
111 }
112
113 @Override
114 public void testGetUserId() {
115 long userId = 0;
116
117 try {
118 userId = getUserId();
119 }
120 catch (Exception e) {
121 _log.error(e, e);
122 }
123
124 if (_log.isInfoEnabled()) {
125 _log.info("User id " + userId);
126 }
127 }
128
129 @Override
130 public boolean testHasClassName() throws SystemException {
131 int count = classNamePersistence.countByValue(
132 PortalService.class.getName());
133
134 if (count > 0) {
135 return true;
136 }
137 else {
138 return false;
139 }
140 }
141
142 protected void addClassName(String classNameValue) throws SystemException {
143 long classNameId = counterLocalService.increment();
144
145 ClassName className = classNamePersistence.create(classNameId);
146
147 className.setValue(classNameValue);
148
149 classNamePersistence.update(className, false);
150 }
151
152 protected void addTransactionPortletBar(
153 String transactionPortletBarText, boolean rollback)
154 throws SystemException {
155
156 try {
157 Message message = new Message();
158
159 message.put("rollback", rollback);
160 message.put("text", transactionPortletBarText);
161
162 SynchronousMessageSender synchronousMessageSender =
163 (SynchronousMessageSender)PortalBeanLocatorUtil.locate(
164 DirectSynchronousMessageSender.class.getName());
165
166 synchronousMessageSender.send(
167 DestinationNames.TEST_TRANSACTION, message);
168 }
169 catch (Exception e) {
170 throw new SystemException(e);
171 }
172 }
173
174 private static Log _log = LogFactoryUtil.getLog(PortalServiceImpl.class);
175
176 }