io.personium.client.ExtCellManager.java Source code

Java tutorial

Introduction

Here is the source code for io.personium.client.ExtCellManager.java

Source

/**
 * Personium
 * Copyright 2014 - 2017 FUJITSU LIMITED
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.personium.client;

import java.util.HashMap;

import org.json.simple.JSONObject;

///**
// * ExtCell?CRUD????.
// */
/**
 * It creates a new object of ExtCellManager. This class performs CRUD operations for External Cell.
 */
public class ExtCellManager extends ODataManager {

    /**
     * This is the parameterized constructor with one argument calling its parent constructor internally.
     * @param as Accessor
     */
    public ExtCellManager(Accessor as) {
        super(as);
    }

    /**
     * This method generates and returns the URL for ExtCell.
     * @return URL value
     */
    @Override
    public String getUrl() {
        StringBuilder sb = new StringBuilder(accessor.getCurrentCell().getUrl());
        sb.append("__ctl/ExtCell");
        return sb.toString();
    }

    // /**
    // * ExtCell?.
    // * @param obj ExtCell
    // * @return ExtCell
    // * @throws DaoException DAO
    // */
    /**
     * This method is used to create an ExtCell using an ExtCell object.
     * @param obj ExtCell object
     * @return ExtCell object that is created
     * @throws DaoException Exception thrown
     */
    @SuppressWarnings("unchecked")
    public ExtCell create(ExtCell obj) throws DaoException {
        JSONObject body = new JSONObject();
        body.put("Url", obj.getUrl());
        JSONObject json = internalCreate(body);
        obj.initialize(this.accessor, json);
        return obj;
    }

    // /**
    // * ExtCell?.
    // * @param body 
    // * @return ???ExtCell
    // * @throws DaoException DAO
    // */
    /**
     * This method is used to create an ExtCell using Requset Body.
     * @param body Request Body
     * @return ExtCell object that is created
     * @throws DaoException Exception thrown
     */
    public ExtCell create(HashMap<String, Object> body) throws DaoException {
        JSONObject json = (JSONObject) internalCreate(body);
        return new ExtCell(accessor, json);
    }

    // /**
    // * ExtCell?.
    // * @param roleId ??RoleId
    // * @return ?????ExtCell
    // * @throws DaoException DAO
    // */
    /**
     * This method is used to fetch the specified ExtCell.
     * @param roleId Role ID
     * @return ExtCell object
     * @throws DaoException Exception thrown
     */
    public ExtCell retrieve(String roleId) throws DaoException {
        JSONObject json = internalRetrieve(roleId);
        return new ExtCell(accessor, json);
    }
}