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

org.eclipse.dirigible.repository.local.LocalFolder Maven / Gradle / Ivy

/**
 * Copyright (c) 2010-2018 SAP and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   SAP - initial API and implementation
 */
package org.eclipse.dirigible.repository.local;

import java.util.List;

import org.eclipse.dirigible.repository.api.RepositoryPath;
import org.eclipse.dirigible.repository.fs.FileSystemRepository;

/**
 * Internal representation of a Folder/Collection kind of object.
 */
public class LocalFolder extends LocalObject {

	/**
	 * Instantiates a new local folder.
	 *
	 * @param repository
	 *            the repository
	 */
	public LocalFolder(FileSystemRepository repository) {
		super(repository);
	}

	/**
	 * Delete tree.
	 *
	 * @throws LocalRepositoryException
	 *             the local repository exception
	 */
	public void deleteTree() throws LocalRepositoryException {
		getRepository().getRepositoryDao().removeFolderByPath(getPath());
	}

	/**
	 * Gets the children.
	 *
	 * @return the children
	 * @throws LocalRepositoryException
	 *             the local repository exception
	 */
	public List getChildren() throws LocalRepositoryException {
		List result = getRepository().getRepositoryDao().getChildrenByFolder(getPath());
		return result;
	}

	/**
	 * Creates the folder.
	 *
	 * @param name
	 *            the name
	 * @throws LocalRepositoryException
	 *             the local repository exception
	 */
	public void createFolder(String name) throws LocalRepositoryException {
		getRepository().getRepositoryDao().createFolder(RepositoryPath.normalizePath(getPath(), name));
	}

	/**
	 * Creates the file.
	 *
	 * @param name
	 *            the name
	 * @param content
	 *            the content
	 * @param isBinary
	 *            the is binary
	 * @param contentType
	 *            the content type
	 * @throws LocalRepositoryException
	 *             the local repository exception
	 */
	public void createFile(String name, byte[] content, boolean isBinary, String contentType) throws LocalRepositoryException {
		getRepository().getRepositoryDao().createFile(RepositoryPath.normalizePath(getPath(), name), content, isBinary, contentType);
	}

	/**
	 * Rename folder.
	 *
	 * @param newPath
	 *            the new path
	 * @throws LocalRepositoryException
	 *             the local repository exception
	 */
	public void renameFolder(String newPath) throws LocalRepositoryException {
		getRepository().getRepositoryDao().renameFolder(getPath(), newPath);
	}

	/**
	 * Copy folder.
	 *
	 * @param newPath
	 *            the new path
	 * @throws LocalRepositoryException
	 *             the local repository exception
	 */
	public void copyFolder(String newPath) throws LocalRepositoryException {
		getRepository().getRepositoryDao().copyFolder(getPath(), newPath);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy