Search in sources :

Example 36 with PropertyMap

use of org.structr.core.property.PropertyMap in project structr by structr.

the class GeoTest method createTestNode.

protected <T extends AbstractNode> T createTestNode(final Class<T> type, final String name) throws FrameworkException {
    final PropertyMap map = new PropertyMap();
    map.put(AbstractNode.name, name);
    return (T) createTestNode(type, map);
}
Also used : PropertyMap(org.structr.core.property.PropertyMap)

Example 37 with PropertyMap

use of org.structr.core.property.PropertyMap in project structr by structr.

the class SSHTest method createFTPFile.

protected File createFTPFile(final String path, final String name) throws FrameworkException {
    PropertyMap props = new PropertyMap();
    props.put(StructrApp.key(File.class, "name"), name);
    props.put(StructrApp.key(File.class, "size"), 0L);
    props.put(StructrApp.key(File.class, "owner"), ftpUser);
    File file = (File) createTestNodes(File.class, 1, props).get(0);
    if (StringUtils.isNotBlank(path)) {
        AbstractFile parent = FileHelper.getFileByAbsolutePath(securityContext, path);
        if (parent != null && parent instanceof Folder) {
            Folder parentFolder = (Folder) parent;
            file.setParent(parentFolder);
        }
    }
    logger.info("FTP file {} created successfully.", file);
    return file;
}
Also used : PropertyMap(org.structr.core.property.PropertyMap) AbstractFile(org.structr.web.entity.AbstractFile) Folder(org.structr.web.entity.Folder) AbstractFile(org.structr.web.entity.AbstractFile) File(org.structr.web.entity.File) FTPFile(org.apache.commons.net.ftp.FTPFile)

Example 38 with PropertyMap

use of org.structr.core.property.PropertyMap in project structr by structr.

the class SSHTest method createFTPDirectory.

protected Folder createFTPDirectory(final String path, final String name) throws FrameworkException {
    PropertyMap props = new PropertyMap();
    props.put(Folder.name, name);
    props.put(Folder.owner, ftpUser);
    Folder dir = (Folder) createTestNodes(Folder.class, 1, props).get(0);
    if (StringUtils.isNotBlank(path)) {
        AbstractFile parent = FileHelper.getFileByAbsolutePath(securityContext, path);
        if (parent != null && parent instanceof Folder) {
            Folder parentFolder = (Folder) parent;
            dir.setParent(parentFolder);
        }
    }
    logger.info("FTP directory {} created successfully.", dir);
    return dir;
}
Also used : PropertyMap(org.structr.core.property.PropertyMap) AbstractFile(org.structr.web.entity.AbstractFile) Folder(org.structr.web.entity.Folder)

Example 39 with PropertyMap

use of org.structr.core.property.PropertyMap in project structr by structr.

the class SSHTest method createFTPUser.

protected User createFTPUser(final String username, final String password) throws FrameworkException {
    PropertyMap props = new PropertyMap();
    props.put(StructrApp.key(Principal.class, "name"), username);
    props.put(StructrApp.key(Principal.class, "password"), password);
    return (User) createTestNodes(User.class, 1, props).get(0);
}
Also used : PropertyMap(org.structr.core.property.PropertyMap) User(org.structr.web.entity.User) Principal(org.structr.core.entity.Principal)

Example 40 with PropertyMap

use of org.structr.core.property.PropertyMap in project structr by structr.

the class StructrDataFeedsModuleTest method createTestNodes.

protected <T extends AbstractNode> List<T> createTestNodes(final Class<T> type, final int number, final long delay) throws FrameworkException {
    try (final Tx tx = app.tx()) {
        final PropertyMap properties = new PropertyMap();
        final List<T> nodes = new LinkedList<>();
        properties.put(NodeInterface.visibleToAuthenticatedUsers, false);
        properties.put(NodeInterface.visibleToPublicUsers, false);
        properties.put(NodeInterface.deleted, false);
        properties.put(NodeInterface.hidden, false);
        for (int i = 0; i < number; i++) {
            nodes.add(app.create(type, properties));
            try {
                Thread.sleep(delay);
            } catch (InterruptedException ex) {
            }
        }
        tx.success();
        return nodes;
    } catch (Throwable t) {
        logger.warn("", t);
    }
    return null;
}
Also used : PropertyMap(org.structr.core.property.PropertyMap) Tx(org.structr.core.graph.Tx) LinkedList(java.util.LinkedList)

Aggregations

PropertyMap (org.structr.core.property.PropertyMap)233 FrameworkException (org.structr.common.error.FrameworkException)100 Tx (org.structr.core.graph.Tx)93 Test (org.junit.Test)60 App (org.structr.core.app.App)34 StructrApp (org.structr.core.app.StructrApp)34 PropertyKey (org.structr.core.property.PropertyKey)34 LinkedList (java.util.LinkedList)28 NodeInterface (org.structr.core.graph.NodeInterface)25 SchemaProperty (org.structr.core.entity.SchemaProperty)23 SecurityContext (org.structr.common.SecurityContext)22 StructrUiTest (org.structr.web.StructrUiTest)21 GraphObject (org.structr.core.GraphObject)20 Result (org.structr.core.Result)19 File (org.structr.web.entity.File)19 DOMNode (org.structr.web.entity.dom.DOMNode)19 TestOne (org.structr.core.entity.TestOne)17 AbstractNode (org.structr.core.entity.AbstractNode)16 Folder (org.structr.web.entity.Folder)15 Page (org.structr.web.entity.dom.Page)15