package eu.dnetlib.client;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

import eu.dnetlib.efg1914.authoring.components.Configuration;
import eu.dnetlib.efg1914.authoring.components.Frame;
import eu.dnetlib.efg1914.authoring.components.Item;
import eu.dnetlib.efg1914.authoring.components.Permit;
import eu.dnetlib.efg1914.authoring.components.Theme;
import eu.dnetlib.efg1914.authoring.components.Topic;
import eu.dnetlib.efg1914.authoring.managers.ComponentManagerException;
import eu.dnetlib.efg1914.authoring.managers.UserManagerException;
import eu.dnetlib.efg1914.authoring.users.User;
import eu.dnetlib.efg1914.commons.store.XMLStoreException;

/**
 * The client side stub for the RPC service.
 */
@RemoteServiceRelativePath("springGwtServices/greetingService")
public interface GreetingService extends RemoteService {
	/*
	 * ***************** ITEMS ********************
	 */

	public Item createNewItem(User user, Item itemToSave) throws XMLStoreException;

	public Item fetchItemMetadata(String url) throws XMLStoreException;
	public Item fetchIVideoMetadata(String url);
	/*
	 * creates a new Image item with the source id
	 */
	Item createNewImageItemFromID(User user, String url, String filetype, String mediaID) throws XMLStoreException;

	/*
	 * creates a new Video item with source the saved video with id mediaId
	 */
	Item createNewVideoItem(User user, String filetype, String url, String mediaId) throws XMLStoreException;

	/*
	 * Get all saved items
	 */
	ArrayList<Item> getAllItems() throws XMLStoreException;

	/*
	 * Get an item by ID
	 */

	Item getItemById(String itemId) throws XMLStoreException;

	/*
	 * Delete an item and its media files
	 */

	String deleteItem(Item item) throws XMLStoreException;

	/*
	 * Delete the media file with id mediaId
	 */
	String deleteMedia(String mediaId) throws XMLStoreException;

	/*
	 * update item and its mini/medium files if it's a video and have changed
	 */

	public Item updateItem(Item item, String miniId, String mediumId, String thumbFileType, boolean isThumbChanged) throws XMLStoreException;

	public Item updateItem(Item item) throws XMLStoreException;

	/**
	 * 
	 * @param itemId
	 * @return list of its parents-frame-ids
	 * @throws XMLStoreException
	 */
	public List<String> getItemParents(String itemId) throws XMLStoreException;

	/*
	 * ************** FRAMES *****************************
	 */
	String saveFrame(Frame frame) throws XMLStoreException;

	List<Frame> getAllFrames() throws XMLStoreException;

	Frame getFrameById(String frameId) throws XMLStoreException;

	String updateFrame(Frame frame) throws XMLStoreException;

	String deleteFrame(String frameId) throws XMLStoreException;

	/**
	 * 
	 * @param frameId
	 * @return list of its parents-topic-ids
	 * @throws XMLStoreException
	 */
	public List<String> getFrameParents(String frameId) throws XMLStoreException;

	/*
	 * ************** TOPICS *****************************
	 */

	Topic saveAndGetTopic(Topic topic) throws XMLStoreException;

	String updateTopic(Topic t) throws XMLStoreException;

	String deleteTopic(String topicId) throws XMLStoreException;

	/**
	 * 
	 * @param topicId
	 * @return list of its parents-theme-ids
	 * @throws XMLStoreException
	 */
	public List<String> getTopicParents(String topicId) throws XMLStoreException;

	/*
	 * ************** THEMES *****************************
	 */

	Theme saveTheme(Theme theme) throws XMLStoreException;

	String deleteTheme(Theme theme) throws XMLStoreException;

	String updateTheme(Theme theme) throws XMLStoreException;

	/*
	 * ************** ********* *****************************
	 */

	 String updateUser(User user) throws XMLStoreException;

	// @Deprecated
	void registerUser(User user) throws XMLStoreException;

	HashMap<String, Permit> loadPermissions(String username) throws XMLStoreException;

 
 	 
	public String saveUser(User user) throws UserManagerException;

	public User getUserById(String userId) throws UserManagerException;

	public void deleteUser(String userId) throws UserManagerException;

	/*
	 * Configuration
	 */

	public void updateConfiguration(Configuration configuration) throws ComponentManagerException;

	public Configuration getConfigurationByName(String name);
 
	public ArrayList<String> getRoleNames() throws UserManagerException;

	

}
