mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Thumbanil API: suport for placeholder thumbnails added and queueing of thumbnails for creation on get
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9434 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -65,6 +65,7 @@
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="placeHolderResourcePath" value="alfresco/thumbnail/thumbnail_placeholder_medium.jpg" />
|
||||
</bean>
|
||||
|
||||
<!-- Web Preview thumbnail options -->
|
||||
@@ -94,5 +95,13 @@
|
||||
<ref bean="ThumbnailService" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Thumbnail service script API -->
|
||||
<bean id="thumbnailServiceScript" parent="baseJavaScriptExtension" class="org.alfresco.repo.thumbnail.script.ScriptThumbnailService">
|
||||
<property name="extensionName">
|
||||
<value>thumbnailService</value>
|
||||
</property>
|
||||
<property name="serviceRegistry" ref="ServiceRegistry"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
BIN
config/alfresco/thumbnail/thumbnail_placeholder_medium.jpg
Normal file
BIN
config/alfresco/thumbnail/thumbnail_placeholder_medium.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 825 B |
@@ -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
|
||||
*
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
@@ -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();
|
||||
testCreateThumbnail();
|
||||
testThumbnailService();
|
Reference in New Issue
Block a user