use of com.liferay.portal.kernel.json.JSONObject in project liferay-ide by liferay.
the class SerializerUtil method setBeanProperty.
protected static void setBeanProperty(Object bean, String fieldName, String value) throws JSONException {
if (Validator.isNull(value)) {
return;
}
if (fieldName.equals("location")) {
JSONObject jsonObject = JSONFactoryUtil.createJSONObject(value);
Address address = new AddressImpl();
copyProperties(jsonObject, address, _ADDRESS_FIELDS);
BeanPropertiesUtil.setProperty(bean, fieldName, address);
} else {
BeanPropertiesUtil.setProperty(bean, fieldName, value);
}
}
use of com.liferay.portal.kernel.json.JSONObject in project liferay-ide by liferay.
the class TasksEntryLocalServiceImpl method addSocialActivity.
protected void addSocialActivity(int status, TasksEntry tasksEntry, ServiceContext serviceContext) throws PortalException, SystemException {
int activity = TasksActivityKeys.UPDATE_ENTRY;
if (status == TasksEntryConstants.STATUS_REOPENED) {
activity = TasksActivityKeys.REOPEN_ENTRY;
} else if (status == TasksEntryConstants.STATUS_RESOLVED) {
activity = TasksActivityKeys.RESOLVE_ENTRY;
}
JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();
extraDataJSONObject.put("title", tasksEntry.getTitle());
SocialActivityLocalServiceUtil.addActivity(serviceContext.getUserId(), tasksEntry.getGroupId(), TasksEntry.class.getName(), tasksEntry.getTasksEntryId(), activity, extraDataJSONObject.toString(), tasksEntry.getAssigneeUserId());
}
use of com.liferay.portal.kernel.json.JSONObject in project liferay-ide by liferay.
the class TasksEntryLocalServiceImpl method addTasksEntry.
public TasksEntry addTasksEntry(long userId, String title, int priority, long assigneeUserId, int dueDateMonth, int dueDateDay, int dueDateYear, int dueDateHour, int dueDateMinute, boolean addDueDate, ServiceContext serviceContext) throws PortalException, SystemException {
// Tasks entry
User user = UserLocalServiceUtil.getUserById(userId);
long groupId = serviceContext.getScopeGroupId();
Date now = new Date();
validate(title);
Date dueDate = null;
if (addDueDate) {
dueDate = PortalUtil.getDate(dueDateMonth, dueDateDay, dueDateYear, dueDateHour, dueDateMinute, user.getTimeZone(), TasksEntryDueDateException.class);
}
long tasksEntryId = CounterLocalServiceUtil.increment();
TasksEntry tasksEntry = tasksEntryPersistence.create(tasksEntryId);
tasksEntry.setGroupId(groupId);
tasksEntry.setCompanyId(user.getCompanyId());
tasksEntry.setUserId(user.getUserId());
tasksEntry.setUserName(user.getFullName());
tasksEntry.setCreateDate(now);
tasksEntry.setModifiedDate(now);
tasksEntry.setTitle(title);
tasksEntry.setPriority(priority);
tasksEntry.setAssigneeUserId(assigneeUserId);
tasksEntry.setDueDate(dueDate);
tasksEntry.setStatus(TasksEntryConstants.STATUS_OPEN);
tasksEntryPersistence.update(tasksEntry);
// Resources
resourceLocalService.addModelResources(tasksEntry, serviceContext);
// Asset
updateAsset(userId, tasksEntry, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames());
// Social
JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();
extraDataJSONObject.put("title", tasksEntry.getTitle());
SocialActivityLocalServiceUtil.addActivity(userId, groupId, TasksEntry.class.getName(), tasksEntryId, TasksActivityKeys.ADD_ENTRY, extraDataJSONObject.toString(), assigneeUserId);
// Notifications
sendNotificationEvent(tasksEntry, TasksEntryConstants.STATUS_ALL, assigneeUserId, serviceContext);
return tasksEntry;
}
use of com.liferay.portal.kernel.json.JSONObject in project liferay-blade-samples by liferay.
the class BladePollProcessor method doReceive.
@Override
protected PollerResponse doReceive(PollerRequest pollerRequest) throws Exception {
_log.log(LogService.LOG_INFO, "Recevied the poller request" + pollerRequest);
JSONObject responseObject = JSONFactoryUtil.createJSONObject();
PollerResponse pollerResponse = new DefaultPollerResponse();
responseObject.put("message", "Hello from BLADE Poller, time now is:" + new Date());
pollerResponse.setParameter("content", responseObject);
return pollerResponse;
}
use of com.liferay.portal.kernel.json.JSONObject in project sw360portal by sw360.
the class ProjectImportPortlet method updateImportables.
private void updateImportables(JSONObject responseData, LoginState loginState, RemoteCredentials remoteCredentials, String projectName) throws JsonProcessingException {
if (!nullToEmpty(remoteCredentials.getServerUrl()).isEmpty()) {
List<Project> importables = loadImportables(remoteCredentials, projectName);
JSONArray serializedProjects = JSONFactoryUtil.createJSONArray();
for (Project p : importables) {
JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
if (p.isSetExternalIds() && !isNullOrEmpty(p.getExternalIds().get(getIdName())))
jsonObject.put("externalId", p.getExternalIds().get(getIdName()));
jsonObject.put("name", p.getName());
serializedProjects.put(jsonObject.toString());
}
responseData.put(ProjectImportConstants.RESPONSE__NEW_IMPORTABLES, serializedProjects);
}
responseData.put(ProjectImportConstants.RESPONSE__DB_URL, remoteCredentials.getServerUrl());
loginState.login(remoteCredentials.getServerUrl());
}
Aggregations