Package org.apache.marmotta.platform.core.model.content

Examples of org.apache.marmotta.platform.core.model.content.MediaContentItem


    @Override
    public void deleteContent(Resource resource, String mimetype) throws IOException {
        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                MediaContentItem mci = FacadingFactory.createFacading(conn).createFacade(resource, MediaContentItem.class);

                String path = mci.getContentPath();
                if(path != null) {
                    if(!path.startsWith(defaultDir)) {
                        if(!configurationService.getBooleanConfiguration("content.filesystem.secure")) {
                            log.warn("accessing file {}, which is outside the default directory; this is a potential security risk; " +
                                    "enable the option content.filesystem.secure in the configuration",path);
View Full Code Here


    @Override
    public void setContentStream(Resource resource, InputStream in, String mimetype) throws IOException {
        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                MediaContentItem mci = FacadingFactory.createFacading(conn).createFacade(resource, MediaContentItem.class);

                String path = mci.getContentPath();

                if(path == null) {
                    if(resource instanceof KiWiUriResource && ((KiWiUriResource)resource).stringValue().startsWith("file:")) {
                        try {
                            URI uri = new URI(((KiWiUriResource)resource).stringValue());
                            path = uri.getPath();
                        } catch(Exception ex) {}
                    } else {
                        // we store all other resources in the default directory; create a random file name and store it in the hasContentLocation
                        // property
                        String extension = null;
                        MimeEntry entry = MimeTable.getDefaultTable().find(mimetype);
                        if(entry != null && entry.getExtensions().length > 0) {
                            extension = entry.getExtensions()[0];
                        }

                        String fileName = UUID.randomUUID().toString();
                        path = defaultDir + File.separator +
                                fileName.substring(0,2) + File.separator +
                                fileName.substring(2,4) + File.separator +
                                fileName.substring(4,6) + File.separator +
                                fileName + (extension != null ? extension : "");
                        mci.setContentPath(path);
                    }
                }

                if(path != null) {
                    if(!path.startsWith(defaultDir)) {
View Full Code Here

    @Override
    public InputStream getContentStream(Resource resource, String mimetype) throws IOException {
        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                MediaContentItem mci = FacadingFactory.createFacading(conn).createFacade(resource, MediaContentItem.class);

                String path = mci.getContentPath();
                if(path == null && resource instanceof KiWiUriResource && resource.stringValue().startsWith("file:")) {
                    try {
                        URI uri = new URI(resource.stringValue());
                        path = uri.getPath();
                    } catch(Exception ex) {}
View Full Code Here

    @Override
    public boolean hasContent(Resource resource, String mimetype) {
        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                MediaContentItem mci = FacadingFactory.createFacading(conn).createFacade(resource, MediaContentItem.class);

                String path = mci.getContentPath();
                if(path == null && resource instanceof KiWiUriResource && resource.stringValue().startsWith("file:")) {
                    try {
                        URI uri = new URI(resource.stringValue());
                        path = uri.getPath();
                    } catch(Exception ex) {}
View Full Code Here

    @Override
    public String getContentType(Resource resource) {
        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                MediaContentItem mci = FacadingFactory.createFacading(conn).createFacade(resource, MediaContentItem.class);

                String path = mci.getContentPath();
                if(path == null && resource instanceof KiWiUriResource && resource.stringValue().startsWith("file:")) {
                    try {
                        URI uri = new URI(resource.stringValue());
                        path = uri.getPath();
                    } catch(Exception ex) {}
View Full Code Here

    @Override
    public long getContentLength(Resource resource, String mimetype) {
        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                MediaContentItem mci = FacadingFactory.createFacading(conn).createFacade(resource, MediaContentItem.class);

                String path = mci.getContentPath();
                if(path == null && resource instanceof KiWiUriResource && resource.stringValue().startsWith("file:")) {
                    try {
                        URI uri = new URI(resource.stringValue());
                        path = uri.getPath();
                    } catch(Exception ex) {}
View Full Code Here

TOP

Related Classes of org.apache.marmotta.platform.core.model.content.MediaContentItem

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.