Package org.lightadmin.api.config.annotation

Examples of org.lightadmin.api.config.annotation.FileReference


            return emptyList();
        }

        Annotation annotation = persistentProperty.findAnnotation(FileReference.class);

        FileReference fileReference = (FileReference) annotation;

        if (isEmpty(fileReference.baseDirectory())) {
            if (lightAdminConfiguration.getFileStorageDirectory() != null) {
                return emptyList();
            }
            return newArrayList(validationContext.missingBaseDirectoryInFileReferenceProblem(fieldMetadata.getName()));
        }

        final File directory = getFile(fileReference.baseDirectory());
        if (directory.exists() && directory.isDirectory()) {
            return emptyList();
        }

        return newArrayList(validationContext.missingBaseDirectoryInFileReferenceProblem(fieldMetadata.getName()));
View Full Code Here


        this.fileStorageDirectory = fileStorageDirectory;
    }

    @Override
    public File persistentPropertyFileReference(Object entity, PersistentProperty persistentProperty) {
        FileReference fileReference = fileReferenceAnnotation(persistentProperty);
        String relativeFilePath = persistentPropertyFileRelativePath(entity, persistentProperty);

        if (propertyBaseDirectoryExists(fileReference)) {
            return getFile(fileReference.baseDirectory(), relativeFilePath);
        }

        return getFile(this.fileStorageDirectory, relativeFilePath);
    }
View Full Code Here

        return getFile(this.fileStorageDirectory, relativeFilePath);
    }

    @Override
    public File persistentPropertyFileDirectory(Object entity, PersistentProperty persistentProperty) {
        FileReference fileReference = fileReferenceAnnotation(persistentProperty);

        if (propertyBaseDirectoryExists(fileReference)) {
            return getFile(fileReference.baseDirectory(), persistentPropertyFileDirectoryRelativePath(entity, persistentProperty));
        }
        return getFile(this.fileStorageDirectory, persistentPropertyFileDirectoryRelativePath(entity, persistentProperty));
    }
View Full Code Here

        return Joiner.on(separator).join(persistentPropertyFileDirectoryRelativePath(entity, persistentProperty), FILE_NAME);
    }

    private boolean propertyValueFileExists(Object entity, PersistentProperty persistentProperty) {
        FileReference fileReference = fileReferenceAnnotation(persistentProperty);
        String propertyValue = propertyValueAsString(entity, persistentProperty);

        File fileDirectory = propertyBaseDirectoryExists(fileReference) ? getFile(fileReference.baseDirectory()) : this.fileStorageDirectory;

        File file = getFile(fileDirectory, propertyValue);

        return file.isFile() && file.exists();
    }
View Full Code Here

TOP

Related Classes of org.lightadmin.api.config.annotation.FileReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.