Search in sources :

Example 11 with JSONObject

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);
    }
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject) Address(org.apache.shindig.social.opensocial.model.Address) AddressImpl(org.apache.shindig.social.core.model.AddressImpl)

Example 12 with JSONObject

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());
}
Also used : TasksEntry(com.liferay.tasks.model.TasksEntry) JSONObject(com.liferay.portal.kernel.json.JSONObject)

Example 13 with JSONObject

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;
}
Also used : TasksEntry(com.liferay.tasks.model.TasksEntry) User(com.liferay.portal.model.User) JSONObject(com.liferay.portal.kernel.json.JSONObject) TasksEntryDueDateException(com.liferay.tasks.TasksEntryDueDateException) Date(java.util.Date)

Example 14 with JSONObject

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;
}
Also used : DefaultPollerResponse(com.liferay.portal.kernel.poller.DefaultPollerResponse) JSONObject(com.liferay.portal.kernel.json.JSONObject) DefaultPollerResponse(com.liferay.portal.kernel.poller.DefaultPollerResponse) PollerResponse(com.liferay.portal.kernel.poller.PollerResponse) Date(java.util.Date)

Example 15 with JSONObject

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());
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) JSONObject(com.liferay.portal.kernel.json.JSONObject) JSONArray(com.liferay.portal.kernel.json.JSONArray)

Aggregations

JSONObject (com.liferay.portal.kernel.json.JSONObject)54 JSONArray (com.liferay.portal.kernel.json.JSONArray)13 IOException (java.io.IOException)10 TException (org.apache.thrift.TException)9 PrintWriter (java.io.PrintWriter)7 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)5 ServiceContext (com.liferay.portal.service.ServiceContext)5 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)5 PortalException (com.liferay.portal.kernel.exception.PortalException)4 JSONException (com.liferay.portal.kernel.json.JSONException)4 Folder (com.liferay.portal.kernel.repository.model.Folder)4 Date (java.util.Date)4 CveSearchService (org.eclipse.sw360.datahandler.thrift.cvesearch.CveSearchService)4 VulnerabilityUpdateStatus (org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus)4 User (org.eclipse.sw360.datahandler.thrift.users.User)4 JSONFactoryUtil.createJSONObject (com.liferay.portal.kernel.json.JSONFactoryUtil.createJSONObject)3 Role (com.liferay.portal.kernel.model.Role)3 User (com.liferay.portal.kernel.model.User)3 UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)3 User (com.liferay.portal.model.User)3