All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.cq.social.srp.internal.SocialDatabase Maven / Gradle / Ivy

There is a newer version: 6.5.21
Show newest version
/*************************************************************************
 *
 * ADOBE CONFIDENTIAL
 * __________________
 *
 *  Copyright 2012 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 **************************************************************************/
package com.adobe.cq.social.srp.internal;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.sling.api.resource.PersistenceException;

import aQute.bnd.annotation.ProviderType;

import com.adobe.cq.social.srp.APIResult;

/**
 * An interface to provide various api to communicate with underlying UGC database/store
 */
@ProviderType
public interface SocialDatabase {
    /**
     * @param key Key
     * @param unpackMap Map
     * @return an ugc data from underlying database matching the unique key
     * @throws IOException IOException
     */
    public Map readDocument(final String key, final boolean unpackMap) throws IOException;

    /**
     * @param keyName String
     * @param keyValue String
     * @param baseType String
     * @param maxResults int
     * @param page int
     * @param orderBy List
     * @param visibleOnly boolean
     * @return a list of ugc data from underlying database matching the input criteria
     *  @throws IOException IOException
     */
    public List> readDocuments(String keyName, String keyValue, String baseType, int maxResults,
        int page, List> orderBy, boolean visibleOnly) throws IOException;

    /**
     * @param keyName String
     * @param keyValue String
     * @param commentToCheck String
     * @param baseType String
     * @param visibleOnly boolean
     * @return index of current comment amongst all comments of a post
     */
    public int getCommentIndex(String keyName, String keyValue, String commentToCheck, String baseType, boolean visibleOnly);

    /**
     * Persist data to underlying database
     * @param origdata Map
     * @return Map
     * @throws PersistenceException PersistenceException
     */
    public Map createDocument(Map origdata) throws PersistenceException;

    /**
     * Delete record matching the key
     * @param key String
     * @return APIResult
     * @throws IOException IOException
     */
    public APIResult deleteDocument(String key) throws IOException;

    /**
     * Update the db record matching the given key
     * @param key String
     * @param origdata Map
     * @return Map
     * @throws PersistenceException PersistenceException
     */
    public Map updateDocument(String key, Map origdata) throws PersistenceException;

    /**
     * Read list of db record matching the given inputs
     * @param keyName String
     * @param keyValue String
     * @param baseType String
     * @param maxResults int
     * @param page int
     * @param orderBy List
     * @param visibleOnly boolean
     * @return List List
     * @throws IOException IOException
     */
    public List> readThread(String keyName, String keyValue, String baseType, int maxResults,
        int page, List> orderBy, boolean visibleOnly) throws IOException;

    /**
     * Persist the attachment/binary into underlying db layer
     * @param key String
     * @param attachment Map
     * @throws PersistenceException PersistenceException
     */
    public void addAttachment(String key, Map attachment) throws PersistenceException;

    /**
     * Retrieve the attachment/binary from the db
     * @param key String
     * @return InputStream
     * @throws IOException IOException
     */
    public InputStream getAttachmentInputStream(String key) throws IOException;

    /**
     * Read the attachment db record from underlying persistence layer
     * @param key String
     * @return Map
     * @throws IOException IOException
     */
    public Map readAttachment(String key) throws IOException;

    /**
     * Delete the attachment matching the given key
     * @param key String
     * @throws IOException IOException
     */
    public void deleteAttachment(String key) throws IOException;

    /**
     * Fetch the count of db record matching the given inputs
     * @param keyValues List
     * @param baseType String
     * @param visibleOnly boolean
     * @return Map
     */
    public Map countChildren(List keyValues, String baseType, boolean visibleOnly);

    /**
     * Retrieve all documents corresponding with the provided paths and add them, in order, to the docs list
     * @param paths List
     * @param docs List
     * @throws IOException IOException
     */
    public void batchRead(List paths, List> docs) throws IOException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy