Search in sources :

Example 56 with Principal

use of org.structr.core.entity.Principal in project structr by structr.

the class AbstractStructrFtpFile method getOwnerName.

@Override
public String getOwnerName() {
    try (Tx tx = StructrApp.getInstance(securityContext).tx()) {
        final Principal owner = getOwner();
        String name = "";
        if (owner != null) {
            name = owner.getProperty(User.name);
        }
        tx.success();
        return name;
    } catch (FrameworkException fex) {
        logger.error("Error while getting owner name of " + this, fex);
    }
    return null;
}
Also used : Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Principal(org.structr.core.entity.Principal)

Example 57 with Principal

use of org.structr.core.entity.Principal in project structr by structr.

the class AbstractStructrFtpFile method getGroupName.

@Override
public String getGroupName() {
    try (Tx tx = StructrApp.getInstance(securityContext).tx()) {
        final Principal owner = getOwner();
        String name = "";
        if (owner != null) {
            final List<Principal> parents = owner.getParents();
            if (!parents.isEmpty()) {
                name = parents.get(0).getProperty(AbstractNode.name);
            }
        }
        tx.success();
        return name;
    } catch (FrameworkException fex) {
        logger.error("Error while getting group name of " + this, fex);
    }
    return "";
}
Also used : Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Principal(org.structr.core.entity.Principal)

Example 58 with Principal

use of org.structr.core.entity.Principal in project structr by structr.

the class AbstractStructrFtpFile method getOwner.

private Principal getOwner() {
    try (Tx tx = StructrApp.getInstance(securityContext).tx()) {
        Principal owner = structrFile.getProperty(File.owner);
        tx.success();
        return owner;
    } catch (FrameworkException fex) {
        logger.error("Error while getting owner of " + this, fex);
    }
    return null;
}
Also used : Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Principal(org.structr.core.entity.Principal)

Example 59 with Principal

use of org.structr.core.entity.Principal in project structr by structr.

the class FtpFilePageWrapper method getOwnerName.

@Override
public String getOwnerName() {
    String name = "";
    try (Tx tx = StructrApp.getInstance().tx()) {
        Principal owner = getOwner();
        if (owner != null) {
            name = owner.getProperty(Principal.name);
        }
        tx.success();
    } catch (FrameworkException fex) {
        logger.error("Error while getting owner name of " + this, fex);
    }
    return name;
}
Also used : Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Principal(org.structr.core.entity.Principal)

Example 60 with Principal

use of org.structr.core.entity.Principal in project structr by structr.

the class FtpFilePageWrapper method getOwner.

private Principal getOwner() {
    try (Tx tx = StructrApp.getInstance().tx()) {
        Principal owner = page.getProperty(File.owner);
        tx.success();
        return owner;
    } catch (FrameworkException fex) {
        logger.error("Error while getting owner of " + this, fex);
    }
    return null;
}
Also used : Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Principal(org.structr.core.entity.Principal)

Aggregations

Principal (org.structr.core.entity.Principal)112 FrameworkException (org.structr.common.error.FrameworkException)68 Tx (org.structr.core.graph.Tx)65 Test (org.junit.Test)41 App (org.structr.core.app.App)31 StructrApp (org.structr.core.app.StructrApp)31 TestOne (org.structr.core.entity.TestOne)16 Group (org.structr.core.entity.Group)14 NodeAttribute (org.structr.core.graph.NodeAttribute)13 PropertyMap (org.structr.core.property.PropertyMap)13 SecurityContext (org.structr.common.SecurityContext)10 LinkedList (java.util.LinkedList)9 Result (org.structr.core.Result)8 User (org.structr.web.entity.User)8 AbstractNode (org.structr.core.entity.AbstractNode)7 SuperUser (org.structr.core.entity.SuperUser)7 StructrUiTest (org.structr.web.StructrUiTest)7 Page (org.structr.web.entity.dom.Page)7 IOException (java.io.IOException)6 List (java.util.List)6