com.liferay.mobile.android.v7.assetvocabulary.AssetVocabularyService.java Source code

Java tutorial

Introduction

Here is the source code for com.liferay.mobile.android.v7.assetvocabulary.AssetVocabularyService.java

Source

/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.liferay.mobile.android.v7.assetvocabulary;

import com.liferay.mobile.android.http.file.UploadData;
import com.liferay.mobile.android.service.BaseService;
import com.liferay.mobile.android.service.JSONObjectWrapper;
import com.liferay.mobile.android.service.Session;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author Bruno Farache
 */
public class AssetVocabularyService extends BaseService {

    public AssetVocabularyService(Session session) {
        super(session);
    }

    public JSONObject addVocabulary(long groupId, String title, JSONObjectWrapper serviceContext) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupId", groupId);
            _params.put("title", checkNull(title));
            mangleWrapper(_params, "serviceContext", "com.liferay.portal.kernel.service.ServiceContext",
                    serviceContext);

            _command.put("/assetvocabulary/add-vocabulary", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONObject(0);
    }

    public JSONObject addVocabulary(long groupId, String title, JSONObject titleMap, JSONObject descriptionMap,
            String settings, JSONObjectWrapper serviceContext) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupId", groupId);
            _params.put("title", checkNull(title));
            _params.put("titleMap", checkNull(titleMap));
            _params.put("descriptionMap", checkNull(descriptionMap));
            _params.put("settings", checkNull(settings));
            mangleWrapper(_params, "serviceContext", "com.liferay.portal.kernel.service.ServiceContext",
                    serviceContext);

            _command.put("/assetvocabulary/add-vocabulary", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONObject(0);
    }

    public JSONArray deleteVocabularies(JSONArray vocabularyIds, JSONObjectWrapper serviceContext)
            throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("vocabularyIds", checkNull(vocabularyIds));
            mangleWrapper(_params, "serviceContext", "com.liferay.portal.kernel.service.ServiceContext",
                    serviceContext);

            _command.put("/assetvocabulary/delete-vocabularies", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONArray(0);
    }

    public void deleteVocabulary(long vocabularyId) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("vocabularyId", vocabularyId);

            _command.put("/assetvocabulary/delete-vocabulary", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        session.invoke(_command);
    }

    public JSONArray getCompanyVocabularies(long companyId) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("companyId", companyId);

            _command.put("/assetvocabulary/get-company-vocabularies", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONArray(0);
    }

    public JSONArray getGroupsVocabularies(JSONArray groupIds, String className) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupIds", checkNull(groupIds));
            _params.put("className", checkNull(className));

            _command.put("/assetvocabulary/get-groups-vocabularies", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONArray(0);
    }

    public JSONArray getGroupsVocabularies(JSONArray groupIds) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupIds", checkNull(groupIds));

            _command.put("/assetvocabulary/get-groups-vocabularies", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONArray(0);
    }

    public JSONArray getGroupsVocabularies(JSONArray groupIds, String className, long classTypePK)
            throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupIds", checkNull(groupIds));
            _params.put("className", checkNull(className));
            _params.put("classTypePK", classTypePK);

            _command.put("/assetvocabulary/get-groups-vocabularies", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONArray(0);
    }

    public JSONArray getGroupVocabularies(long groupId, boolean createDefaultVocabulary, int start, int end,
            JSONObjectWrapper obc) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupId", groupId);
            _params.put("createDefaultVocabulary", createDefaultVocabulary);
            _params.put("start", start);
            _params.put("end", end);
            mangleWrapper(_params, "obc",
                    "com.liferay.portal.kernel.util.OrderByComparator<com.liferay.asset.kernel.model.AssetVocabulary>",
                    obc);

            _command.put("/assetvocabulary/get-group-vocabularies", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONArray(0);
    }

    public JSONArray getGroupVocabularies(long groupId, int start, int end, JSONObjectWrapper obc)
            throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupId", groupId);
            _params.put("start", start);
            _params.put("end", end);
            mangleWrapper(_params, "obc",
                    "com.liferay.portal.kernel.util.OrderByComparator<com.liferay.asset.kernel.model.AssetVocabulary>",
                    obc);

            _command.put("/assetvocabulary/get-group-vocabularies", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONArray(0);
    }

    public JSONArray getGroupVocabularies(long groupId, String name, int start, int end, JSONObjectWrapper obc)
            throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupId", groupId);
            _params.put("name", checkNull(name));
            _params.put("start", start);
            _params.put("end", end);
            mangleWrapper(_params, "obc",
                    "com.liferay.portal.kernel.util.OrderByComparator<com.liferay.asset.kernel.model.AssetVocabulary>",
                    obc);

            _command.put("/assetvocabulary/get-group-vocabularies", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONArray(0);
    }

    public JSONArray getGroupVocabularies(JSONArray groupIds) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupIds", checkNull(groupIds));

            _command.put("/assetvocabulary/get-group-vocabularies", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONArray(0);
    }

    public JSONArray getGroupVocabularies(long groupId, boolean createDefaultVocabulary) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupId", groupId);
            _params.put("createDefaultVocabulary", createDefaultVocabulary);

            _command.put("/assetvocabulary/get-group-vocabularies", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONArray(0);
    }

    public JSONArray getGroupVocabularies(long groupId) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupId", groupId);

            _command.put("/assetvocabulary/get-group-vocabularies", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONArray(0);
    }

    public Integer getGroupVocabulariesCount(long groupId, String name) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupId", groupId);
            _params.put("name", checkNull(name));

            _command.put("/assetvocabulary/get-group-vocabularies-count", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getInt(0);
    }

    public Integer getGroupVocabulariesCount(JSONArray groupIds) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupIds", checkNull(groupIds));

            _command.put("/assetvocabulary/get-group-vocabularies-count", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getInt(0);
    }

    public Integer getGroupVocabulariesCount(long groupId) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupId", groupId);

            _command.put("/assetvocabulary/get-group-vocabularies-count", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getInt(0);
    }

    public JSONArray getVocabularies(JSONArray vocabularyIds) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("vocabularyIds", checkNull(vocabularyIds));

            _command.put("/assetvocabulary/get-vocabularies", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONArray(0);
    }

    public JSONObject updateVocabulary(long vocabularyId, String title, JSONObject titleMap,
            JSONObject descriptionMap, String settings, JSONObjectWrapper serviceContext) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("vocabularyId", vocabularyId);
            _params.put("title", checkNull(title));
            _params.put("titleMap", checkNull(titleMap));
            _params.put("descriptionMap", checkNull(descriptionMap));
            _params.put("settings", checkNull(settings));
            mangleWrapper(_params, "serviceContext", "com.liferay.portal.kernel.service.ServiceContext",
                    serviceContext);

            _command.put("/assetvocabulary/update-vocabulary", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONObject(0);
    }

    public JSONObject fetchVocabulary(long vocabularyId) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("vocabularyId", vocabularyId);

            _command.put("/assetvocabulary/fetch-vocabulary", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONObject(0);
    }

    public JSONObject searchVocabulariesDisplay(long groupId, String title, boolean addDefaultVocabulary, int start,
            int end, JSONObjectWrapper sort) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupId", groupId);
            _params.put("title", checkNull(title));
            _params.put("addDefaultVocabulary", addDefaultVocabulary);
            _params.put("start", start);
            _params.put("end", end);
            mangleWrapper(_params, "sort", "com.liferay.portal.kernel.search.Sort", sort);

            _command.put("/assetvocabulary/search-vocabularies-display", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONObject(0);
    }

    public JSONObject searchVocabulariesDisplay(long groupId, String title, boolean addDefaultVocabulary, int start,
            int end) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupId", groupId);
            _params.put("title", checkNull(title));
            _params.put("addDefaultVocabulary", addDefaultVocabulary);
            _params.put("start", start);
            _params.put("end", end);

            _command.put("/assetvocabulary/search-vocabularies-display", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONObject(0);
    }

    public JSONObject getGroupVocabulariesDisplay(long groupId, String name, int start, int end,
            JSONObjectWrapper obc) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupId", groupId);
            _params.put("name", checkNull(name));
            _params.put("start", start);
            _params.put("end", end);
            mangleWrapper(_params, "obc",
                    "com.liferay.portal.kernel.util.OrderByComparator<com.liferay.asset.kernel.model.AssetVocabulary>",
                    obc);

            _command.put("/assetvocabulary/get-group-vocabularies-display", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONObject(0);
    }

    public JSONObject getGroupVocabulariesDisplay(long groupId, String name, int start, int end,
            boolean addDefaultVocabulary, JSONObjectWrapper obc) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("groupId", groupId);
            _params.put("name", checkNull(name));
            _params.put("start", start);
            _params.put("end", end);
            _params.put("addDefaultVocabulary", addDefaultVocabulary);
            mangleWrapper(_params, "obc",
                    "com.liferay.portal.kernel.util.OrderByComparator<com.liferay.asset.kernel.model.AssetVocabulary>",
                    obc);

            _command.put("/assetvocabulary/get-group-vocabularies-display", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONObject(0);
    }

    public JSONObject getVocabulary(long vocabularyId) throws Exception {
        JSONObject _command = new JSONObject();

        try {
            JSONObject _params = new JSONObject();

            _params.put("vocabularyId", vocabularyId);

            _command.put("/assetvocabulary/get-vocabulary", _params);
        } catch (JSONException _je) {
            throw new Exception(_je);
        }

        JSONArray _result = session.invoke(_command);

        if (_result == null) {
            return null;
        }

        return _result.getJSONObject(0);
    }

}