diff --git a/config/alfresco/thumbnail-service-context.xml b/config/alfresco/thumbnail-service-context.xml index c11d55ac52..e3e38ee4aa 100644 --- a/config/alfresco/thumbnail-service-context.xml +++ b/config/alfresco/thumbnail-service-context.xml @@ -65,6 +65,7 @@ + @@ -94,5 +95,13 @@ + + + + + thumbnailService + + + diff --git a/config/alfresco/thumbnail/thumbnail_placeholder_medium.jpg b/config/alfresco/thumbnail/thumbnail_placeholder_medium.jpg new file mode 100644 index 0000000000..91f2b5c772 Binary files /dev/null and b/config/alfresco/thumbnail/thumbnail_placeholder_medium.jpg differ diff --git a/source/java/org/alfresco/repo/jscript/People.java b/source/java/org/alfresco/repo/jscript/People.java index acf665c901..53639fc220 100644 --- a/source/java/org/alfresco/repo/jscript/People.java +++ b/source/java/org/alfresco/repo/jscript/People.java @@ -88,7 +88,7 @@ public final class People extends BaseScopableProcessorExtension PersonService personService = services.getPersonService(); personService.deletePerson(username); } - + /** * Create a Person with the given username and password * diff --git a/source/java/org/alfresco/repo/thumbnail/ThumbnailDetails.java b/source/java/org/alfresco/repo/thumbnail/ThumbnailDetails.java index bfdad94939..ff224d50d0 100644 --- a/source/java/org/alfresco/repo/thumbnail/ThumbnailDetails.java +++ b/source/java/org/alfresco/repo/thumbnail/ThumbnailDetails.java @@ -24,6 +24,8 @@ */ package org.alfresco.repo.thumbnail; +import java.lang.reflect.Constructor; + import org.alfresco.service.cmr.repository.TransformationOptions; /** @@ -40,7 +42,10 @@ public class ThumbnailDetails private String mimetype; /** Transformation options */ - private TransformationOptions options; + private TransformationOptions options; + + /** Path to placeholder thumbnail */ + private String placeHolderResourcePath; /** * Default constructor @@ -72,6 +77,20 @@ public class ThumbnailDetails this.name= thumbnailName; } + /** + * Constructor. Specify the place holder thumbnail path. + * + * @param mimetype + * @param options + * @param thumbnailName + * @param placeHolderResourcePath + */ + public ThumbnailDetails(String mimetype, TransformationOptions options, String thumbnailName, String placeHolderResourcePath) + { + this(mimetype, options, thumbnailName); + this.placeHolderResourcePath = placeHolderResourcePath; + } + /** * Set the destination mimetype * @@ -131,4 +150,22 @@ public class ThumbnailDetails { return name; } + + /** + * + * @param placeHolderResourcePath + */ + public void setPlaceHolderResourcePath(String placeHolderResourcePath) + { + this.placeHolderResourcePath = placeHolderResourcePath; + } + + /** + * + * @return + */ + public String getPlaceHolderResourcePath() + { + return placeHolderResourcePath; + } } diff --git a/source/java/org/alfresco/repo/thumbnail/script/ScriptThumbnailService.java b/source/java/org/alfresco/repo/thumbnail/script/ScriptThumbnailService.java new file mode 100644 index 0000000000..3500266d8e --- /dev/null +++ b/source/java/org/alfresco/repo/thumbnail/script/ScriptThumbnailService.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.thumbnail.script; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.repo.jscript.BaseScopableProcessorExtension; +import org.alfresco.repo.site.SiteInfo; +import org.alfresco.repo.site.SiteService; +import org.alfresco.repo.thumbnail.ThumbnailDetails; +import org.alfresco.service.ServiceRegistry; + + +/** + * Script object representing the site service. + * + * @author Roy Wetherall + */ +public class ScriptThumbnailService extends BaseScopableProcessorExtension +{ + /** Service Registry */ + private ServiceRegistry serviceRegistry; + + /** + * Sets the Service Registry + * + * @param serviceRegistry + */ + public void setServiceRegistry(ServiceRegistry serviceRegistry) + { + this.serviceRegistry = serviceRegistry; + } + + /** + * Indicates whether a given thumbnail name has been registered. + * + * @param thumbnailName thumbnail name + * @return boolean true if the thumbnail name is registered, false otherwise + */ + public boolean isThumbnailNameRegistered(String thumbnailName) + { + return (this.serviceRegistry.getThumbnailService().getThumbnailRegistry().getThumbnailDetails(thumbnailName) != null); + } + + /** + * Gets the resource path for the place holder thumbnail for the given named thumbnail. + * + * Returns null if none set. + * + * @param thumbnailName the thumbnail name + * @return String the place holder thumbnail resource path, null if none set + */ + public String getPlaceHolderResourcePath(String thumbnailName) + { + String result = null; + ThumbnailDetails details = this.serviceRegistry.getThumbnailService().getThumbnailRegistry().getThumbnailDetails(thumbnailName); + if (details != null) + { + result = details.getPlaceHolderResourcePath(); + } + return result; + } + +} diff --git a/source/java/org/alfresco/repo/thumbnail/script/test_thumbnailAPI.js b/source/java/org/alfresco/repo/thumbnail/script/test_thumbnailAPI.js index f5df4760ae..f7f0e498b0 100644 --- a/source/java/org/alfresco/repo/thumbnail/script/test_thumbnailAPI.js +++ b/source/java/org/alfresco/repo/thumbnail/script/test_thumbnailAPI.js @@ -3,29 +3,18 @@ function testCreateThumbnail() // Create a thumbnail var thumbnail = jpgOrig.createThumbnail("medium"); test.assertNotNull(thumbnail); +} + +function testThumbnailService() +{ + test.assertFalse(thumbnailService.isThumbnailNameRegistered("rubbish")); + test.assertTrue(thumbnailService.isThumbnailNameRegistered("medium")); - // Create async thumbnail -// var thumbnail2 = gifOrig.createThumbnail("medium", true); -// test.assertNull(thumbnail2); - - // Try and get the created thumbnail -// var count = 0; -// while (true) -// { -// thumbnail2 = gifOrig.getThumbnail("medium"); - -// if (thumbnail2 != null) -// { -// break; -// } - //else if (count > 1000) - //{ - // test.fail("Async thumbanil wasn't created"); - //} - -// count++; -// } + test.assertNull(thumbnailService.getPlaceHolderResourcePath("rubbish")); + test.assertNull(thumbnailService.getPlaceHolderResourcePath("webpreview")); + test.assertNotNull(thumbnailService.getPlaceHolderResourcePath("medium")); } // Execute the tests -testCreateThumbnail(); \ No newline at end of file +testCreateThumbnail(); +testThumbnailService(); \ No newline at end of file