Search in sources :

Example 46 with LogicalData

use of nl.uva.cs.lobcder.resources.LogicalData in project lobcder by skoulouzis.

the class Assimilator method add.

public void add(VDir dir, String base, Connection connection, long ssid, boolean addFiles) throws MalformedURLException, VlException, SQLException, NoSuchAlgorithmException {
    VFSNode[] nodes = dir.list();
    for (VFSNode f : nodes) {
        VRL currentPath = new VRL(f.getPath().replaceFirst(base, ""));
        LogicalData register = getLogicalDataByPath(Path.path(currentPath.getPath()), connection);
        LogicalData parent = getLogicalDataByPath(Path.path(currentPath.getPath()).getParent(), connection);
        Long parentRef = new Long(1);
        if (parent == null) {
            parentRef = new Long(1);
        } else {
            parentRef = parent.getUid();
        }
        if (f.isDir()) {
            if (register == null) {
                LogicalData entry = new LogicalData();
                entry.setCreateDate(f.getModificationTime());
                entry.setModifiedDate(f.getModificationTime());
                entry.setName(f.getName());
                entry.setOwner("admin");
                entry.setParentRef(parentRef);
                register = registerDirLogicalData(entry, connection);
            }
            add((VDir) f, base, connection, ssid, addFiles);
        } else if (addFiles) {
            if (register == null) {
                System.err.println(f.getVRL());
                addFile(connection, (VFile) f, parentRef, ssid);
            }
        }
    }
}
Also used : VRL(nl.uva.vlet.vrl.VRL) LogicalData(nl.uva.cs.lobcder.resources.LogicalData) VFSNode(nl.uva.vlet.vfs.VFSNode) VFile(nl.uva.vlet.vfs.VFile)

Example 47 with LogicalData

use of nl.uva.cs.lobcder.resources.LogicalData in project lobcder by skoulouzis.

the class JDBCatalogue method setLogicalDataSupervised.

public void setLogicalDataSupervised(@Nonnull Long uid, @Nonnull Boolean flag, @Nonnull Connection connection) throws SQLException {
    try (PreparedStatement ps = connection.prepareStatement("UPDATE ldata_table SET isSupervised = ? WHERE uid = ?")) {
        ps.setBoolean(1, flag);
        ps.setLong(2, uid);
        ps.executeUpdate();
    }
    LogicalData cached = getFromLDataCache(uid, null);
    if (cached != null) {
        cached.setSupervised(flag);
        putToLDataCache(cached, null);
    }
}
Also used : LogicalData(nl.uva.cs.lobcder.resources.LogicalData)

Example 48 with LogicalData

use of nl.uva.cs.lobcder.resources.LogicalData in project lobcder by skoulouzis.

the class JDBCatalogue method setLocationPreference.

public void setLocationPreference(Long uid, String locationPreference, Connection connection) throws SQLException {
    try (PreparedStatement ps = connection.prepareStatement("UPDATE ldata_table SET locationPreference = ? WHERE uid = ?")) {
        ps.setString(1, locationPreference);
        ps.setLong(2, uid);
        ps.executeUpdate();
    }
    LogicalData cached = getFromLDataCache(uid, null);
    if (cached != null) {
        cached.setDataLocationPreference(locationPreference);
        putToLDataCache(cached, null);
    }
}
Also used : LogicalData(nl.uva.cs.lobcder.resources.LogicalData)

Example 49 with LogicalData

use of nl.uva.cs.lobcder.resources.LogicalData in project lobcder by skoulouzis.

the class JDBCatalogue method setLockTokenID.

public void setLockTokenID(@Nonnull Long uid, @Nonnull String lockTokenID, @Nonnull Connection connection) throws SQLException {
    try (PreparedStatement ps = connection.prepareStatement("UPDATE ldata_table SET lockTokenID = ? WHERE uid = ?")) {
        ps.setString(1, lockTokenID);
        ps.setLong(2, uid);
        ps.executeUpdate();
    }
    LogicalData cached = getFromLDataCache(uid, null);
    if (cached != null) {
        cached.setLockTokenID(lockTokenID);
        putToLDataCache(cached, null);
    }
}
Also used : LogicalData(nl.uva.cs.lobcder.resources.LogicalData)

Example 50 with LogicalData

use of nl.uva.cs.lobcder.resources.LogicalData in project lobcder by skoulouzis.

the class JDBCatalogue method setLockType.

public void setLockType(Long uid, String lockType, Connection connection) throws SQLException {
    try (PreparedStatement ps = connection.prepareStatement("UPDATE ldata_table SET lockType = ? WHERE uid = ?")) {
        ps.setString(1, lockType);
        ps.setLong(2, uid);
        ps.executeUpdate();
    }
    LogicalData cached = getFromLDataCache(uid, null);
    if (cached != null) {
        cached.setLockType(lockType);
        putToLDataCache(cached, null);
    }
}
Also used : LogicalData(nl.uva.cs.lobcder.resources.LogicalData)

Aggregations

LogicalData (nl.uva.cs.lobcder.resources.LogicalData)71 Connection (java.sql.Connection)29 SQLException (java.sql.SQLException)29 Permissions (nl.uva.cs.lobcder.auth.Permissions)29 MyPrincipal (nl.uva.cs.lobcder.auth.MyPrincipal)20 PreparedStatement (java.sql.PreparedStatement)11 ResultSet (java.sql.ResultSet)10 Path (io.milton.common.Path)7 ArrayList (java.util.ArrayList)7 BadRequestException (io.milton.http.exceptions.BadRequestException)6 NotAuthorizedException (io.milton.http.exceptions.NotAuthorizedException)5 PDRIDescr (nl.uva.cs.lobcder.resources.PDRIDescr)5 ConflictException (io.milton.http.exceptions.ConflictException)4 URISyntaxException (java.net.URISyntaxException)4 Stack (java.util.Stack)4 Path (javax.ws.rs.Path)4 LogicalDataWrapped (nl.uva.cs.lobcder.rest.wrappers.LogicalDataWrapped)4 VRL (nl.uva.vlet.vrl.VRL)4 PreConditionFailedException (io.milton.http.exceptions.PreConditionFailedException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3