|
From: <mol...@us...> - 2009-02-19 10:55:54
|
Revision: 1024
http://openutils.svn.sourceforge.net/openutils/?rev=1024&view=rev
Author: molaschi
Date: 2009-02-19 10:55:49 +0000 (Thu, 19 Feb 2009)
Log Message:
-----------
fix problem on node name editing
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTree.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTree.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTree.java 2009-02-17 09:49:37 UTC (rev 1023)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTree.java 2009-02-19 10:55:49 UTC (rev 1024)
@@ -331,10 +331,11 @@
html.append(" />"); //$NON-NLS-1$
}
String dblclick = StringUtils.EMPTY;
- if (permissionWrite && StringUtils.isNotEmpty(this.getColumns(0).getHtmlEdit()) && !this.isBrowseMode())
+ String htmlEdit = this.getColumns(0).getHtmlEdit();
+ if (permissionWrite && StringUtils.isNotEmpty(htmlEdit) && !this.isBrowseMode())
// && this.getRequest().getParameter("selectMedia") == null)
{
- dblclick = " ondblclick=\"" + this.getJavascriptTree() + ".editNodeData(this,'" + handle + "',0);\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ dblclick = " ondblclick=\"" + this.getJavascriptTree() + ".editNodeData(this,'" + handle + "',0,'"+ htmlEdit.replace("\"", """) +"');\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
html.append("<span class=\"mgnlTreeText\" id=\"");
html.append(idPre);
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-02-17 09:49:37 UTC (rev 1023)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-02-19 10:55:49 UTC (rev 1024)
@@ -24,9 +24,11 @@
import info.magnolia.cms.util.ExclusiveWrite;
import info.magnolia.context.MgnlContext;
+import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
+import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.io.BufferedOutputStream;
@@ -73,6 +75,8 @@
private static SimpleDateFormat sdf;
+ private static String TRANSPARENT = "transparent";
+
private static final String[] extensions = new String[]{"jpg", "gif", "png" };
static
@@ -194,6 +198,16 @@
*/
public static BufferedImage fitIn(BufferedImage original, int x, int y)
{
+ return resizeInOut(original, x, y, false);
+ }
+
+ public static BufferedImage resizeNoCrop(BufferedImage original, int x, int y)
+ {
+ return resizeInOut(original, x, y, true);
+ }
+
+ private static BufferedImage resizeInOut(BufferedImage original, int x, int y, boolean external)
+ {
if (original == null)
{
throw new IllegalArgumentException("input image is null");
@@ -207,67 +221,13 @@
throw new IllegalArgumentException("Broken input image (width=" + oX + ",height=" + oY + ")");
}
- float oDelta = oX / oY;
- float delta = ((float) x) / ((float) y);
-
- if (oDelta > delta)
- {
- int newY = (int) (x * oY / oX);
- if (newY < 1)
- {
- newY = 1;
- }
- return resizeImage(original, x, newY);
- }
- else if (oDelta < delta)
- {
- int newX = (int) (y * oX / oY);
- if (newX < 1)
- {
- newX = 1;
- }
- return resizeImage(original, newX, y);
- }
- else
- {
- return resizeImage(original, x, y);
- }
- }
-
- public static BufferedImage resizeNoCrop(BufferedImage original, int x, int y)
- {
- float oX = original.getWidth();
- float oY = original.getHeight();
-
double xRatio = (double) x / oX;
double yRatio = (double) y / oY;
- double ratio = Math.min(xRatio, yRatio);
+ double ratio = (external ? Math.min(xRatio, yRatio) : Math.min(xRatio, yRatio));
int newX = (int) Math.round(oX * ratio);
int newY = (int) Math.round(oY * ratio);
- BufferedImage resizedImage = new BufferedImage(x, y, getType(original.getColorModel()));
-
- Graphics2D graphics2D = resizedImage.createGraphics();
- graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
-
- if (ratio > 1)
- {
- graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- graphics2D.drawImage(original, (x - newX) / 2, (y - newY) / 2, newX, newY, null);
- }
- else
- {
- graphics2D.drawImage(
- original.getScaledInstance(newX, newY, Image.SCALE_SMOOTH),
- (x - newX) / 2,
- (y - newY) / 2,
- newX,
- newY,
- null);
- }
-
- return resizedImage;
+ return resizeImage(original, newX, newY);
}
/**
@@ -302,6 +262,78 @@
}
}
+ private static int[] convertHexToRGB(String hexColor)
+ {
+ String hex = hexColor.trim();
+ if (hex.startsWith("#"))
+ {
+ hex = hex.substring(1);
+ }
+ if (hex.equals("transparent"))
+ {
+ return new int[]{0, 0, 0, 0 };
+ }
+ if (hex.length() == 3)
+ {
+ // allow three digit codes like for css
+ hex = String.valueOf(hex.charAt(0))
+ + String.valueOf(hex.charAt(0))
+ + String.valueOf(hex.charAt(1))
+ + String.valueOf(hex.charAt(1))
+ + String.valueOf(hex.charAt(2))
+ + String.valueOf(hex.charAt(2));
+ }
+
+ int[] rgb = new int[4];
+ try
+ {
+ // Convert rrggbb string to hex ints
+ rgb[0] = Integer.parseInt(hex.substring(0, 2), 16);
+ rgb[1] = Integer.parseInt(hex.substring(2, 4), 16);
+ rgb[2] = Integer.parseInt(hex.substring(4), 16);
+ rgb[3] = 255;
+ }
+ catch (NumberFormatException e)
+ {
+ log.error("NumberFormatException occured during text-to-image conversion: "
+ + "Attempting to convert Hex ["
+ + hex
+ + "] color to RGB color: "
+ + e.getMessage(), e);
+ rgb = new int[]{255, 0, 0, 255 }; // red
+ }
+ return rgb;
+ }
+
+ public static BufferedImage addRoundedCorners(BufferedImage original, String backgroundColor, int radius)
+ {
+ BufferedImage resizedImage;
+ try
+ {
+ resizedImage = new BufferedImage(original.getWidth(), original.getHeight(), getType(original
+ .getColorModel()));
+ }
+ catch (NegativeArraySizeException e)
+ {
+ throw new RuntimeException("NegativeArraySizeException caught when resizing image]");
+ }
+
+ Graphics2D graphics2D = resizedImage.createGraphics();
+ graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+
+ int[] colorAr = convertHexToRGB(backgroundColor);
+ Color color = new Color(colorAr[0], colorAr[1], colorAr[2], colorAr[3]);
+
+ graphics2D.setBackground(color);
+ graphics2D.clearRect(0, 0, original.getWidth(), original.getHeight());
+ graphics2D
+ .setClip(new RoundRectangle2D.Double(0, 0, original.getWidth(), original.getHeight(), radius, radius));
+ graphics2D.drawImage(original, 0, 0, original.getWidth(), original.getHeight(), null);
+
+ return resizedImage;
+ }
+
/**
* Save a resolution for an image to a node (in resolutions/res-[width]x[height]/data.jpg)
* @param image image to save
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mol...@us...> - 2009-09-04 17:04:12
|
Revision: 1365
http://openutils.svn.sourceforge.net/openutils/?rev=1365&view=rev
Author: molaschi
Date: 2009-09-04 17:03:57 +0000 (Fri, 04 Sep 2009)
Log Message:
-----------
update javadocs
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/commands/MediaActivationCommand.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/ImageProcessorsManager.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaTypeConfiguration.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogCustomSaveHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileNoPreview.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileVideo.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogMetadata.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialog.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/commands/MediaActivationCommand.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/commands/MediaActivationCommand.java 2009-09-04 16:29:16 UTC (rev 1364)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/commands/MediaActivationCommand.java 2009-09-04 17:03:57 UTC (rev 1365)
@@ -39,6 +39,7 @@
/**
+ * Overrides default activation, and doesn't publish resolutions node
* @author molaschi
* @version $Id$
*/
@@ -53,6 +54,7 @@
/**
* {@inheritDoc}
*/
+ @SuppressWarnings("unchecked")
@Override
public boolean execute(Context ctx)
{
@@ -106,6 +108,7 @@
}
}
+ @SuppressWarnings("unchecked")
public void activateRecursiveOneLevel(String parentPath, Content node) throws RepositoryException,
ExchangeException
{
@@ -139,6 +142,7 @@
/**
* {@inheritDoc}
*/
+ @SuppressWarnings("unchecked")
@Override
protected void activateRecursive(String parentPath, Content node, Context ctx) throws ExchangeException,
RepositoryException
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/ImageProcessorsManager.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/ImageProcessorsManager.java 2009-09-04 16:29:16 UTC (rev 1364)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/ImageProcessorsManager.java 2009-09-04 17:03:57 UTC (rev 1365)
@@ -13,13 +13,49 @@
import javax.jcr.RepositoryException;
+import net.sourceforge.openutils.mgnlmedia.media.processors.FitInAndFillWithBandsImageResolutionProcessor;
+import net.sourceforge.openutils.mgnlmedia.media.processors.FitInImageResolutionProcessor;
import net.sourceforge.openutils.mgnlmedia.media.processors.ImagePostProcessor;
import net.sourceforge.openutils.mgnlmedia.media.processors.ImageResolutionProcessor;
+import net.sourceforge.openutils.mgnlmedia.media.processors.ResizeCropCenteredImageResolutionProcessor;
+import net.sourceforge.openutils.mgnlmedia.media.processors.ResizeNoCropImageResolutionProcessor;
import org.apache.commons.lang.StringUtils;
/**
+ * ObservedManager that manages the maps of processors that handle images resize and processors that do operation on
+ * images after the resize. <br/>
+ * default image resolution processors:
+ * <table>
+ * <tbody>
+ * <tr>
+ * <td>control chars</td>
+ * <td>image resolution processor</td>
+ * <td>description</td>
+ * </tr>
+ * <tr>
+ * <td>b, o</td>
+ * <td>{@link FitInAndFillWithBandsImageResolutionProcessor}</td>
+ * <td>resize image to fit in required resolution and fills empty areas by color passed in parameters as "background"</td>
+ * </tr>
+ * <tr>
+ * <td>l</td>
+ * <td>{@link FitInImageResolutionProcessor}</td>
+ * <td>resize image to fit in required resolution</td>
+ * </tr>
+ * <tr>
+ * <td>x</td>
+ * <td>{@link ResizeNoCropImageResolutionProcessor}</td>
+ * <td>resize image to contain required resolution</td>
+ * </tr>
+ * <tr>
+ * <td>no control char (default), c</td>
+ * <td>{@link ResizeCropCenteredImageResolutionProcessor}</td>
+ * <td>resize image to contain required resolution, and crop simmetric bands that outfits the required resolution rect</td>
+ * </tr>
+ * </tbody>
+ * </table>
* @author molaschi
* @version $Id: $
*/
@@ -34,6 +70,10 @@
private Map<String, ImagePostProcessor> imagePostProcs = new HashMap<String, ImagePostProcessor>();
+ /**
+ * Get singleton instance
+ * @return singleton manager instance
+ */
public static ImageProcessorsManager getInstance()
{
return (ImageProcessorsManager) FactoryUtil.getSingleton(ImageProcessorsManager.class);
@@ -52,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @SuppressWarnings("unchecked")
@Override
protected void onRegister(Content parentNode)
{
@@ -144,31 +185,59 @@
}
}
+ /**
+ * Get image resolution processor for a given control char
+ * @param controlChar resolution control char
+ * @return image resolution processor for a given control char
+ */
public ImageResolutionProcessor getImageResolutionProcessor(char controlChar)
{
return imageResProcs.get(String.valueOf(controlChar));
}
+ /**
+ * Check if control char is registered
+ * @param controlChar control char to check
+ * @return true if control char is registered
+ */
public boolean isValidControlChar(char controlChar)
{
return imageResProcs.keySet().contains(String.valueOf(controlChar));
}
+ /**
+ * Get the default image resolution processor (by default config is
+ * {@link ResizeCropCenteredImageResolutionProcessor})
+ * @return the default image resolution processor
+ */
public ImageResolutionProcessor getDefaultImageResolutionProcessor()
{
return imageResProcs.get("default");
}
+ /**
+ * Get image post processor by its name
+ * @param name image post processor name
+ * @return image post processor
+ */
public ImagePostProcessor getImagePostProcessor(String name)
{
return imagePostProcs.get(name);
}
+ /**
+ * Get all image post processors
+ * @return image post processors list
+ */
public Collection<ImagePostProcessor> getImagePostProcessorsList()
{
return imagePostProcs.values();
}
+ /**
+ * Get the map of image post processors
+ * @return image post processors map
+ */
public Map<String, ImagePostProcessor> getImagePostProcessorsMap()
{
return imagePostProcs;
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2009-09-04 16:29:16 UTC (rev 1364)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2009-09-04 17:03:57 UTC (rev 1365)
@@ -48,7 +48,6 @@
import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
import net.sourceforge.openutils.mgnlmedia.media.pages.MediaFolderViewPage;
-import net.sourceforge.openutils.mgnlmedia.media.processors.ImageResolutionProcessor;
import net.sourceforge.openutils.mgnlmedia.media.types.MediaTypeHandler;
import org.apache.commons.collections.CollectionUtils;
@@ -59,6 +58,16 @@
/**
+ * ObservedManager that keeps that media types configuration.<br/>
+ * Each media type is defined under the mediatypes contentnode in /modules/media.<br/>
+ * I.e.<br/>
+ * /modules/media/mediatypes/pdf<br/>
+ * <ul>
+ * <li>label = pdf file</li>
+ * <li>handler = info.acme.PdfTypeHandler</li>
+ * <li>menuIcon = .resources/pdf/icons/pdf16.gif</li>
+ * <li>extensions = pdf</li>
+ * </ul>
* @author molaschi
*/
public class MediaConfigurationManager extends ObservedManager
@@ -79,7 +88,7 @@
public static final ItemType MEDIA = new ItemType(MGNL_MEDIA_TYPE);
/**
- *
+ * Resolutions node type
*/
public static final ItemType RESOLUTIONS = new ItemType(MGNL_RESOLUTION_TYPE);
@@ -158,11 +167,20 @@
}
}
+ /**
+ * Get singleton instance
+ * @return singleton instance
+ */
public static MediaConfigurationManager getInstance()
{
return (MediaConfigurationManager) FactoryUtil.getSingleton(MediaConfigurationManager.class);
}
+ /**
+ * Get the media type from a file extension
+ * @param extension file extension
+ * @return media type
+ */
public static MediaTypeConfiguration getMediaHandlerFromExtension(String extension)
{
for (Map.Entry<String, MediaTypeConfiguration> entry : MediaConfigurationManager
@@ -178,6 +196,10 @@
return null;
}
+ /**
+ * Get all media type map
+ * @return media type map
+ */
public Map<String, MediaTypeConfiguration> getTypes()
{
return types;
@@ -224,7 +246,7 @@
}
/**
- * Get all media nodes of passed type in a folder
+ * Get all media nodes of given type in a folder
* @param folder folder
* @param type media
* @param sorting sorting
@@ -338,6 +360,13 @@
return medias;
}
+ /**
+ * Search media
+ * @param text text to search
+ * @param type if specified restricts the search to the type
+ * @return found medias
+ * @throws RepositoryException exception working on repository
+ */
@SuppressWarnings("unchecked")
public Collection<Content> search(String text, final String type) throws RepositoryException
{
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaTypeConfiguration.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaTypeConfiguration.java 2009-09-04 16:29:16 UTC (rev 1364)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaTypeConfiguration.java 2009-09-04 17:03:57 UTC (rev 1365)
@@ -23,6 +23,7 @@
/**
+ * Bean that contains all media type informations
* @author molaschi
* @version $Id$
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogCustomSaveHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogCustomSaveHandler.java 2009-09-04 16:29:16 UTC (rev 1364)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogCustomSaveHandler.java 2009-09-04 17:03:57 UTC (rev 1365)
@@ -29,6 +29,7 @@
/**
+ * This dialog renders a field with a custom save handler which will be called on saves
* @author molaschi
* @version $Id$
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java 2009-09-04 16:29:16 UTC (rev 1364)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java 2009-09-04 17:03:57 UTC (rev 1365)
@@ -28,11 +28,11 @@
import javax.jcr.PropertyType;
-import org.apache.commons.lang.StringUtils;
-
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager;
+import org.apache.commons.lang.StringUtils;
+
/**
* @author molaschi
* @version Id:
@@ -190,11 +190,4 @@
out.write(control.getHtmlNodeDataTemplate());
this.drawHtmlPost(out);
}
-
- private String getPreviewUrl()
- {
- return MediaConfigurationManager.getInstance().getURIMappingPrefix()
- + this.getStorageNode().getHandle()
- + "/resolutions/thumbnail/data.jpg";
- }
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileNoPreview.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileNoPreview.java 2009-09-04 16:29:16 UTC (rev 1364)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileNoPreview.java 2009-09-04 17:03:57 UTC (rev 1365)
@@ -15,6 +15,9 @@
/**
+ * Overrides DialogFile and force no preview but the download link.<br/>
+ * Renders the list of valid file extensions (specified by "extensions" property) and validates uploaded file against
+ * it.
* @author molaschi
* @version $Id: $
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileVideo.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileVideo.java 2009-09-04 16:29:16 UTC (rev 1364)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileVideo.java 2009-09-04 17:03:57 UTC (rev 1365)
@@ -210,10 +210,4 @@
this.drawHtmlPost(out);
}
- private String getPreviewUrl()
- {
- return MediaConfigurationManager.getInstance().getURIMappingPrefix()
- + this.getStorageNode().getHandle()
- + "/resolutions/thumbnail/data.jpg";
- }
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogMetadata.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogMetadata.java 2009-09-04 16:29:16 UTC (rev 1364)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogMetadata.java 2009-09-04 17:03:57 UTC (rev 1365)
@@ -24,6 +24,7 @@
/**
+ * Overrides to format date values
* @author fgiust
* @version $Id$
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java 2009-09-04 16:29:16 UTC (rev 1364)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java 2009-09-04 17:03:57 UTC (rev 1365)
@@ -57,10 +57,10 @@
/**
+ * This dialogs draws the control that allows to select a media from repository and store its uuid
* @author molaschi
* @version $Id$
*/
-
@SuppressWarnings("unchecked")
public class DialogSelectMedia extends DialogCustomSaveHandler
{
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialog.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialog.java 2009-09-04 16:29:16 UTC (rev 1364)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialog.java 2009-09-04 17:03:57 UTC (rev 1365)
@@ -31,6 +31,7 @@
/**
+ * This dialog allow to popup the dialog as an Ext js layer
* @author molaschi
* @version $Id$
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java 2009-09-04 16:29:16 UTC (rev 1364)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java 2009-09-04 17:03:57 UTC (rev 1365)
@@ -43,6 +43,8 @@
/**
+ * With {@link LayerDialog} allows to have a dialog in an Ext js layer.
+ *
* @author molaschi
* @version $Id$
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java 2009-09-04 16:29:16 UTC (rev 1364)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java 2009-09-04 17:03:57 UTC (rev 1365)
@@ -27,6 +27,7 @@
/**
+ * Media module lifecycle manager
* @author molaschi
*/
public class MediaModule implements ModuleLifecycle
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mol...@us...> - 2009-09-05 09:38:59
|
Revision: 1368
http://openutils.svn.sourceforge.net/openutils/?rev=1368&view=rev
Author: molaschi
Date: 2009-09-05 09:38:50 +0000 (Sat, 05 Sep 2009)
Log Message:
-----------
javadocs and extract MediaBean class
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MessagesTemplatedMVCHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInImageResolutionProcessor.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImagePostProcessor.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImageResolutionProcessor.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/LogSizePostProcessor.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeCropCenteredImageResolutionProcessor.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeNoCropImageResolutionProcessor.java
Added Paths:
-----------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBean.java
Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBean.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBean.java (rev 0)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBean.java 2009-09-05 09:38:50 UTC (rev 1368)
@@ -0,0 +1,263 @@
+/**
+ *
+ * Magnolia SimpleMedia Module (http://lab.openmindonline.it/lab/products/media.html)
+ * Magnolia SimpleMedia Module: a module for Magnolia CMS for easier management of images and videos with
+ * several features.
+ * Copyright (C)2008 - 2009, Openmind S.r.l. http://www.openmindonline.it
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl-2.1.html
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package net.sourceforge.openutils.mgnlmedia.media.pages;
+
+import info.magnolia.cms.core.Content;
+import info.magnolia.cms.core.MetaData;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Store media info for rendering in {@link MediaFolderViewPage}
+ * @author molaschi
+ * @version $Id: MediaFolderViewPage.java 1366 2009-09-05 08:56:03Z molaschi $
+ */
+public class MediaBean
+{
+
+ private String handle;
+
+ private String filename;
+
+ private String description;
+
+ private String thumbnailUrl;
+
+ private String previewUrl;
+
+ private Content content;
+
+ private MetaData metaData;
+
+ private String uuid;
+
+ private List<String> usedInWebPages = new ArrayList<String>();
+
+ private boolean canPublish;
+
+ private boolean writable;
+
+ /**
+ * Returns the metaData.
+ * @return the metaData
+ */
+ public MetaData getMetaData()
+ {
+ return metaData;
+ }
+
+ /**
+ * Sets the metaData.
+ * @param metaData the metaData to set
+ */
+ public void setMetaData(MetaData metaData)
+ {
+ this.metaData = metaData;
+ }
+
+ /**
+ * Returns the handle.
+ * @return the handle
+ */
+ public String getHandle()
+ {
+ return handle;
+ }
+
+ /**
+ * Sets the handle.
+ * @param handle the handle to set
+ */
+ public void setHandle(String handle)
+ {
+ this.handle = handle;
+ }
+
+ /**
+ * Returns the filename.
+ * @return the filename
+ */
+ public String getFilename()
+ {
+ return filename;
+ }
+
+ /**
+ * Sets the filename.
+ * @param filename the filename to set
+ */
+ public void setFilename(String filename)
+ {
+ this.filename = filename;
+ }
+
+ /**
+ * Returns the description.
+ * @return the description
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+ /**
+ * Sets the description.
+ * @param description the description to set
+ */
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ /**
+ * Returns the thumbnailUrl.
+ * @return the thumbnailUrl
+ */
+ public String getThumbnailUrl()
+ {
+ return thumbnailUrl;
+ }
+
+ /**
+ * Sets the thumbnailUrl.
+ * @param thumbnailUrl the thumbnailUrl to set
+ */
+ public void setThumbnailUrl(String thumbnailUrl)
+ {
+ this.thumbnailUrl = thumbnailUrl;
+ }
+
+ /**
+ * Returns the previewUrl.
+ * @return the previewUrl
+ */
+ public String getPreviewUrl()
+ {
+ return previewUrl;
+ }
+
+ /**
+ * Sets the previewUrl.
+ * @param previewUrl the previewUrl to set
+ */
+ public void setPreviewUrl(String previewUrl)
+ {
+ this.previewUrl = previewUrl;
+ }
+
+ /**
+ * Returns the content.
+ * @return the content
+ */
+ public Content getContent()
+ {
+ return content;
+ }
+
+ /**
+ * Sets the content.
+ * @param content the content to set
+ */
+ public void setContent(Content content)
+ {
+ this.content = content;
+ }
+
+ /**
+ * Returns the uuid.
+ * @return the uuid
+ */
+ public String getUuid()
+ {
+ return uuid;
+ }
+
+ /**
+ * Sets the uuid.
+ * @param uuid the uuid to set
+ */
+ public void setUuid(String uuid)
+ {
+ this.uuid = uuid;
+ }
+
+ /**
+ * Returns the usedInWebPages.
+ * @return the usedInWebPages
+ */
+ public List<String> getUsedInWebPages()
+ {
+ return usedInWebPages;
+ }
+
+ /**
+ * Sets the usedInWebPages.
+ * @param usedInWebPages the usedInWebPages to set
+ */
+ public void setUsedInWebPages(List<String> usedInWebPages)
+ {
+ this.usedInWebPages = usedInWebPages;
+ }
+
+ /**
+ * Returns the canPublish.
+ * @return the canPublish
+ */
+ public boolean isCanPublish()
+ {
+ return canPublish;
+ }
+
+ /**
+ * Sets the canPublish.
+ * @param canPublish the canPublish to set
+ */
+ public void setCanPublish(boolean canPublish)
+ {
+ this.canPublish = canPublish;
+ }
+
+ /**
+ * Returns the writable.
+ * @return the writable
+ */
+ public boolean isWritable()
+ {
+ return writable;
+ }
+
+ /**
+ * Sets the writable.
+ * @param writable the writable to set
+ */
+ public void setWritable(boolean writable)
+ {
+ this.writable = writable;
+ }
+
+}
\ No newline at end of file
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java 2009-09-05 08:58:55 UTC (rev 1367)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java 2009-09-05 09:38:50 UTC (rev 1368)
@@ -55,6 +55,7 @@
/**
+ * Page that contains the tree and the foldere view.
* @author molaschi
* @version $Id$
*/
@@ -85,7 +86,7 @@
private Document zipFile;
/**
- * @param name
+ * @param name command name
* @param request
* @param response
*/
@@ -110,6 +111,10 @@
}
}
+ /**
+ * Save Zip file command
+ * @return view
+ */
public String saveZip()
{
InputStream zipStream = null;
@@ -344,7 +349,6 @@
@Override
public Messages getMsgs()
{
- // TODO Auto-generated method stub
return super.getMsgs();
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2009-09-05 08:58:55 UTC (rev 1367)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2009-09-05 09:38:50 UTC (rev 1368)
@@ -28,7 +28,6 @@
import info.magnolia.cms.core.Content;
import info.magnolia.cms.core.HierarchyManager;
import info.magnolia.cms.core.ItemType;
-import info.magnolia.cms.core.MetaData;
import info.magnolia.cms.core.Path;
import info.magnolia.cms.core.SystemProperty;
import info.magnolia.cms.core.search.Query;
@@ -48,7 +47,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import javax.jcr.RepositoryException;
@@ -68,6 +66,7 @@
/**
+ * Page that renders the folder view
* @author molaschi
* @version $Id$
*/
@@ -173,6 +172,9 @@
}
}
+ /**
+ * Count medias for each media type
+ */
private void fillNumberOfMediaPerType()
{
numberOfMedia = new HashMap<String, Integer>();
@@ -353,7 +355,7 @@
}
/**
- * Copy or move a node (from AdminTreeMVCHandler
+ * Copy or move a node (from AdminTreeMVCHandler)
* @param source source node
* @param destination destination folder
* @param move move or copy?
@@ -379,11 +381,10 @@
{
if (destination.indexOf(source + "/") == 0)
{
- // todo: disable this possibility in javascript
// move source into destinatin not possible
return null;
}
- // TODO verificare se funziona lo stesso
+ // TODO verify if it works anyway
// this.deactivateNode(source);
try
{
@@ -417,6 +418,10 @@
return newContent;
}
+ /**
+ * Activates single media node
+ * @return view
+ */
@SuppressWarnings("unchecked")
public String activate()
{
@@ -447,6 +452,10 @@
return this.show();
}
+ /**
+ * Deactivates single media node
+ * @return view
+ */
@SuppressWarnings("unchecked")
public String deactivate()
{
@@ -468,6 +477,10 @@
return this.show();
}
+ /**
+ * Download media
+ * @return nothing, but attach downloadable file to response
+ */
public String download()
{
@@ -579,235 +592,6 @@
}
/**
- * @author molaschi
- * @version $Id$
- */
- public class MediaBean
- {
-
- private String handle;
-
- private String filename;
-
- private String description;
-
- private String thumbnailUrl;
-
- private String previewUrl;
-
- private Content content;
-
- private MetaData metaData;
-
- private String uuid;
-
- private List<String> usedInWebPages = new ArrayList<String>();
-
- private boolean canPublish;
-
- private boolean writable;
-
- /**
- * Returns the metaData.
- * @return the metaData
- */
- public MetaData getMetaData()
- {
- return metaData;
- }
-
- /**
- * Sets the metaData.
- * @param metaData the metaData to set
- */
- public void setMetaData(MetaData metaData)
- {
- this.metaData = metaData;
- }
-
- /**
- * Returns the handle.
- * @return the handle
- */
- public String getHandle()
- {
- return handle;
- }
-
- /**
- * Sets the handle.
- * @param handle the handle to set
- */
- public void setHandle(String handle)
- {
- this.handle = handle;
- }
-
- /**
- * Returns the filename.
- * @return the filename
- */
- public String getFilename()
- {
- return filename;
- }
-
- /**
- * Sets the filename.
- * @param filename the filename to set
- */
- public void setFilename(String filename)
- {
- this.filename = filename;
- }
-
- /**
- * Returns the description.
- * @return the description
- */
- public String getDescription()
- {
- return description;
- }
-
- /**
- * Sets the description.
- * @param description the description to set
- */
- public void setDescription(String description)
- {
- this.description = description;
- }
-
- /**
- * Returns the thumbnailUrl.
- * @return the thumbnailUrl
- */
- public String getThumbnailUrl()
- {
- return thumbnailUrl;
- }
-
- /**
- * Sets the thumbnailUrl.
- * @param thumbnailUrl the thumbnailUrl to set
- */
- public void setThumbnailUrl(String thumbnailUrl)
- {
- this.thumbnailUrl = thumbnailUrl;
- }
-
- /**
- * Returns the previewUrl.
- * @return the previewUrl
- */
- public String getPreviewUrl()
- {
- return previewUrl;
- }
-
- /**
- * Sets the previewUrl.
- * @param previewUrl the previewUrl to set
- */
- public void setPreviewUrl(String previewUrl)
- {
- this.previewUrl = previewUrl;
- }
-
- /**
- * Returns the content.
- * @return the content
- */
- public Content getContent()
- {
- return content;
- }
-
- /**
- * Sets the content.
- * @param content the content to set
- */
- public void setContent(Content content)
- {
- this.content = content;
- }
-
- /**
- * Returns the uuid.
- * @return the uuid
- */
- public String getUuid()
- {
- return uuid;
- }
-
- /**
- * Sets the uuid.
- * @param uuid the uuid to set
- */
- public void setUuid(String uuid)
- {
- this.uuid = uuid;
- }
-
- /**
- * Returns the usedInWebPages.
- * @return the usedInWebPages
- */
- public List<String> getUsedInWebPages()
- {
- return usedInWebPages;
- }
-
- /**
- * Sets the usedInWebPages.
- * @param usedInWebPages the usedInWebPages to set
- */
- public void setUsedInWebPages(List<String> usedInWebPages)
- {
- this.usedInWebPages = usedInWebPages;
- }
-
- /**
- * Returns the canPublish.
- * @return the canPublish
- */
- public boolean isCanPublish()
- {
- return canPublish;
- }
-
- /**
- * Sets the canPublish.
- * @param canPublish the canPublish to set
- */
- public void setCanPublish(boolean canPublish)
- {
- this.canPublish = canPublish;
- }
-
- /**
- * Returns the writable.
- * @return the writable
- */
- public boolean isWritable()
- {
- return writable;
- }
-
- /**
- * Sets the writable.
- * @param writable the writable to set
- */
- public void setWritable(boolean writable)
- {
- this.writable = writable;
- }
-
- }
-
- /**
* Returns the writable.
* @return the writable
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java 2009-09-05 08:58:55 UTC (rev 1367)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java 2009-09-05 09:38:50 UTC (rev 1368)
@@ -55,6 +55,7 @@
/**
+ * Search in medias and shows results
* @author molaschi
* @version $Id$
*/
@@ -95,6 +96,7 @@
/**
* {@inheritDoc}
*/
+ @SuppressWarnings("unchecked")
@Override
public String show()
{
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MessagesTemplatedMVCHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MessagesTemplatedMVCHandler.java 2009-09-05 08:58:55 UTC (rev 1367)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MessagesTemplatedMVCHandler.java 2009-09-05 09:38:50 UTC (rev 1368)
@@ -33,6 +33,7 @@
/**
+ * Make getMsgs method public
* @author molaschi
* @version $Id$
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java 2009-09-05 08:58:55 UTC (rev 1367)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java 2009-09-05 09:38:50 UTC (rev 1368)
@@ -35,6 +35,7 @@
/**
+ * Base implementation of {@link ImageResolutionProcessor}.
* @author molaschi
* @version $Id: $
*/
@@ -47,7 +48,7 @@
private Logger log = LoggerFactory.getLogger(BaseImageResolutionProcessor.class);
/**
- * Resize an image to fit into x,y not changing x/y
+ * Resize an image to fit into x,y not changing image original side proportion
* @param original original image
* @param x max width
* @param y max height
@@ -58,17 +59,30 @@
return resizeInOut(original, x, y, false, null);
}
- public BufferedImage resizeNoCrop(BufferedImage original, int x, int y)
+ /**
+ * Resize an image to fit into the rect x, y and fill empty spaces with given background color
+ * @param original original image
+ * @param x max width
+ * @param y max height
+ * @param background background to color empty spaces
+ * @return resized image
+ */
+ public BufferedImage fitIn(BufferedImage original, int x, int y, Color background)
{
- return resizeInOut(original, x, y, true, null);
- }
-
- public BufferedImage resizeNoCrop(BufferedImage original, int x, int y, Color background)
- {
return resizeInOut(original, x, y, true, background);
}
- protected BufferedImage resizeInOut(BufferedImage original, int x, int y, boolean external, Color background)
+ /**
+ * Resize image to fit in x,y. If fit is true the resulting image is x,y and if there are two empty bands they are
+ * filled with backgroung color.
+ * @param original original image
+ * @param x max width
+ * @param y max height
+ * @param fit fully fit x,y?
+ * @param background color to fill empty bands if fit is true
+ * @return image
+ */
+ protected BufferedImage resizeInOut(BufferedImage original, int x, int y, boolean fit, Color background)
{
if (original == null)
{
@@ -96,15 +110,15 @@
int newX = (int) Math.round(oX * ratio);
int newY = (int) Math.round(oY * ratio);
- return ImageUtils.resizeImage(original, newX, newY, external ? x : newX, external ? y : newY, background);
+ return ImageUtils.resizeImage(original, newX, newY, fit ? x : newX, fit ? y : newY, background);
}
/**
- * Resize an image to fill x or y and (if set) center and crop what is out
+ * Resize an image to fill x or y and (if set) center and if cropCentered is true crop what outfit
* @param original original image
* @param x min width
* @param y min height
- * @param cropCentered crop image
+ * @param cropCentered crop image?
* @return resized image
*/
public BufferedImage fill(BufferedImage original, int x, int y, boolean cropCentered)
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java 2009-09-05 08:58:55 UTC (rev 1367)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java 2009-09-05 09:38:50 UTC (rev 1368)
@@ -35,6 +35,8 @@
/**
+ * Implementation of {@link ImageResolutionProcessor} that render image to fully fit the required resolution, eventually
+ * adding colored bands.
* @author molaschi
* @version $Id: $
*/
@@ -66,6 +68,6 @@
log.error("Invalid color code: " + hexColor, e);
}
}
- return resizeInOut(original, x, y, false, color);
+ return fitIn(original, x, y, color);
}
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInImageResolutionProcessor.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInImageResolutionProcessor.java 2009-09-05 08:58:55 UTC (rev 1367)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInImageResolutionProcessor.java 2009-09-05 09:38:50 UTC (rev 1368)
@@ -30,6 +30,7 @@
/**
+ * Implementation of {@link ImageResolutionProcessor} that render image to fit inside the required resolution.
* @author molaschi
* @version $Id: $
*/
@@ -41,7 +42,7 @@
*/
public BufferedImage getImageForResolution(BufferedImage original, int x, int y, Map<String, String> parameters)
{
- return resizeInOut(original, x, y, false, null);
+ return fitIn(original, x, y, null);
}
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImagePostProcessor.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImagePostProcessor.java 2009-09-05 08:58:55 UTC (rev 1367)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImagePostProcessor.java 2009-09-05 09:38:50 UTC (rev 1368)
@@ -30,6 +30,8 @@
/**
+ * Interface for processors that are called after the image resize has happened. Maybe, you could choose to apply or
+ * skip the processor checking for a parameter in parameters map.
* @author molaschi
* @version $Id: $
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImageResolutionProcessor.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImageResolutionProcessor.java 2009-09-05 08:58:55 UTC (rev 1367)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImageResolutionProcessor.java 2009-09-05 09:38:50 UTC (rev 1368)
@@ -28,8 +28,12 @@
import java.awt.image.BufferedImage;
import java.util.Map;
+import net.sourceforge.openutils.mgnlmedia.media.configuration.ImageProcessorsManager;
+
/**
+ * Interface for processors that resize an image. The implementation are associated with a control char by module
+ * configuration managed by {@link ImageProcessorsManager}.
* @author molaschi
* @version $Id: $
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/LogSizePostProcessor.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/LogSizePostProcessor.java 2009-09-05 08:58:55 UTC (rev 1367)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/LogSizePostProcessor.java 2009-09-05 09:38:50 UTC (rev 1368)
@@ -33,6 +33,7 @@
/**
+ * Example post processor that logs required image size and resulting image size if the parameter "logsize" is specified
* @author molaschi
* @version $Id: $
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeCropCenteredImageResolutionProcessor.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeCropCenteredImageResolutionProcessor.java 2009-09-05 08:58:55 UTC (rev 1367)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeCropCenteredImageResolutionProcessor.java 2009-09-05 09:38:50 UTC (rev 1368)
@@ -30,6 +30,8 @@
/**
+ * Default {@link ImageResolutionProcessor} that resizes an image to contain the required resolution and then crops the
+ * simmetric bands that outfits.
* @author molaschi
* @version $Id: $
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeNoCropImageResolutionProcessor.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeNoCropImageResolutionProcessor.java 2009-09-05 08:58:55 UTC (rev 1367)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeNoCropImageResolutionProcessor.java 2009-09-05 09:38:50 UTC (rev 1368)
@@ -30,6 +30,8 @@
/**
+ * {@link ImageResolutionProcessor} that resizes an image to contain the required resolution. The resulting image should
+ * outfit required resolution
* @author molaschi
* @version $Id: $
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mol...@us...> - 2009-09-06 19:40:24
|
Revision: 1433
http://openutils.svn.sourceforge.net/openutils/?rev=1433&view=rev
Author: molaschi
Date: 2009-09-06 19:40:12 +0000 (Sun, 06 Sep 2009)
Log Message:
-----------
javadocs
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/JcrBrowserWithNodeTypeTreeConfiguration.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaBrowserConfiguration.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTree.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeMVCHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/BadImageFormatException.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java 2009-09-06 07:54:02 UTC (rev 1432)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java 2009-09-06 19:40:12 UTC (rev 1433)
@@ -46,6 +46,8 @@
/**
+ * {@link FieldSaveHandler} implementation that calls the onSavingPropertyMedia method on the handler of target media
+ * type when a media is associated to a page
* @author molaschi
* @version $Id$
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java 2009-09-06 07:54:02 UTC (rev 1432)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java 2009-09-06 19:40:12 UTC (rev 1433)
@@ -27,16 +27,12 @@
import info.magnolia.cms.core.Content;
import info.magnolia.cms.core.NodeData;
-import info.magnolia.cms.core.SystemProperty;
import info.magnolia.cms.core.search.Query;
import info.magnolia.cms.core.search.QueryManager;
import info.magnolia.cms.core.search.QueryResult;
import info.magnolia.module.InstallContext;
-import info.magnolia.module.delta.Delta;
-import info.magnolia.module.delta.DeltaBuilder;
import info.magnolia.module.delta.Task;
import info.magnolia.module.delta.TaskExecutionException;
-import info.magnolia.module.model.Version;
import it.openutils.mgnltasks.NodeSortTask;
import it.openutils.mgnltasks.SimpleModuleVersionHandler;
@@ -51,12 +47,12 @@
import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
import net.sourceforge.openutils.mgnlmedia.media.types.impl.BaseTypeHandler;
-import org.apache.commons.lang.ObjectUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
+ * Module version handler for media module
* @author manuel
* @version $Id
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2009-09-06 07:54:02 UTC (rev 1432)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2009-09-06 19:40:12 UTC (rev 1433)
@@ -33,8 +33,6 @@
import info.magnolia.context.MgnlContext;
import java.awt.Point;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -58,6 +56,7 @@
/**
+ * Class that holds media el functions methods
* @author molaschi
* @version $Id$
*/
@@ -107,7 +106,8 @@
}
/**
- * Get localized description for a media
+ * Get localized description for a media. If the locale is "it", it searches for a nodedata called description-it,
+ * or (if not found) description-en or (if not found) description.
* @param media media
* @param locale language
* @return description
@@ -131,7 +131,7 @@
}
/**
- * Get localized description for a media
+ * Get description for a media
* @param media media
* @return description
*/
@@ -141,7 +141,8 @@
}
/**
- * Get localized title for a media
+ * Get localized title for a media. If the locale is "it", it searches for a nodedata called title-it, or (if not
+ * found) title-en or (if not found) title.
* @param media media
* @param locale language
* @return title
@@ -165,7 +166,7 @@
}
/**
- * Get localized title for a media
+ * Get title for a media
* @param media media
* @return title
*/
@@ -175,7 +176,8 @@
}
/**
- * Get localized tags for a media
+ * Get localized tags for a media. If the locale is "it", it searches for a nodedata called tags-it, or (if not
+ * found) tags-en or (if not found) tags.
* @param media media
* @param locale language
* @return tags
@@ -200,7 +202,7 @@
}
/**
- * Get localized tags for a media
+ * Get tags for a media
* @param media media
* @return tags
*/
@@ -220,8 +222,9 @@
}
/**
- * Get url for a media
+ * Get url for a media, passing some parameters
* @param media media
+ * @param options optional parameters
* @return url
*/
public static String getUrl2(Content media, Map<String, String> options)
@@ -235,8 +238,9 @@
}
/**
- * @param media
- * @return String the thumbnail url for this media, null otherwise
+ * Get url to thumbnail
+ * @param media media to get the url for
+ * @return the thumbnail url for this media, null otherwise
*/
public static String getThumbnail(Content media)
{
@@ -249,8 +253,9 @@
}
/**
- * @param media
- * @return String the type of this media if existing, null otherwise
+ * Get media type
+ * @param media media to get the type
+ * @return the type of this media if existing, null otherwise
*/
public static String getType(Content media)
{
@@ -262,8 +267,9 @@
}
/**
- * @param media
- * @return
+ * Get all resolution strings (i.e. 'o200x350;background=45A97B') that generates cached resolutions
+ * @param media media to get the resolutions
+ * @return all resolution strings
*/
@SuppressWarnings("unchecked")
public static String[] listResolutions(Content media)
@@ -277,7 +283,14 @@
{
if (item.getName().startsWith("res-"))
{
- res.add(StringUtils.substringAfter(item.getName(), "-"));
+ if (item.getAttribute(ImageUtils.RESOLUTION_PROPERTY) != null)
+ {
+ res.add(item.getAttribute(ImageUtils.RESOLUTION_PROPERTY));
+ }
+ else
+ {
+ res.add(StringUtils.substringAfter(item.getName(), "-"));
+ }
}
}
@@ -375,8 +388,9 @@
}
/**
- * @param media
- * @return String the preview url for this media if existing, null otherwise
+ * Get url to media preview
+ * @param media media
+ * @return the preview url for this media if existing, null otherwise
*/
public static String getPreview(Content media)
{
@@ -389,7 +403,8 @@
}
/**
- * @param media
+ * Get an array of String(s) containing a list of web pages where this media is used, an empty array otherwise
+ * @param media media to search in web pages
* @return an array of String(s) containing a list of web pages where this media is used, an empty array otherwise
* @throws IllegalArgumentException if media is null
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/JcrBrowserWithNodeTypeTreeConfiguration.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/JcrBrowserWithNodeTypeTreeConfiguration.java 2009-09-06 07:54:02 UTC (rev 1432)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/JcrBrowserWithNodeTypeTreeConfiguration.java 2009-09-06 19:40:12 UTC (rev 1433)
@@ -39,6 +39,8 @@
/**
+ * Custom JCR tree browser configuration that adds management of media custom nodetypes (mgnl:media mgnl:resolutions)
+ * and adds a column showing node type
* @author molaschi
* @version $Id$
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaBrowserConfiguration.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaBrowserConfiguration.java 2009-09-06 07:54:02 UTC (rev 1432)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaBrowserConfiguration.java 2009-09-06 19:40:12 UTC (rev 1433)
@@ -38,6 +38,7 @@
/**
+ * Tree Configuration that shows folders and media but no resolutions
* @author molaschi
* @version $Id$
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTree.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTree.java 2009-09-06 07:54:02 UTC (rev 1432)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTree.java 2009-09-06 19:40:12 UTC (rev 1433)
@@ -43,6 +43,7 @@
/**
+ * The tree for media folders browsing
* @author molaschi
* @version $Id$
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java 2009-09-06 07:54:02 UTC (rev 1432)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java 2009-09-06 19:40:12 UTC (rev 1433)
@@ -48,6 +48,7 @@
/**
+ * Custom Tree configuration for media folders browsing
* @author molaschi
* @version $Id$
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeMVCHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeMVCHandler.java 2009-09-06 07:54:02 UTC (rev 1432)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeMVCHandler.java 2009-09-06 19:40:12 UTC (rev 1433)
@@ -34,6 +34,7 @@
/**
+ * Extends {@link AdminTreeMVCHandler} to include custom js and to route activate command to activateMedia command
* @author molaschi
* @version $Id$
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/BadImageFormatException.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/BadImageFormatException.java 2009-09-06 07:54:02 UTC (rev 1432)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/BadImageFormatException.java 2009-09-06 19:40:12 UTC (rev 1433)
@@ -26,6 +26,7 @@
package net.sourceforge.openutils.mgnlmedia.media.utils;
/**
+ * Exception for images with unknown format
* @author fgiust
* @version $Id$
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-09-06 07:54:02 UTC (rev 1432)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-09-06 19:40:12 UTC (rev 1433)
@@ -25,24 +25,6 @@
*/
package net.sourceforge.openutils.mgnlmedia.media.utils;
-/**
- * Copyright Openmind http://www.openmindonline.it
- *
- * 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
import info.magnolia.cms.beans.runtime.FileProperties;
import info.magnolia.cms.core.Content;
import info.magnolia.cms.core.HierarchyManager;
@@ -94,6 +76,7 @@
/**
+ * Main utility class that works with images and media nodes
* @author molaschi
* @version $Id$
*/
@@ -107,7 +90,7 @@
private static SimpleDateFormat sdf;
- private static String RESOLUTION_PROPERTY = "resolution";
+ public static String RESOLUTION_PROPERTY = "resolution";
private static final String[] extensions = new String[]{"jpg", "gif", "png" };
@@ -386,6 +369,11 @@
}
}
+ /**
+ * Get resolution nodedata name for a given resolution string
+ * @param resolution resolution string
+ * @return resolution nodedata name
+ */
public static String getResolutionPath(String resolution)
{
if (resolution.indexOf(';') > 0)
@@ -397,6 +385,13 @@
return resolution;
}
+ /**
+ * Get an inputstream for an image and the target file extension
+ * @param image image to get the inputstream from
+ * @param extension target file extension
+ * @return inputstream
+ * @throws IOException
+ */
public static InputStream getStream(BufferedImage image, String extension) throws IOException
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -432,11 +427,24 @@
return new ByteArrayInputStream(bos.toByteArray());
}
+ /**
+ * Check if the resolution for a media is already present. Otherwise create it
+ * @param media media to check the resolutoin on
+ * @param resolutionTarget target resolution
+ * @return false if resolution doesn't exist and there is a problem in generate it; true otherwise
+ */
public static boolean checkOrCreateResolution(final Content media, final String resolutionTarget)
{
return checkOrCreateResolution(media, resolutionTarget, BaseTypeHandler.ORGINAL_NODEDATA_NAME);
}
+ /**
+ * Check if the resolution for a media is already present. Otherwise create it
+ * @param media media to check the resolutoin on
+ * @param resolutionTarget target resolution
+ * @param nodeDataName nodedata where the image to resize is stored
+ * @return false if resolution doesn't exist and there is a problem in generate it; true otherwise
+ */
public static boolean checkOrCreateResolution(final Content media, final String resolutionTarget,
final String nodeDataName)
{
@@ -587,10 +595,10 @@
return true;
}
-/**
+ /**
* Get image for a resolution
* @param original original image
- * @param resolution resolution (if it starts with '<' does a fitIn else a fillAndCropCentered
+ * @param resolution resolution
* @return new image
*/
public static BufferedImage getImageForResolution(BufferedImage original, String resolution)
@@ -663,6 +671,12 @@
return img;
}
+ /**
+ * Get file extension for a resolution stored in a media node
+ * @param media media
+ * @param resolution resolution
+ * @return file extension for a resolution stored in a media node
+ */
public static String getExtension(Content media, String resolution)
{
try
@@ -678,8 +692,9 @@
}
/**
- * @param image
- * @return
+ * Create a buffered image from the binary data stored in nodedata
+ * @param image nodedata
+ * @return buffered image from the binary data stored in nodedata
*/
public static BufferedImage createBufferedImage(NodeData image)
{
@@ -708,6 +723,11 @@
}
}
+ /**
+ * Parse resolution string for required size
+ * @param res resolution string
+ * @return required size parsed from given resolution string
+ */
public static java.awt.Point parseForSize(String res)
{
Point size = new Point();
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java 2009-09-06 07:54:02 UTC (rev 1432)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java 2009-09-06 19:40:12 UTC (rev 1433)
@@ -52,6 +52,7 @@
/**
+ * Utility Class that manages loading files into media repository
* @author fgiust
* @version $Id$
*/
@@ -63,6 +64,16 @@
*/
private static Logger log = LoggerFactory.getLogger(MediaLoadUtils.class);
+ /**
+ * Load a file in media repository
+ * @param inputStream file input stream
+ * @param parent parent folder node
+ * @param filename filename
+ * @param overwrite overwrite if already exists?
+ * @return create media node
+ * @throws RepositoryException exception working on media repository
+ * @throws IOException exception working with file stream
+ */
public static Content loadEntry(InputStream inputStream, String parent, String filename, boolean overwrite)
throws RepositoryException, IOException
{
@@ -135,6 +146,14 @@
return null;
}
+ /**
+ * Get the content node matching required path using hierarchy manager. If the required path doesn't exist create
+ * it.
+ * @param mgr hierarchy manager
+ * @param path path to get or create
+ * @return content to required path
+ * @throws RepositoryException exception getting or creating path
+ */
public static Content getOrCreateFullPath(HierarchyManager mgr, String path) throws RepositoryException
{
String[] contentNodeNames = path.split("/");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mol...@us...> - 2009-10-08 14:21:34
|
Revision: 1468
http://openutils.svn.sourceforge.net/openutils/?rev=1468&view=rev
Author: molaschi
Date: 2009-10-08 14:21:20 +0000 (Thu, 08 Oct 2009)
Log Message:
-----------
MEDIA-25
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java 2009-10-02 14:57:50 UTC (rev 1467)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java 2009-10-08 14:21:20 UTC (rev 1468)
@@ -53,7 +53,7 @@
*/
public BufferedImage getImageForResolution(BufferedImage original, int x, int y, Map<String, String> parameters)
{
- Color color = Color.WHITE;
+ Color color = null;
String hexColor = parameters.get("background");
if (StringUtils.isNotBlank(hexColor))
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-10-02 14:57:50 UTC (rev 1467)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-10-08 14:21:20 UTC (rev 1468)
@@ -175,16 +175,28 @@
}
Graphics2D graphics2D = resizedImage.createGraphics();
- // background color
- if (background != null)
- {
- graphics2D.setBackground(background);
- }
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
if (canvasX > x || canvasY > y)
{
graphics2D.clearRect(0, 0, canvasX, canvasY);
+
+ // fill bands
+ if (background != null)
+ {
+ graphics2D.setColor(background);
+
+ if (canvasX > x)
+ {
+ graphics2D.fillRect(0, 0, (canvasX - x) / 2, canvasY);
+ graphics2D.fillRect(canvasX - (canvasX - x) / 2, 0, canvasX, canvasY);
+ }
+ if (canvasY > y)
+ {
+ graphics2D.fillRect(0, 0, canvasX, (canvasY - y) / 2);
+ graphics2D.fillRect(0, canvasY - (canvasY - y) / 2, canvasX, canvasY);
+ }
+ }
}
if (x > original.getWidth())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2009-12-30 19:48:17
|
Revision: 1563
http://openutils.svn.sourceforge.net/openutils/?rev=1563&view=rev
Author: fgiust
Date: 2009-12-30 19:48:09 +0000 (Wed, 30 Dec 2009)
Log Message:
-----------
properly cleanup temporary files
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java 2009-12-30 19:22:33 UTC (rev 1562)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java 2009-12-30 19:48:09 UTC (rev 1563)
@@ -48,6 +48,7 @@
import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
import net.sourceforge.openutils.mgnlmedia.media.utils.MediaLoadUtils;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
@@ -126,9 +127,10 @@
public String saveZip()
{
InputStream zipStream = null;
+ File temp = null;
try
{
- File temp = File.createTempFile("zipmedia", ".zip");
+ temp = File.createTempFile("zipmedia", ".zip");
FileOutputStream fos = new FileOutputStream(temp);
zipStream = zipFile.getStream();
@@ -184,6 +186,8 @@
IOUtils.closeQuietly(zipStream);
}
+ FileUtils.deleteQuietly(temp);
+
this.openPath = parentPath;
return this.show();
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java 2009-12-30 19:22:33 UTC (rev 1562)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java 2009-12-30 19:48:09 UTC (rev 1563)
@@ -45,6 +45,7 @@
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration;
import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
@@ -131,7 +132,7 @@
mgr.save();
- File f = File.createTempFile("entry", extension);
+ File f = File.createTempFile("entry", "." + extension);
FileOutputStream fTemp = new FileOutputStream(f);
IOUtils.copy(inputStream, fTemp);
@@ -141,6 +142,9 @@
mtc.getHandler().saveFromZipFile(media, f, cleanFilename, extension);
mgr.save();
+
+ FileUtils.deleteQuietly(f);
+
return media;
}
return null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2010-01-09 17:30:36
|
Revision: 1626
http://openutils.svn.sourceforge.net/openutils/?rev=1626&view=rev
Author: fgiust
Date: 2010-01-09 17:30:29 +0000 (Sat, 09 Jan 2010)
Log Message:
-----------
MEDIA-51 media:urlres EL expressions can't be used to generate scaled images of video previews
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/MediaTypeHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/MediaWithPreviewImageTypeHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2010-01-09 17:26:31 UTC (rev 1625)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2010-01-09 17:30:29 UTC (rev 1626)
@@ -46,6 +46,7 @@
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager;
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration;
import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
+import net.sourceforge.openutils.mgnlmedia.media.types.impl.BaseTypeHandler;
import net.sourceforge.openutils.mgnlmedia.media.utils.ImageUtils;
import org.apache.commons.collections.CollectionUtils;
@@ -316,7 +317,7 @@
*/
public static String getResolutionUrl(Content media, String resolution)
{
- FileProperties prop = new FileProperties(media, "image");
+ FileProperties prop = new FileProperties(media, BaseTypeHandler.ORGINAL_NODEDATA_NAME);
Integer width = NumberUtils.toInt(prop.getProperty(FileProperties.PROPERTY_WIDTH));
Integer height = NumberUtils.toInt(prop.getProperty(FileProperties.PROPERTY_HEIGHT));
Point size = ImageUtils.parseForSize(resolution);
@@ -325,7 +326,7 @@
return mcm.getURIMappingPrefix() + prop.getProperty(FileProperties.PATH);
}
- if (media == null || !ImageUtils.checkOrCreateResolution(media, resolution))
+ if (media == null || !ImageUtils.checkOrCreateResolution(media, resolution, null))
{
return null;
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/MediaTypeHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/MediaTypeHandler.java 2010-01-09 17:26:31 UTC (rev 1625)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/MediaTypeHandler.java 2010-01-09 17:30:29 UTC (rev 1626)
@@ -150,6 +150,12 @@
String getNewNodeName(MultipartForm form, HttpServletRequest request);
/**
+ * Get the name of the nodedata for the image used for preview
+ * @return the name of the nodedata for the image used for preview
+ */
+ String getPreviewImageNodeDataName();
+
+ /**
* Called when a media is going to be associated with a node
* @param media media
* @param parentNode node to be associated
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2010-01-09 17:26:31 UTC (rev 1625)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2010-01-09 17:30:29 UTC (rev 1626)
@@ -87,6 +87,11 @@
return request.getParameter(ORGINAL_NODEDATA_NAME + "_" + FileProperties.PROPERTY_FILENAME);
}
+ public String getPreviewImageNodeDataName()
+ {
+ return ORGINAL_NODEDATA_NAME;
+ }
+
/**
* {@inheritDoc}
*/
@@ -300,4 +305,5 @@
{
return getPropertyLocalized(media, "abstract");
}
+
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java 2010-01-09 17:26:31 UTC (rev 1625)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java 2010-01-09 17:30:29 UTC (rev 1626)
@@ -44,7 +44,7 @@
*/
public String getThumbnailUrl(Content media)
{
- if (!ImageUtils.checkOrCreateResolution(media, "thumbnail"))
+ if (!ImageUtils.checkOrCreateResolution(media, "thumbnail", BaseTypeHandler.ORGINAL_NODEDATA_NAME))
{
return StringUtils.EMPTY;
}
@@ -60,7 +60,7 @@
@Override
public String getPreviewUrl(Content media)
{
- if (!ImageUtils.checkOrCreateResolution(media, "preview"))
+ if (!ImageUtils.checkOrCreateResolution(media, "preview", BaseTypeHandler.ORGINAL_NODEDATA_NAME))
{
return StringUtils.EMPTY;
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/MediaWithPreviewImageTypeHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/MediaWithPreviewImageTypeHandler.java 2010-01-09 17:26:31 UTC (rev 1625)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/MediaWithPreviewImageTypeHandler.java 2010-01-09 17:30:29 UTC (rev 1626)
@@ -40,11 +40,16 @@
{
/**
+ * Nodedata name where preview media content is saved
+ */
+ public static final String PREVIEW_NODEDATA_NAME = "image";
+
+ /**
* {@inheritDoc}
*/
public String getThumbnailUrl(Content media)
{
- if (!ImageUtils.checkOrCreateResolution(media, "thumbnail", "image"))
+ if (!ImageUtils.checkOrCreateResolution(media, "thumbnail", PREVIEW_NODEDATA_NAME))
{
return StringUtils.EMPTY;
}
@@ -54,4 +59,9 @@
+ "/resolutions/thumbnail/data."
+ ImageUtils.getExtension(media, "thumbnail");
}
+
+ public String getPreviewImageNodeDataName()
+ {
+ return PREVIEW_NODEDATA_NAME;
+ }
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2010-01-09 17:26:31 UTC (rev 1625)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2010-01-09 17:30:29 UTC (rev 1626)
@@ -68,6 +68,7 @@
import net.sourceforge.openutils.mgnlmedia.media.configuration.ImageProcessorsManager;
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager;
+import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration;
import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
import net.sourceforge.openutils.mgnlmedia.media.processors.ImagePostProcessor;
import net.sourceforge.openutils.mgnlmedia.media.types.impl.BaseTypeHandler;
@@ -598,6 +599,7 @@
*/
public static boolean checkOrCreateResolution(final Content media, final String resolutionTarget)
{
+
return checkOrCreateResolution(media, resolutionTarget, BaseTypeHandler.ORGINAL_NODEDATA_NAME);
}
@@ -609,7 +611,7 @@
* @return false if resolution doesn't exist and there is a problem in generate it; true otherwise
*/
public static boolean checkOrCreateResolution(final Content media, final String resolutionTarget,
- final String nodeDataName)
+ String nodeDataName)
{
Content resolutions = media.getChildByName("resolutions");
@@ -638,6 +640,21 @@
return false;
}
+ if (nodeDataName == null)
+ {
+
+ MediaTypeConfiguration mtc = MediaConfigurationManager.getInstance().getMediaTypeConfigurationFromMedia(
+ media);
+ if (mtc == null)
+ {
+ nodeDataName = BaseTypeHandler.ORGINAL_NODEDATA_NAME;
+ }
+ else
+ {
+ nodeDataName = mtc.getHandler().getPreviewImageNodeDataName();
+ }
+ }
+
try
{
if (!media.hasNodeData(nodeDataName))
@@ -650,6 +667,8 @@
log.warn(e2.getMessage(), e2);
}
+ final String finalNodeDataName = nodeDataName;
+
try
{
ImageUtils.doInSystemContext(new MgnlContext.SystemContextOperation()
@@ -682,7 +701,7 @@
throw new RuntimeException(e);
}
- NodeData image = node.getNodeData(nodeDataName);
+ NodeData image = node.getNodeData(finalNodeDataName);
if (image.getContentLength() == 0)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <die...@us...> - 2010-02-01 19:03:55
|
Revision: 1751
http://openutils.svn.sourceforge.net/openutils/?rev=1751&view=rev
Author: diego_schivo
Date: 2010-02-01 19:03:44 +0000 (Mon, 01 Feb 2010)
Log Message:
-----------
MEDIA-67 Parse flv files for metadata at upload
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java
Added Paths:
-----------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMetaData.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java 2010-02-01 17:44:41 UTC (rev 1750)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java 2010-02-01 19:03:44 UTC (rev 1751)
@@ -19,6 +19,19 @@
package net.sourceforge.openutils.mgnlmedia.media.types.impl;
+import info.magnolia.cms.core.Content;
+import info.magnolia.cms.util.ContentUtil;
+import info.magnolia.cms.util.NodeDataUtil;
+import info.magnolia.context.MgnlContext;
+import info.magnolia.context.WebContext;
+
+import javax.servlet.http.HttpServletRequest;
+
+import net.sourceforge.openutils.mgnlmedia.media.utils.FLVMetaData;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Type handler for flv videos
* @author molaschi
@@ -27,4 +40,40 @@
public class VideoTypeHandler extends MediaWithPreviewImageTypeHandler
{
+ /**
+ * Logger.
+ */
+ private Logger log = LoggerFactory.getLogger(VideoTypeHandler.class);
+
+ @Override
+ public boolean onPostSave(Content media)
+ {
+ try
+ {
+ HttpServletRequest request = ((WebContext) MgnlContext.getInstance()).getRequest();
+ String baseUrl = request.getScheme() + "://" + request.getServerName();
+ if ("http".equals(request.getScheme()) && request.getServerPort() != 80)
+ {
+ baseUrl += ":" + request.getServerPort();
+ }
+
+ String url = baseUrl + request.getContextPath() + getUrl(media);
+ FLVMetaData flvMetaData = new FLVMetaData(url, true);
+
+ Content original = ContentUtil.getContent(media, "original");
+ if (original != null)
+ {
+ NodeDataUtil.getOrCreateAndSet(original, "width", flvMetaData.getWidth());
+ NodeDataUtil.getOrCreateAndSet(original, "height", flvMetaData.getHeight());
+ NodeDataUtil.getOrCreateAndSet(original, "duration", flvMetaData.getDuration());
+ original.save();
+ }
+ }
+ catch (Exception e)
+ {
+ log.error(e.getMessage(), e);
+ }
+ return super.onPostSave(media);
+ }
+
}
Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMetaData.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMetaData.java (rev 0)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMetaData.java 2010-02-01 19:03:44 UTC (rev 1751)
@@ -0,0 +1,300 @@
+/**
+ *
+ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html)
+ * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.sourceforge.openutils.mgnlmedia.media.utils;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.nio.ByteBuffer;
+import java.net.URL;
+import java.net.HttpURLConnection;
+import java.text.DecimalFormat;
+
+/**
+ * This class will get the FLV meta data information.
+ * @author SANTHOSH REDDY MANDADI
+ * @version 1.0
+ * @since 10th June 2009
+ */
+public class FLVMetaData
+{
+ /**
+ * Represents the FLV path either a URL or a absolute file path. If it is URL
+ * url property should be true to access the file from web
+ */
+ private String flv=null;
+
+ /**
+ * Represents whether the FLV is remote or local, if this is true
+ * data will be fetched through the HTTP connection otherwise data will
+ * be fetched from the local file.
+ */
+ private boolean url=true;
+
+ //All the FLV properties
+ private String duration;
+ private double width;
+ private double height;
+ private double audioDataRate;
+ private double videoDataRate;
+ private double fileSize;
+ private String createdDate;
+ private String mimeType;
+ private double frameRate;
+
+ /**
+ * Constructs an object with flv as a url
+ * @param flv represents the web url
+ * @since 10-Jun-2009
+ */
+ public FLVMetaData(String flv) throws Exception
+ {
+ this.flv=flv;
+ getMetaData();
+ }
+
+ /**
+ * Constructs an object with flv and boolean value url.
+ * @param flv represents the FLV path either a URL or a absolute file path.
+ * @param url represents boolean value.
+ */
+ public FLVMetaData(String flv, boolean url) throws Exception
+ {
+ this.flv=flv;
+ this.url=url;
+ getMetaData();
+ }
+
+ /**
+ * Extract the metadata for the flv and sets them in the properties.
+ * If the property has 0.0 or null, then the information is not available on
+ * the target FLV.
+ * @throws Exception if something goes wrong.
+ */
+ private void getMetaData() throws Exception
+ {
+ InputStream fis=null;
+ try{
+ if(url)
+ {
+ //Creating the URL object
+ URL url = new URL(flv);
+ //Establishing the connection to the server
+ HttpURLConnection connection=(HttpURLConnection)url.openConnection();
+ //Getting the remote input stream
+ fis=connection.getInputStream();
+ }
+ else
+ {
+ fis=new FileInputStream(flv);
+ }
+ //Creating the bytes array to read the first 400 bytes data from input stream
+ byte bytes[]=new byte[400];
+ //Reading the data from the input stream
+ fis.read(bytes);
+
+ /*Fetching the properties. If the output shows -1 or null then
+ consider that the FLV doesn't have that info on metadata*/
+ double duration=getDouble(bytes,"duration");
+ DecimalFormat f = new DecimalFormat("00");
+ setDuration(f.format((int)duration/60)+":"+f.format((int)duration%60));
+ setWidth(getDouble(bytes,"width"));
+ setHeight(getDouble(bytes,"height"));
+ setAudioDataRate(getDouble(bytes,"audiodatarate"));
+ setVideoDataRate(getDouble(bytes,"videodatarate"));
+ setFileSize(getDouble(bytes,"filesize"));
+ setCreatedDate(getString(bytes,"creationdate"));
+ setMimeType(getString(bytes,"mimetype"));
+ setFrameRate(getDouble(bytes,"framerate"));
+
+ //Closing the remote input stream
+ fis.close();
+ }catch(Exception e) {
+ throw new Exception(e);
+ }
+ finally {
+ if(fis!=null) {
+ fis.close();
+ }
+ }
+ }
+ private double getDouble(byte[] bytes, String property)
+ {
+ //Creating a string from the bytes
+ String metaData=new String(bytes);
+ //Checking whether the property exists on the metadata
+ int offset=metaData.indexOf(property);
+ if(offset!=-1)
+ {
+ //Calculating the value from the bytes received from getBytes method
+ return ByteBuffer.wrap(getBytes(bytes, offset+property.length()+1, 8)).getDouble();
+ }
+ else
+ {
+ //Returning -1 to notify the info not available
+ return -1;
+ }
+ }
+ private String getString(byte[] bytes, String property)
+ {
+ //Creating a string from the bytes
+ String metaData=new String(bytes);
+ //Checking whether the property exists on the metadata
+ int offset=metaData.indexOf(property);
+ if(offset!=-1)
+ {
+ //Constructing the string from the bytes received from getBytes method
+ return new String(getBytes(bytes, offset+property.length()+3, 24));
+ }
+ else
+ {
+ //Returning null to notify the info not available
+ return null;
+ }
+ }
+ private byte[] getBytes(byte[] bytes, int offset, int length)
+ {
+ //Fetching the required number of bytes from the source and returning
+ byte requiredBytes[]=new byte[length];
+ for(int i=offset, j=0;j<length;i++,j++)
+ {
+ requiredBytes[j]=bytes[i];
+ }
+ return requiredBytes;
+ }
+
+ public void setFlv(String flv)
+ {
+ this.flv = flv;
+ }
+
+ public String getFlv()
+ {
+ return flv;
+ }
+
+ public void setUrl(boolean url)
+ {
+ this.url = url;
+ }
+
+ public boolean isUrl()
+ {
+ return url;
+ }
+
+ public void setCreatedDate(String createdDate)
+ {
+ this.createdDate = createdDate;
+ }
+
+ public String getCreatedDate()
+ {
+ return createdDate;
+ }
+
+ public void setMimeType(String mimeType)
+ {
+ this.mimeType = mimeType;
+ }
+
+ public String getMimeType()
+ {
+ return mimeType;
+ }
+
+ public void setWidth(double width)
+ {
+ this.width = width;
+ }
+
+ public double getWidth()
+ {
+ return width;
+ }
+
+ public void setHeight(double height)
+ {
+ this.height = height;
+ }
+
+ public double getHeight()
+ {
+ return height;
+ }
+
+ public void setAudioDataRate(double audioDataRate)
+ {
+ this.audioDataRate = audioDataRate;
+ }
+
+ public double getAudioDataRate()
+ {
+ return audioDataRate;
+ }
+
+ public void setVideoDataRate(double videoDataRate)
+ {
+ this.videoDataRate = videoDataRate;
+ }
+
+ public double getVideoDataRate()
+ {
+ return videoDataRate;
+ }
+
+ public void setFileSize(double fileSize)
+ {
+ this.fileSize = fileSize;
+ }
+
+ public double getFileSize()
+ {
+ return fileSize;
+ }
+
+ public void setFrameRate(double frameRate)
+ {
+ this.frameRate = frameRate;
+ }
+
+ public double getFrameRate()
+ {
+ return frameRate;
+ }
+
+ public void setDuration(String duration)
+ {
+ this.duration = duration;
+ }
+
+ public String getDuration()
+ {
+ return duration;
+ }
+
+ public static void main(String args[]) throws Exception
+ {
+ FLVMetaData metaData=new FLVMetaData("http://domain/o18/HCINTL/LIVE/72224/myhc_200.flv");
+ System.out.println(metaData.getDuration());
+ metaData.setUrl(false);
+ metaData.setFlv("1.flv");
+ metaData.getMetaData();
+ System.out.println(metaData.getDuration());
+ }
+}
\ No newline at end of file
Property changes on: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2010-02-01 22:02:41
|
Revision: 1753
http://openutils.svn.sourceforge.net/openutils/?rev=1753&view=rev
Author: fgiust
Date: 2010-02-01 22:02:34 +0000 (Mon, 01 Feb 2010)
Log Message:
-----------
MEDIA-67 a bit of refactoring... but I can't get any valid info from the test flv, needs to be checked
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java
Added Paths:
-----------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMedataUtils.java
Removed Paths:
-------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMetaData.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2010-02-01 21:00:06 UTC (rev 1752)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2010-02-01 22:02:34 UTC (rev 1753)
@@ -65,7 +65,7 @@
*/
private Logger log = LoggerFactory.getLogger(BaseTypeHandler.class);
- private String type = null;
+ private String type;
/**
* {@inheritDoc}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java 2010-02-01 21:00:06 UTC (rev 1752)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java 2010-02-01 22:02:34 UTC (rev 1753)
@@ -19,19 +19,23 @@
package net.sourceforge.openutils.mgnlmedia.media.types.impl;
+import info.magnolia.cms.beans.runtime.FileProperties;
import info.magnolia.cms.core.Content;
+import info.magnolia.cms.core.NodeData;
import info.magnolia.cms.util.ContentUtil;
import info.magnolia.cms.util.NodeDataUtil;
-import info.magnolia.context.MgnlContext;
-import info.magnolia.context.WebContext;
-import javax.servlet.http.HttpServletRequest;
+import java.io.InputStream;
-import net.sourceforge.openutils.mgnlmedia.media.utils.FLVMetaData;
+import net.sourceforge.openutils.mgnlmedia.media.utils.FLVMedataUtils;
+import net.sourceforge.openutils.mgnlmedia.media.utils.FLVMedataUtils.FLVMetaData;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.time.DurationFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
/**
* Type handler for flv videos
* @author molaschi
@@ -45,29 +49,60 @@
*/
private Logger log = LoggerFactory.getLogger(VideoTypeHandler.class);
+ protected final String DURATION_ATTRIBUTE = "duration";
+
@Override
public boolean onPostSave(Content media)
{
try
{
- HttpServletRequest request = ((WebContext) MgnlContext.getInstance()).getRequest();
- String baseUrl = request.getScheme() + "://" + request.getServerName();
- if ("http".equals(request.getScheme()) && request.getServerPort() != 80)
+ // HttpServletRequest request = ((WebContext) MgnlContext.getInstance()).getRequest();
+ // String baseUrl = request.getScheme() + "://" + request.getServerName();
+ // if ("http".equals(request.getScheme()) && request.getServerPort() != 80)
+ // {
+ // baseUrl += ":" + request.getServerPort();
+ // }
+
+ // String url = baseUrl + request.getContextPath() + getUrl(media);
+ // FLVMetaData flvMetaData = new FLVMetaData(url, true);
+
+ NodeData originalFileNodeData = getOriginalFileNodeData(media);
+
+ if (originalFileNodeData != null)
{
- baseUrl += ":" + request.getServerPort();
- }
+ InputStream stream = originalFileNodeData.getStream();
- String url = baseUrl + request.getContextPath() + getUrl(media);
- FLVMetaData flvMetaData = new FLVMetaData(url, true);
+ FLVMetaData flvMetaData = null;
- Content original = ContentUtil.getContent(media, "original");
- if (original != null)
- {
- NodeDataUtil.getOrCreateAndSet(original, "width", flvMetaData.getWidth());
- NodeDataUtil.getOrCreateAndSet(original, "height", flvMetaData.getHeight());
- NodeDataUtil.getOrCreateAndSet(original, "duration", flvMetaData.getDuration());
- original.save();
+ try
+ {
+ flvMetaData = FLVMedataUtils.parseFLVfromStream(stream);
+ }
+ catch (Throwable e)
+ {
+ log.warn("Error parsing FLV file "
+ + originalFileNodeData.getHandle()
+ + " "
+ + e.getClass().getName()
+ + " "
+ + e.getMessage(), e);
+ }
+ finally
+ {
+ IOUtils.closeQuietly(stream);
+ }
+
+ // duh, we should be able to set properties on binary nodedata but at the moment there is no
+ // setAttribute(Long) in the interface!
+ Content originalAsNode = ContentUtil.getContent(media, BaseTypeHandler.ORGINAL_NODEDATA_NAME);
+
+ NodeDataUtil.getOrCreateAndSet(originalAsNode, FileProperties.PROPERTY_WIDTH, flvMetaData.getWidth());
+ NodeDataUtil.getOrCreateAndSet(originalAsNode, FileProperties.PROPERTY_HEIGHT, flvMetaData.getHeight());
+ NodeDataUtil.getOrCreateAndSet(originalAsNode, DURATION_ATTRIBUTE, flvMetaData.getDuration());
+ originalAsNode.save();
+
}
+
}
catch (Exception e)
{
@@ -76,4 +111,53 @@
return super.onPostSave(media);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getMediaInfo(Content media)
+ {
+
+ Content originalAsNode = ContentUtil.getContent(media, BaseTypeHandler.ORGINAL_NODEDATA_NAME);
+
+ String ext = originalAsNode.getNodeData(FileProperties.PROPERTY_EXTENSION).getString();
+ long width = originalAsNode.getNodeData(FileProperties.PROPERTY_WIDTH).getLong();
+ long height = originalAsNode.getNodeData(FileProperties.PROPERTY_HEIGHT).getLong();
+ long duration = originalAsNode.getNodeData(DURATION_ATTRIBUTE).getLong();
+ long size = originalAsNode.getNodeData(FileProperties.PROPERTY_SIZE).getLong();
+
+ return ext
+ + (width > 0 ? (" " + width + "x" + height) : "")
+ + " length: "
+ + DurationFormatUtils.formatDuration(duration, "m:s ")
+ + "size: "
+ + toSizeString(size);
+ }
+
+ /*
+ * todo: move to an utility class
+ */
+ private String toSizeString(long size)
+ {
+ String unit = "bytes";
+ String sizeStr;
+ if (size >= 1000)
+ {
+ size = size / 1024;
+ unit = "KB";
+ if (size >= 1000)
+ {
+ size = size / 1024;
+ unit = "MB";
+ }
+ sizeStr = Double.toString(size);
+ sizeStr = sizeStr.substring(0, sizeStr.indexOf(".") + 2); //$NON-NLS-1$
+ }
+ else
+ {
+ sizeStr = Double.toString(size);
+ sizeStr = sizeStr.substring(0, sizeStr.indexOf(".")); //$NON-NLS-1$
+ }
+ return sizeStr + " " + unit;
+ }
}
Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMedataUtils.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMedataUtils.java (rev 0)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMedataUtils.java 2010-02-01 22:02:34 UTC (rev 1753)
@@ -0,0 +1,265 @@
+package net.sourceforge.openutils.mgnlmedia.media.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.ByteBuffer;
+
+import org.apache.commons.io.IOUtils;
+
+
+/**
+ * <p>
+ * Parses FLV metadata in order to extract size and duration.
+ * </p>
+ * <p>
+ * Code based on FLVMetaData class by SANTHOSH REDDY MANDADI
+ * http://java-servlet-jsp-web.blogspot.com/2009/06/java-program-to-fetch-flv-metadata.html
+ * </p>
+ * @author fgiust
+ * @version $Id$
+ */
+public final class FLVMedataUtils
+{
+
+ /**
+ * Contains informations about a FLV file.
+ */
+ public static class FLVMetaData
+ {
+
+ private long duration;
+
+ private long width;
+
+ private long height;
+
+ private double audioDataRate;
+
+ private double videoDataRate;
+
+ private long fileSize;
+
+ private String createdDate;
+
+ private String mimeType;
+
+ private double frameRate;
+
+ public void setCreatedDate(String createdDate)
+ {
+ this.createdDate = createdDate;
+ }
+
+ public String getCreatedDate()
+ {
+ return createdDate;
+ }
+
+ public void setMimeType(String mimeType)
+ {
+ this.mimeType = mimeType;
+ }
+
+ public String getMimeType()
+ {
+ return mimeType;
+ }
+
+ public void setWidth(long width)
+ {
+ this.width = width;
+ }
+
+ public double getWidth()
+ {
+ return width;
+ }
+
+ public void setHeight(long height)
+ {
+ this.height = height;
+ }
+
+ public long getHeight()
+ {
+ return height;
+ }
+
+ public void setAudioDataRate(double audioDataRate)
+ {
+ this.audioDataRate = audioDataRate;
+ }
+
+ public double getAudioDataRate()
+ {
+ return audioDataRate;
+ }
+
+ public void setVideoDataRate(double videoDataRate)
+ {
+ this.videoDataRate = videoDataRate;
+ }
+
+ public double getVideoDataRate()
+ {
+ return videoDataRate;
+ }
+
+ public void setFileSize(long fileSize)
+ {
+ this.fileSize = fileSize;
+ }
+
+ public long getFileSize()
+ {
+ return fileSize;
+ }
+
+ public void setFrameRate(double frameRate)
+ {
+ this.frameRate = frameRate;
+ }
+
+ public double getFrameRate()
+ {
+ return frameRate;
+ }
+
+ public void setDuration(long duration)
+ {
+ this.duration = duration;
+ }
+
+ public long getDuration()
+ {
+ return duration;
+ }
+
+ }
+
+ public static FLVMetaData parseFLVfromStream(InputStream stream) throws IOException
+ {
+ return getMetaData(stream);
+ }
+
+ public static FLVMetaData parseFLVfromUrl(URL url) throws IOException
+ {
+ URLConnection connection = url.openConnection();
+ // Getting the remote input stream
+ InputStream fis = connection.getInputStream();
+ try
+ {
+ return parseFLVfromStream(fis);
+ }
+ finally
+ {
+ IOUtils.closeQuietly(fis);
+ }
+
+ }
+
+ /**
+ * Extract the metadata for the flv and sets them in the properties. If the property has 0.0 or null, then the
+ * information is not available on the target FLV.
+ * @throws IOException
+ * @throws Exception if something goes wrong.
+ */
+ private static FLVMetaData getMetaData(InputStream fis) throws IOException
+ {
+ FLVMetaData meta = new FLVMetaData();
+ try
+ {
+ // Creating the bytes array to read the first 400 bytes data from input stream
+ byte[] bytes = new byte[400];
+ // Reading the data from the input stream
+ fis.read(bytes);
+
+ // Fetching the properties. If the output shows -1 or null then consider that the FLV doesn't have that
+ // info on metadata
+ meta.setDuration(getLong(bytes, "duration"));
+ meta.setWidth(getLong(bytes, "width"));
+ meta.setHeight(getLong(bytes, "height"));
+ meta.setAudioDataRate(getDouble(bytes, "audiodatarate"));
+ meta.setVideoDataRate(getDouble(bytes, "videodatarate"));
+ meta.setFileSize(getLong(bytes, "filesize"));
+ meta.setCreatedDate(getString(bytes, "creationdate"));
+ meta.setMimeType(getString(bytes, "mimetype"));
+ meta.setFrameRate(getDouble(bytes, "framerate"));
+
+ }
+ finally
+ {
+ IOUtils.closeQuietly(fis);
+ }
+
+ return meta;
+ }
+
+ private static double getDouble(byte[] bytes, String property)
+ {
+ // Creating a string from the bytes
+ String metaData = new String(bytes);
+ // Checking whether the property exists on the metadata
+ int offset = metaData.indexOf(property);
+ if (offset != -1)
+ {
+ // Calculating the value from the bytes received from getBytes method
+ return ByteBuffer.wrap(getBytes(bytes, offset + property.length() + 1, 8)).getDouble();
+ }
+ else
+ {
+ // Returning -1 to notify the info not available
+ return -1;
+ }
+ }
+
+ private static long getLong(byte[] bytes, String property)
+ {
+ // Creating a string from the bytes
+ String metaData = new String(bytes);
+ // Checking whether the property exists on the metadata
+ int offset = metaData.indexOf(property);
+ if (offset != -1)
+ {
+ // Calculating the value from the bytes received from getBytes method
+ return (long) ByteBuffer.wrap(getBytes(bytes, offset + property.length() + 1, 8)).getDouble();
+ }
+ else
+ {
+ // Returning -1 to notify the info not available
+ return -1;
+ }
+ }
+
+ private static String getString(byte[] bytes, String property)
+ {
+ // Creating a string from the bytes
+ String metaData = new String(bytes);
+ // Checking whether the property exists on the metadata
+ int offset = metaData.indexOf(property);
+ if (offset != -1)
+ {
+ // Constructing the string from the bytes received from getBytes method
+ return new String(getBytes(bytes, offset + property.length() + 3, 24));
+ }
+ else
+ {
+ // Returning null to notify the info not available
+ return null;
+ }
+ }
+
+ private static byte[] getBytes(byte[] bytes, int offset, int length)
+ {
+ // Fetching the required number of bytes from the source and returning
+ byte[] requiredBytes = new byte[length];
+ for (int i = offset, j = 0; j < length; i++, j++)
+ {
+ requiredBytes[j] = bytes[i];
+ }
+ return requiredBytes;
+ }
+
+}
Property changes on: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMedataUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Deleted: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMetaData.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMetaData.java 2010-02-01 21:00:06 UTC (rev 1752)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMetaData.java 2010-02-01 22:02:34 UTC (rev 1753)
@@ -1,310 +0,0 @@
-/**
- *
- * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html)
- * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it
- *
- * 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 3 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, see <http://www.gnu.org/licenses/>.
- */
-
-package net.sourceforge.openutils.mgnlmedia.media.utils;
-
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.nio.ByteBuffer;
-import java.text.DecimalFormat;
-
-
-/**
- * This class will get the FLV meta data information.
- * @author SANTHOSH REDDY MANDADI
- * @version 1.0
- * @since 10th June 2009
- */
-public class FLVMetaData
-{
-
- /**
- * Represents the FLV path either a URL or a absolute file path. If it is URL url property should be true to access
- * the file from web
- */
- private String flv = null;
-
- /**
- * Represents whether the FLV is remote or local, if this is true data will be fetched through the HTTP connection
- * otherwise data will be fetched from the local file.
- */
- private boolean url = true;
-
- // All the FLV properties
- private String duration;
-
- private double width;
-
- private double height;
-
- private double audioDataRate;
-
- private double videoDataRate;
-
- private double fileSize;
-
- private String createdDate;
-
- private String mimeType;
-
- private double frameRate;
-
- /**
- * Constructs an object with flv as a url
- * @param flv represents the web url
- * @since 10-Jun-2009
- */
- public FLVMetaData(String flv) throws Exception
- {
- this.flv = flv;
- getMetaData();
- }
-
- /**
- * Constructs an object with flv and boolean value url.
- * @param flv represents the FLV path either a URL or a absolute file path.
- * @param url represents boolean value.
- */
- public FLVMetaData(String flv, boolean url) throws Exception
- {
- this.flv = flv;
- this.url = url;
- getMetaData();
- }
-
- /**
- * Extract the metadata for the flv and sets them in the properties. If the property has 0.0 or null, then the
- * information is not available on the target FLV.
- * @throws Exception if something goes wrong.
- */
- private void getMetaData() throws Exception
- {
- InputStream fis = null;
- try
- {
- if (url)
- {
- // Creating the URL object
- URL url = new URL(flv);
- // Establishing the connection to the server
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- // Getting the remote input stream
- fis = connection.getInputStream();
- }
- else
- {
- fis = new FileInputStream(flv);
- }
- // Creating the bytes array to read the first 400 bytes data from input stream
- byte bytes[] = new byte[400];
- // Reading the data from the input stream
- fis.read(bytes);
-
- /*
- * Fetching the properties. If the output shows -1 or null then consider that the FLV doesn't have that info
- * on metadata
- */
- double duration = getDouble(bytes, "duration");
- DecimalFormat f = new DecimalFormat("00");
- setDuration(f.format((int) duration / 60) + ":" + f.format((int) duration % 60));
- setWidth(getDouble(bytes, "width"));
- setHeight(getDouble(bytes, "height"));
- setAudioDataRate(getDouble(bytes, "audiodatarate"));
- setVideoDataRate(getDouble(bytes, "videodatarate"));
- setFileSize(getDouble(bytes, "filesize"));
- setCreatedDate(getString(bytes, "creationdate"));
- setMimeType(getString(bytes, "mimetype"));
- setFrameRate(getDouble(bytes, "framerate"));
-
- // Closing the remote input stream
- fis.close();
- }
- catch (Exception e)
- {
- throw new Exception(e);
- }
- finally
- {
- if (fis != null)
- {
- fis.close();
- }
- }
- }
-
- private double getDouble(byte[] bytes, String property)
- {
- // Creating a string from the bytes
- String metaData = new String(bytes);
- // Checking whether the property exists on the metadata
- int offset = metaData.indexOf(property);
- if (offset != -1)
- {
- // Calculating the value from the bytes received from getBytes method
- return ByteBuffer.wrap(getBytes(bytes, offset + property.length() + 1, 8)).getDouble();
- }
- else
- {
- // Returning -1 to notify the info not available
- return -1;
- }
- }
-
- private String getString(byte[] bytes, String property)
- {
- // Creating a string from the bytes
- String metaData = new String(bytes);
- // Checking whether the property exists on the metadata
- int offset = metaData.indexOf(property);
- if (offset != -1)
- {
- // Constructing the string from the bytes received from getBytes method
- return new String(getBytes(bytes, offset + property.length() + 3, 24));
- }
- else
- {
- // Returning null to notify the info not available
- return null;
- }
- }
-
- private byte[] getBytes(byte[] bytes, int offset, int length)
- {
- // Fetching the required number of bytes from the source and returning
- byte requiredBytes[] = new byte[length];
- for (int i = offset, j = 0; j < length; i++, j++)
- {
- requiredBytes[j] = bytes[i];
- }
- return requiredBytes;
- }
-
- public void setFlv(String flv)
- {
- this.flv = flv;
- }
-
- public String getFlv()
- {
- return flv;
- }
-
- public void setUrl(boolean url)
- {
- this.url = url;
- }
-
- public boolean isUrl()
- {
- return url;
- }
-
- public void setCreatedDate(String createdDate)
- {
- this.createdDate = createdDate;
- }
-
- public String getCreatedDate()
- {
- return createdDate;
- }
-
- public void setMimeType(String mimeType)
- {
- this.mimeType = mimeType;
- }
-
- public String getMimeType()
- {
- return mimeType;
- }
-
- public void setWidth(double width)
- {
- this.width = width;
- }
-
- public double getWidth()
- {
- return width;
- }
-
- public void setHeight(double height)
- {
- this.height = height;
- }
-
- public double getHeight()
- {
- return height;
- }
-
- public void setAudioDataRate(double audioDataRate)
- {
- this.audioDataRate = audioDataRate;
- }
-
- public double getAudioDataRate()
- {
- return audioDataRate;
- }
-
- public void setVideoDataRate(double videoDataRate)
- {
- this.videoDataRate = videoDataRate;
- }
-
- public double getVideoDataRate()
- {
- return videoDataRate;
- }
-
- public void setFileSize(double fileSize)
- {
- this.fileSize = fileSize;
- }
-
- public double getFileSize()
- {
- return fileSize;
- }
-
- public void setFrameRate(double frameRate)
- {
- this.frameRate = frameRate;
- }
-
- public double getFrameRate()
- {
- return frameRate;
- }
-
- public void setDuration(String duration)
- {
- this.duration = duration;
- }
-
- public String getDuration()
- {
- return duration;
- }
-
-}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <die...@us...> - 2010-02-03 10:17:42
|
Revision: 1786
http://openutils.svn.sourceforge.net/openutils/?rev=1786&view=rev
Author: diego_schivo
Date: 2010-02-03 10:17:35 +0000 (Wed, 03 Feb 2010)
Log Message:
-----------
MEDIA-54 We should deprecated the autoactivate property and add a better named "singleinstance" one.
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java 2010-02-03 10:09:18 UTC (rev 1785)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java 2010-02-03 10:17:35 UTC (rev 1786)
@@ -42,7 +42,7 @@
private Logger log = LoggerFactory.getLogger(MediaModule.class);
- private boolean autoactivate;
+ private boolean singleinstance;
private static MediaModule instance;
@@ -85,24 +85,46 @@
}
/**
+ * @deprecated use singleinstance
* Returns the autoactivate.
* @return the autoactivate
*/
+ @Deprecated
public boolean isAutoactivate()
{
- return autoactivate;
+ return singleinstance;
}
/**
+ * @deprecated use singleinstance
* Sets the autoactivate.
* @param autoactivate the autoactivate to set
*/
+ @Deprecated
public void setAutoactivate(boolean autoactivate)
{
- this.autoactivate = autoactivate;
+ this.singleinstance = autoactivate;
}
/**
+ * Returns the singleinstance.
+ * @return the singleinstance
+ */
+ public boolean isSingleinstance()
+ {
+ return singleinstance;
+ }
+
+ /**
+ * Sets the singleinstance.
+ * @param singleinstance the singleinstance to set
+ */
+ public void setSingleinstance(boolean singleinstance)
+ {
+ this.singleinstance = singleinstance;
+ }
+
+ /**
* Returns the version.
* @return the version
*/
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-02-03 10:09:18 UTC (rev 1785)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-02-03 10:17:35 UTC (rev 1786)
@@ -256,7 +256,7 @@
try
{
mb.setWritable(media.getParent().isGranted(Permission.WRITE));
- mb.setCanPublish(!MediaModule.getInstance().isAutoactivate()
+ mb.setCanPublish(!MediaModule.getInstance().isSingleinstance()
&& mb.isWritable()
&& ActivationManagerFactory.getActivationManager().hasAnyActiveSubscriber());
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java 2010-02-03 10:09:18 UTC (rev 1785)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java 2010-02-03 10:17:35 UTC (rev 1786)
@@ -214,7 +214,7 @@
tree.addMenuItem(menuCut);
tree.addMenuItem(menuCopy);
- if (!MediaModule.getInstance().isAutoactivate())
+ if (!MediaModule.getInstance().isSingleinstance())
{
tree.addSeparator();
tree.addMenuItem(menuActivateExcl);
@@ -255,7 +255,7 @@
tree.addColumn(column0);
- if (!browseMode && !MediaModule.getInstance().isAutoactivate())
+ if (!browseMode && !MediaModule.getInstance().isSingleinstance())
{
if (ServerConfiguration.getInstance().isAdmin()
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2010-02-03 10:09:18 UTC (rev 1785)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2010-02-03 10:17:35 UTC (rev 1786)
@@ -136,7 +136,7 @@
media.save();
}
- if (MediaModule.getInstance().isAutoactivate())
+ if (MediaModule.getInstance().isSingleinstance())
{
media.getMetaData().setActivated();
media.save();
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java 2010-02-03 10:09:18 UTC (rev 1785)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java 2010-02-03 10:17:35 UTC (rev 1786)
@@ -119,7 +119,7 @@
nd = NodeDataUtil.getOrCreate(media, "modificationDate");
nd.setValue(Calendar.getInstance());
- if (MediaModule.getInstance().isAutoactivate())
+ if (MediaModule.getInstance().isSingleinstance())
{
media.getMetaData().setActivated();
}
@@ -165,7 +165,7 @@
contentNodeName,
MediaConfigurationManager.FOLDER);
- if (MediaModule.getInstance().isAutoactivate() && !currContent.getMetaData().getIsActivated())
+ if (MediaModule.getInstance().isSingleinstance() && !currContent.getMetaData().getIsActivated())
{
currContent.getMetaData().setActivated();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2010-02-13 13:09:42
|
Revision: 1906
http://openutils.svn.sourceforge.net/openutils/?rev=1906&view=rev
Author: fgiust
Date: 2010-02-13 13:09:35 +0000 (Sat, 13 Feb 2010)
Log Message:
-----------
MEDIA-14 Better image naming
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileImage.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/MediaWithPreviewImageTypeHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileImage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileImage.java 2010-02-12 15:16:59 UTC (rev 1905)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileImage.java 2010-02-13 13:09:35 UTC (rev 1906)
@@ -237,6 +237,8 @@
{
return MediaConfigurationManager.getInstance().getURIMappingPrefix()
+ this.getStorageNode().getHandle()
- + "/resolutions/thumbnail/data.jpg";
+ + "/resolutions/thumbnail/"
+ + this.getStorageNode().getName()
+ + ".jpg";
}
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java 2010-02-12 15:16:59 UTC (rev 1905)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java 2010-02-13 13:09:35 UTC (rev 1906)
@@ -58,7 +58,9 @@
}
return MediaConfigurationManager.getInstance().getURIMappingPrefix()
+ media.getHandle()
- + "/resolutions/thumbnail/data."
+ + "/resolutions/thumbnail/"
+ + media.getName()
+ + "."
+ ImageUtils.getExtension(media, "thumbnail");
}
@@ -74,7 +76,9 @@
}
return MediaConfigurationManager.getInstance().getURIMappingPrefix()
+ media.getHandle()
- + "/resolutions/preview/data."
+ + "/resolutions/preview/"
+ + media.getName()
+ + "."
+ ImageUtils.getExtension(media, "preview");
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/MediaWithPreviewImageTypeHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/MediaWithPreviewImageTypeHandler.java 2010-02-12 15:16:59 UTC (rev 1905)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/MediaWithPreviewImageTypeHandler.java 2010-02-13 13:09:35 UTC (rev 1906)
@@ -51,7 +51,9 @@
return MediaConfigurationManager.getInstance().getURIMappingPrefix()
+ media.getHandle()
- + "/resolutions/thumbnail/data."
+ + "/resolutions/thumbnail/"
+ + media.getName()
+ + "."
+ ImageUtils.getExtension(media, "thumbnail");
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2010-02-12 15:16:59 UTC (rev 1905)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2010-02-13 13:09:35 UTC (rev 1906)
@@ -46,7 +46,6 @@
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Arrays;
-import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
@@ -425,7 +424,7 @@
}
nd.setAttribute(ImageUtils.RESOLUTION_PROPERTY, originalRes);
nd.setAttribute(FileProperties.PROPERTY_EXTENSION, extension);
- nd.setAttribute(FileProperties.PROPERTY_FILENAME, "data");
+ nd.setAttribute(FileProperties.PROPERTY_FILENAME, saveTo.getName());
nd.setAttribute(FileProperties.PROPERTY_CONTENTTYPE, mimetype);
nd.setAttribute(FileProperties.PROPERTY_LASTMODIFIED, GregorianCalendar.getInstance(TimeZone
.getDefault()));
@@ -702,8 +701,10 @@
if (image.getContentLength() == 0)
{
- throw new RuntimeException("Invalid image nodedata " + image.getHandle()
- + ", size " + image.getContentLength());
+ throw new RuntimeException("Invalid image nodedata "
+ + image.getHandle()
+ + ", size "
+ + image.getContentLength());
}
String extension = image.getAttribute(FileProperties.PROPERTY_EXTENSION);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2010-02-13 19:39:43
|
Revision: 1915
http://openutils.svn.sourceforge.net/openutils/?rev=1915&view=rev
Author: fgiust
Date: 2010-02-13 19:39:37 +0000 (Sat, 13 Feb 2010)
Log Message:
-----------
MEDIA-93 Static methods in MediaEL must have the same name used for EL functions, for jsp/freemarker similarity
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/uri/MediaURI2RepositoryMapping.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2010-02-13 19:12:05 UTC (rev 1914)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2010-02-13 19:39:37 UTC (rev 1915)
@@ -23,7 +23,6 @@
import info.magnolia.cms.core.Content;
import info.magnolia.cms.core.HierarchyManager;
import info.magnolia.cms.core.NodeData;
-import info.magnolia.cms.util.DateUtil;
import info.magnolia.cms.util.NodeDataUtil;
import info.magnolia.context.MgnlContext;
@@ -31,7 +30,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -66,7 +64,7 @@
private static MediaConfigurationManager mcm = MediaConfigurationManager.getInstance();
- private static final Logger log = LoggerFactory.getLogger(MediaEl.class);
+ private static Logger log = LoggerFactory.getLogger(MediaEl.class);
private static final String[] EMPTY_STRING_ARRAY = new String[]{};
@@ -79,7 +77,7 @@
* Get the media module instance
* @return media module instance
*/
- public static MediaModule getModule()
+ public static MediaModule module()
{
return MediaModule.getInstance();
}
@@ -89,7 +87,7 @@
* @param obj content node or node UUID
* @return content node
*/
- public static Content getNode(Object obj)
+ public static Content node(Object obj)
{
if (obj == null)
{
@@ -132,7 +130,7 @@
* @param locale language
* @return description
*/
- public static String getDescription(Content media, Locale locale)
+ public static String descLoc(Content media, Locale locale)
{
if (media == null)
{
@@ -155,9 +153,9 @@
* @param media media
* @return description
*/
- public static String getDescription(Content media)
+ public static String desc(Content media)
{
- return getDescription(media, null);
+ return descLoc(media, null);
}
/**
@@ -167,7 +165,7 @@
* @param locale language
* @return title
*/
- public static String getTitle(Content media, Locale locale)
+ public static String titleLoc(Content media, Locale locale)
{
if (media == null)
{
@@ -190,9 +188,9 @@
* @param media media
* @return title
*/
- public static String getTitle(Content media)
+ public static String title(Content media)
{
- return getTitle(media, null);
+ return titleLoc(media, null);
}
/**
@@ -202,7 +200,7 @@
* @param locale language
* @return tags
*/
- public static String[] getTags(Content media, Locale locale)
+ public static String[] tagsLoc(Content media, Locale locale)
{
if (media == null)
{
@@ -226,9 +224,9 @@
* @param media media
* @return tags
*/
- public static String[] getTags(Content media)
+ public static String[] tags(Content media)
{
- return getTags(media, null);
+ return tagsLoc(media, null);
}
/**
@@ -236,9 +234,9 @@
* @param media media
* @return url
*/
- public static String getUrl(Content media)
+ public static String url(Content media)
{
- return getUrl2(media, Collections.<String, String> emptyMap());
+ return urlParams(media, Collections.<String, String> emptyMap());
}
/**
@@ -247,7 +245,7 @@
* @param options optional parameters
* @return url
*/
- public static String getUrl2(Content media, Map<String, String> options)
+ public static String urlParams(Content media, Map<String, String> options)
{
if (media == null)
{
@@ -266,7 +264,7 @@
* @param media media to get the url for
* @return the thumbnail url for this media, null otherwise
*/
- public static String getThumbnail(Content media)
+ public static String thumbnail(Content media)
{
if (media == null)
{
@@ -281,7 +279,7 @@
* @param media media to get the type
* @return the type of this media if existing, null otherwise
*/
- public static String getType(Content media)
+ public static String type(Content media)
{
if (media == null)
{
@@ -295,15 +293,14 @@
* @param media media to get the resolutions
* @return all resolution strings
*/
- @SuppressWarnings("unchecked")
- public static String[] listResolutions(Content media)
+ public static String[] resolutions(Content media)
{
List<String> res = new ArrayList<String>();
Content resolutions = media.getChildByName("resolutions");
- for (NodeData item : (Collection<NodeData>) resolutions.getNodeDataCollection())
+ for (NodeData item : resolutions.getNodeDataCollection())
{
if (item.getName().startsWith("res-"))
{
@@ -328,7 +325,7 @@
* @param resolution resolution
* @return url
*/
- public static String getResolutionUrl(Content media, String resolution)
+ public static String urlres(Content media, String resolution)
{
// MEDIA-90 may be simply a url
@@ -375,7 +372,7 @@
* @param resolution resolution for witch calculate size
* @return size of an image
*/
- public static int[] getSize(Content media, String resolution)
+ public static int[] size(Content media, String resolution)
{
if (media != null)
{
@@ -420,7 +417,7 @@
* @param media media
* @return the preview url for this media if existing, null otherwise
*/
- public static String getPreview(Content media)
+ public static String preview(Content media)
{
if (media == null)
{
@@ -435,7 +432,7 @@
* @param media media to search in web pages
* @return an array of String(s) containing a list of web pages where this media is used, an empty array otherwise
*/
- public static String[] findMediaUsedInWebPages(Content media)
+ public static String[] usedInWebPages(Content media)
{
if (media == null)
{
@@ -546,4 +543,144 @@
return null;
}
+ /**
+ * @deprecated, use node(Object)
+ */
+ @Deprecated
+ public static Content getNode(Object obj)
+ {
+ log.warn("\"getNode()\" has been deprecated, please use \"node()\"");
+ return node(obj);
+ }
+
+ /**
+ * @deprecated, use descLoc(Content, Locale)
+ */
+ @Deprecated
+ public static String getDescription(Content media, Locale locale)
+ {
+ log.warn("\"getDescription()\" has been deprecated, please use \"descLoc()\"");
+ return descLoc(media, locale);
+ }
+
+ /**
+ * @deprecated, use desc(Content)
+ */
+ @Deprecated
+ public static String getDescription(Content media)
+ {
+ log.warn("\"getDescription()\" has been deprecated, please use \"desc()\"");
+ return desc(media);
+ }
+
+ /**
+ * @deprecated, use titleLoc(Content, Locale)
+ */
+ @Deprecated
+ public static String getTitle(Content media, Locale locale)
+ {
+ log.warn("\"getTitle()\" has been deprecated, please use \"titleLoc()\"");
+ return titleLoc(media, locale);
+ }
+
+ /**
+ * @deprecated, use title(Content)
+ */
+ @Deprecated
+ public static String getTitle(Content media)
+ {
+ log.warn("\"getTitle()\" has been deprecated, please use \"title()\"");
+ return title(media);
+ }
+
+ /**
+ * @deprecated, use url(Content)
+ */
+ @Deprecated
+ public static String getUrl(Content media)
+ {
+ log.warn("\"getUrl()\" has been deprecated, please use \"url()\"");
+ return url(media);
+ }
+
+ /**
+ * @deprecated, use urlParams(Content, Map)
+ */
+ @Deprecated
+ public static String getUrl2(Content media, Map<String, String> options)
+ {
+ log.warn("\"url2()\" has been deprecated, please use \"urlParams()\"");
+ return urlParams(media, options);
+ }
+
+ /**
+ * @deprecated, use urlres(Content, String)
+ */
+ @Deprecated
+ public static String getResolutionUrl(Content media, String resolution)
+ {
+ log.warn("\"getResolutionUrl()\" has been deprecated, please use \"urlres()\"");
+ return urlres(media, resolution);
+ }
+
+ /**
+ * @deprecated, use resolutions(Content)
+ */
+ @Deprecated
+ public static String[] listResolutions(Content media)
+ {
+ log.warn("\"listResolutions()\" has been deprecated, please use \"resolutions()\"");
+ return resolutions(media);
+ }
+
+ /**
+ * @deprecated, use thumbnail(Content)
+ */
+ @Deprecated
+ public static String getThumbnail(Content media)
+ {
+ log.warn("\"getThumbnail()\" has been deprecated, please use \"thumbnail()\"");
+ return thumbnail(media);
+ }
+
+ /**
+ * @deprecated, use preview(Content)
+ */
+ @Deprecated
+ public static String getPreview(Content media)
+ {
+ log.warn("\"getPreview()\" has been deprecated, please use \"preview()\"");
+ return preview(media);
+ }
+
+ /**
+ * @deprecated, use type(Content)
+ */
+ @Deprecated
+ public static String getType(Content media)
+ {
+ log.warn("\"getType()\" has been deprecated, please use \"type()\"");
+ return type(media);
+ }
+
+ /**
+ * @deprecated, use size(Content, String)
+ */
+ @Deprecated
+ public static int[] getSize(Content media, String resolution)
+ {
+ log.warn("\"getSize()\" has been deprecated, please use \"size()\"");
+ return size(media, resolution);
+ }
+
+ /**
+ * @deprecated, use usedInWebPages(Content)
+ */
+ @Deprecated
+ public static String[] findMediaUsedInWebPages(Content media)
+ {
+ log.warn("\"findMediaUsedInWebPages()\" has been deprecated, please use \"usedInWebPages()\"");
+ return usedInWebPages(media);
+ }
+
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/uri/MediaURI2RepositoryMapping.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/uri/MediaURI2RepositoryMapping.java 2010-02-13 19:12:05 UTC (rev 1914)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/uri/MediaURI2RepositoryMapping.java 2010-02-13 19:39:37 UTC (rev 1915)
@@ -55,7 +55,7 @@
String uri;
try
{
- uri = MediaEl.getUrl(MgnlContext.getHierarchyManager(getRepository()).getContent(urisimple));
+ uri = MediaEl.url(MgnlContext.getHierarchyManager(getRepository()).getContent(urisimple));
}
catch (RepositoryException e)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <die...@us...> - 2010-02-17 09:51:28
|
Revision: 1971
http://openutils.svn.sourceforge.net/openutils/?rev=1971&view=rev
Author: diego_schivo
Date: 2010-02-17 09:50:56 +0000 (Wed, 17 Feb 2010)
Log Message:
-----------
MEDIA-109 Remove static method MediaModule.getInstance()
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java 2010-02-17 09:34:12 UTC (rev 1970)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java 2010-02-17 09:50:56 UTC (rev 1971)
@@ -21,6 +21,7 @@
import info.magnolia.module.ModuleLifecycle;
import info.magnolia.module.ModuleLifecycleContext;
+import info.magnolia.module.ModuleRegistry;
import net.sourceforge.openutils.mgnlmedia.media.configuration.ImageProcessorsManager;
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager;
@@ -36,12 +37,15 @@
{
/**
+ * Media module name.
+ */
+ public static final String NAME = "media";
+
+ /**
* Media repository name.
*/
public static final String REPO = "media";
- private static MediaModule instance;
-
private Logger log = LoggerFactory.getLogger(MediaModule.class);
private boolean singleinstance;
@@ -55,19 +59,9 @@
*/
public MediaModule()
{
- instance = this;
}
/**
- * Get instance
- * @return media module instance
- */
- public static MediaModule getInstance()
- {
- return instance;
- }
-
- /**
* {@inheritDoc}
*/
public void start(ModuleLifecycleContext ctx)
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java 2010-02-17 09:34:12 UTC (rev 1970)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java 2010-02-17 09:50:56 UTC (rev 1971)
@@ -40,6 +40,7 @@
import javax.servlet.http.HttpServletResponse;
import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
+import net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl;
import net.sourceforge.openutils.mgnlmedia.media.utils.MediaLoadUtils;
import org.apache.commons.io.FileUtils;
@@ -369,7 +370,7 @@
*/
public String getModuleVersion()
{
- return MediaModule.getInstance().getVersion();
+ return MediaEl.module().getVersion();
}
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-02-17 09:34:12 UTC (rev 1970)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-02-17 09:50:56 UTC (rev 1971)
@@ -52,6 +52,7 @@
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager;
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration;
import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
+import net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl;
import org.apache.commons.chain.Command;
import org.apache.commons.collections.CollectionUtils;
@@ -264,7 +265,7 @@
try
{
mb.setWritable(media.getParent().isGranted(Permission.WRITE));
- mb.setCanPublish(!MediaModule.getInstance().isSingleinstance()
+ mb.setCanPublish(!MediaEl.module().isSingleinstance()
&& mb.isWritable()
&& ActivationManagerFactory.getActivationManager().hasAnyActiveSubscriber());
@@ -784,7 +785,7 @@
public boolean isSingleInstance()
{
- return MediaModule.getInstance().isSingleinstance();
+ return MediaEl.module().isSingleinstance();
}
public String getBgSelector()
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2010-02-17 09:34:12 UTC (rev 1970)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2010-02-17 09:50:56 UTC (rev 1971)
@@ -25,6 +25,7 @@
import info.magnolia.cms.core.NodeData;
import info.magnolia.cms.util.NodeDataUtil;
import info.magnolia.context.MgnlContext;
+import info.magnolia.module.ModuleRegistry;
import java.awt.Point;
import java.util.ArrayList;
@@ -79,7 +80,7 @@
*/
public static MediaModule module()
{
- return MediaModule.getInstance();
+ return (MediaModule) ModuleRegistry.Factory.getInstance().getModuleInstance(MediaModule.NAME);
}
/**
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java 2010-02-17 09:34:12 UTC (rev 1970)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java 2010-02-17 09:50:56 UTC (rev 1971)
@@ -37,6 +37,7 @@
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager;
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration;
import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
+import net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl;
import org.apache.commons.lang.StringUtils;
@@ -214,7 +215,7 @@
tree.addMenuItem(menuCut);
tree.addMenuItem(menuCopy);
- if (!MediaModule.getInstance().isSingleinstance())
+ if (!MediaEl.module().isSingleinstance())
{
tree.addSeparator();
tree.addMenuItem(menuActivateExcl);
@@ -255,7 +256,7 @@
tree.addColumn(column0);
- if (!browseMode && !MediaModule.getInstance().isSingleinstance())
+ if (!browseMode && !MediaEl.module().isSingleinstance())
{
if (ServerConfiguration.getInstance().isAdmin()
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2010-02-17 09:34:12 UTC (rev 1970)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2010-02-17 09:50:56 UTC (rev 1971)
@@ -41,6 +41,7 @@
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager;
import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
+import net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl;
import net.sourceforge.openutils.mgnlmedia.media.types.MediaTypeHandler;
import org.apache.commons.lang.StringUtils;
@@ -137,7 +138,7 @@
media.save();
}
- if (MediaModule.getInstance().isSingleinstance())
+ if (MediaEl.module().isSingleinstance())
{
media.getMetaData().setActivated();
media.save();
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java 2010-02-17 09:34:12 UTC (rev 1970)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java 2010-02-17 09:50:56 UTC (rev 1971)
@@ -38,6 +38,7 @@
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager;
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration;
import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
+import net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
@@ -107,7 +108,7 @@
NodeDataUtil.getOrCreateAndSet(media, "modificationDate", Calendar.getInstance());
NodeDataUtil.getOrCreateAndSet(media, "modificationUser", MgnlContext.getUser().getName());
- if (MediaModule.getInstance().isSingleinstance())
+ if (MediaEl.module().isSingleinstance())
{
media.getMetaData().setActivated();
}
@@ -169,7 +170,7 @@
contentNodeName,
MediaConfigurationManager.FOLDER);
- if (MediaModule.getInstance().isSingleinstance() && !currContent.getMetaData().getIsActivated())
+ if (MediaEl.module().isSingleinstance() && !currContent.getMetaData().getIsActivated())
{
currContent.getMetaData().setActivated();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <die...@us...> - 2010-02-18 11:53:05
|
Revision: 1984
http://openutils.svn.sourceforge.net/openutils/?rev=1984&view=rev
Author: diego_schivo
Date: 2010-02-18 11:52:59 +0000 (Thu, 18 Feb 2010)
Log Message:
-----------
MEDIA-107 Display the number of media for each type after a search
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2010-02-18 11:44:49 UTC (rev 1983)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2010-02-18 11:52:59 UTC (rev 1984)
@@ -50,11 +50,11 @@
import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
import net.sourceforge.openutils.mgnlmedia.media.pages.MediaFolderViewPage;
-import net.sourceforge.openutils.mgnlmedia.media.types.MediaTypeHandler;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.lang.StringUtils;
+import org.apache.jackrabbit.util.ISO9075;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -348,6 +348,7 @@
* @param type if specified restricts the search to the type
* @return found medias
* @throws RepositoryException exception working on repository
+ * @deprecated, use find(String, String, String, boolean)
*/
@SuppressWarnings("unchecked")
public Collection<Content> search(String text, final String type) throws RepositoryException
@@ -384,6 +385,44 @@
return c;
}
+ @SuppressWarnings("unchecked")
+ public Collection<Content> find(String path, String type, String search, boolean recursive)
+ throws RepositoryException
+ {
+ QueryManager qm = MgnlContext.getQueryManager(MediaModule.REPO);
+ StringBuffer sbQuery = new StringBuffer("/jcr:root/");
+ path = StringUtils.removeEnd(StringUtils.removeStart(StringUtils.trimToEmpty(path), "/"), "/");
+ if (StringUtils.isNotEmpty(path))
+ {
+ sbQuery.append(ISO9075.encodePath(path)).append('/');
+ }
+ if (recursive)
+ {
+ sbQuery.append('/');
+ }
+ sbQuery.append("element(*," + MediaConfigurationManager.MEDIA.getSystemName() + ")");
+ List<String> clauses = new ArrayList<String>();
+ if (StringUtils.isNotBlank(search))
+ {
+ clauses.add("jcr:contains(.,'" + StringUtils.replace(search, "'", "''") + "')");
+ }
+ if (StringUtils.isNotBlank(type))
+ {
+ clauses.add("@type='" + type + "'");
+ }
+ if (!clauses.isEmpty())
+ {
+ sbQuery.append('[').append(StringUtils.join(clauses, " and ")).append(']');
+ }
+ if (StringUtils.isNotBlank(search))
+ {
+ sbQuery.append(" order by @jcr:score descending");
+ }
+ Query q = qm.createQuery(new String(sbQuery), Query.XPATH);
+ QueryResult qr = q.execute();
+ return qr.getContent(MediaConfigurationManager.MGNL_MEDIA_TYPE);
+ }
+
/**
* Get the type configuration for a media
* @param media media
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-02-18 11:44:49 UTC (rev 1983)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-02-18 11:52:59 UTC (rev 1984)
@@ -161,7 +161,7 @@
types = MediaConfigurationManager.getInstance().getTypes().values();
}
- if (!StringUtils.isBlank(path))
+ if (!StringUtils.isBlank(path) || !StringUtils.isBlank(search))
{
fillNumberOfMediaPerType();
}
@@ -180,19 +180,17 @@
numberOfMedia = new HashMap<String, Integer>();
for (MediaTypeConfiguration mtc : types)
{
- QueryManager qm = MgnlContext.getQueryManager(MediaModule.REPO);
try
{
- Query q = qm.createQuery(
- ISO9075.encodePath(path.substring(1)) + "/*[type='" + mtc.getName() + "']",
- Query.XPATH);
- QueryResult qr = q.execute();
-
- numberOfMedia.put(mtc.getName(), qr.getContent(MediaConfigurationManager.MEDIA.getSystemName()).size());
+ Collection<Content> c = MediaConfigurationManager.getInstance().find(
+ path,
+ mtc.getName(),
+ search,
+ StringUtils.isBlank(path));
+ numberOfMedia.put(mtc.getName(), c.size());
}
catch (RepositoryException e)
{
-
}
}
}
@@ -235,7 +233,7 @@
writable = false;
canPublish = false;
- mediasOfType = MediaConfigurationManager.getInstance().search(search, type);
+ mediasOfType = MediaConfigurationManager.getInstance().find(null, type, search, true);
}
catch (RepositoryException ex)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <die...@us...> - 2010-02-18 11:57:37
|
Revision: 1985
http://openutils.svn.sourceforge.net/openutils/?rev=1985&view=rev
Author: diego_schivo
Date: 2010-02-18 11:57:28 +0000 (Thu, 18 Feb 2010)
Log Message:
-----------
MEDIA-107 refactoring
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2010-02-18 11:52:59 UTC (rev 1984)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2010-02-18 11:57:28 UTC (rev 1985)
@@ -348,41 +348,10 @@
* @param type if specified restricts the search to the type
* @return found medias
* @throws RepositoryException exception working on repository
- * @deprecated, use find(String, String, String, boolean)
*/
- @SuppressWarnings("unchecked")
public Collection<Content> search(String text, final String type) throws RepositoryException
{
- QueryManager qm = MgnlContext.getQueryManager(MediaModule.REPO);
- StringBuilder sb = new StringBuilder();
- sb.append("//*[jcr:contains(.,'");
- sb.append(StringUtils.replace(text, "'", "''"));
- sb.append("')] order by @jcr:score descending");
- Query q = qm.createQuery(sb.toString(), Query.XPATH);
- QueryResult qr = q.execute();
- Collection c = qr.getContent(MediaConfigurationManager.MGNL_MEDIA_TYPE);
-
- if (!StringUtils.isBlank(type))
- {
- CollectionUtils.filter(c, new Predicate()
- {
-
- /**
- * {@inheritDoc}
- */
- public boolean evaluate(Object object)
- {
- if (object instanceof Content)
- {
- return NodeDataUtil.getString((Content) object, "type").equals(type);
- }
- return false;
- }
-
- });
- }
-
- return c;
+ return find(null, type, text, true);
}
@SuppressWarnings("unchecked")
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-02-18 11:52:59 UTC (rev 1984)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-02-18 11:57:28 UTC (rev 1985)
@@ -186,7 +186,7 @@
path,
mtc.getName(),
search,
- StringUtils.isBlank(path));
+ StringUtils.isNotBlank(search));
numberOfMedia.put(mtc.getName(), c.size());
}
catch (RepositoryException e)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <die...@us...> - 2010-02-18 15:23:42
|
Revision: 1992
http://openutils.svn.sourceforge.net/openutils/?rev=1992&view=rev
Author: diego_schivo
Date: 2010-02-18 15:23:36 +0000 (Thu, 18 Feb 2010)
Log Message:
-----------
MEDIA-100 removing width/height when not specified
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java 2010-02-18 15:23:28 UTC (rev 1991)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java 2010-02-18 15:23:36 UTC (rev 1992)
@@ -23,6 +23,7 @@
import info.magnolia.cms.core.Content;
import info.magnolia.cms.core.HierarchyManager;
import info.magnolia.cms.security.AccessDeniedException;
+import info.magnolia.cms.util.NodeDataUtil;
import info.magnolia.context.MgnlContext;
import info.magnolia.module.admininterface.FieldSaveHandler;
@@ -35,6 +36,7 @@
import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -68,6 +70,14 @@
{
parentNode.deleteNodeData(name);
}
+ if (parentNode.hasNodeData(name + "_width"))
+ {
+ parentNode.deleteNodeData(name + "width");
+ }
+ if (parentNode.hasNodeData(name + "_height"))
+ {
+ parentNode.deleteNodeData(name + "_height");
+ }
return;
}
@@ -97,6 +107,22 @@
log.warn("Missing media {} referenced in node {}", value, parentNode.getHandle());
}
+ boolean resizing = NodeDataUtil.getBoolean(configNode, "resizing", false);
+ for (String dimKey : new String[]{
+ "width", "height"
+ })
+ {
+ String paramName = name + '_' + dimKey;
+ long dimValue = NumberUtils.toLong(request.getParameter(paramName), -1);
+ if (resizing && dimValue >= 0)
+ {
+ NodeDataUtil.getOrCreateAndSet(parentNode, paramName, dimValue);
+ }
+ else if (parentNode.hasNodeData(paramName))
+ {
+ parentNode.deleteNodeData(paramName);
+ }
+ }
}
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2010-02-18 15:23:28 UTC (rev 1991)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2010-02-18 15:23:36 UTC (rev 1992)
@@ -103,17 +103,6 @@
NodeData nd = NodeDataUtil.getOrCreate(parentNode, name);
nd.setValue(uuid);
- for (String dimKey : new String[]{
- "width", "height"
- })
- {
- String paramName = name + '_' + dimKey;
- long dimValue = NumberUtils.toLong(request.getParameter(paramName), -1);
- if (dimValue >= 0)
- {
- NodeDataUtil.getOrCreateAndSet(parentNode, paramName, dimValue);
- }
- }
return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2010-02-23 17:41:53
|
Revision: 2045
http://openutils.svn.sourceforge.net/openutils/?rev=2045&view=rev
Author: fgiust
Date: 2010-02-23 17:41:47 +0000 (Tue, 23 Feb 2010)
Log Message:
-----------
MEDIA-115 parsing of remote files can now be disabled
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/externals/YoutubeSupport.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ExternalVideoTypeHandler.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMedataUtils.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java 2010-02-23 17:36:59 UTC (rev 2044)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java 2010-02-23 17:41:47 UTC (rev 2045)
@@ -139,6 +139,12 @@
// sort mediatypes on the "order" property
tasks.add(new NodeSortTask("config", "/modules/media/mediatypes", "order"));
+ tasks.add(new CreateMissingPropertyTask(
+ ContentRepository.CONFIG,
+ "/modules/media/mediatypes/youtube/handler",
+ "parseremotefiles",
+ Boolean.TRUE));
+
// install stk support
try
{
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/externals/YoutubeSupport.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/externals/YoutubeSupport.java 2010-02-23 17:36:59 UTC (rev 2044)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/externals/YoutubeSupport.java 2010-02-23 17:41:47 UTC (rev 2045)
@@ -88,6 +88,7 @@
String videoInfoUrl = "http://www.youtube.com/get_video_info?video_id=" + videoId;
URL url = new URL(videoInfoUrl);
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ httpConn.setConnectTimeout(5000);
if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK)
{
in = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ExternalVideoTypeHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ExternalVideoTypeHandler.java 2010-02-23 17:36:59 UTC (rev 2044)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ExternalVideoTypeHandler.java 2010-02-23 17:41:47 UTC (rev 2045)
@@ -70,6 +70,20 @@
private List<ExternalVideoSupport> videoSupportHandlers = new ArrayList<ExternalVideoSupport>();
/**
+ * If true, the media module will try to connect to the remote server to analyze flv metadata.
+ */
+ private boolean parseremotefiles;
+
+ /**
+ * If true, the media module will try to connect to the remote server to analyze flv metadata.
+ * @param parseremotefiles true to enable the parsing of remote flv files.
+ */
+ public void setParseremotefiles(boolean parseremotefiles)
+ {
+ this.parseremotefiles = parseremotefiles;
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -190,6 +204,11 @@
@Override
protected FLVMetaData parseFLVMetaData(Content media) throws Exception
{
+ if (!parseremotefiles)
+ {
+ return null;
+ }
+
String downloadUrl = getUrl(media);
for (ExternalVideoSupport external : videoSupportHandlers)
{
@@ -223,29 +242,34 @@
@Override
public boolean onPostSave(Content media)
{
- try
+
+ if (parseremotefiles)
{
- if (!media.hasNodeData(PREVIEW_NODEDATA_NAME))
+ try
{
- String downloadUrl = getUrl(media);
- for (ExternalVideoSupport external : videoSupportHandlers)
+ if (!media.hasNodeData(PREVIEW_NODEDATA_NAME))
{
- if (external.isEnabled() && external.canHandle(downloadUrl))
+ String downloadUrl = getUrl(media);
+ for (ExternalVideoSupport external : videoSupportHandlers)
{
- String previewUrl = external.getPreviewUrl(downloadUrl);
- if (StringUtils.isNotBlank(previewUrl))
+ if (external.isEnabled() && external.canHandle(downloadUrl))
{
- copyPreviewImageToRepository(media, previewUrl);
+ String previewUrl = external.getPreviewUrl(downloadUrl);
+ if (StringUtils.isNotBlank(previewUrl))
+ {
+ copyPreviewImageToRepository(media, previewUrl);
+ }
+ break;
}
- break;
}
}
}
+ catch (RepositoryException e)
+ {
+ log.error(e.getMessage(), e);
+ }
}
- catch (RepositoryException e)
- {
- log.error(e.getMessage(), e);
- }
+
return super.onPostSave(media);
}
@@ -260,6 +284,7 @@
{
URL url = new URL(previewUrl);
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ httpConn.setConnectTimeout(5000);
if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK)
{
is = httpConn.getInputStream();
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMedataUtils.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMedataUtils.java 2010-02-23 17:36:59 UTC (rev 2044)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMedataUtils.java 2010-02-23 17:41:47 UTC (rev 2045)
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.nio.ByteBuffer;
@@ -166,6 +167,8 @@
public static FLVMetaData parseFLVfromUrl(URL url) throws IOException
{
URLConnection connection = url.openConnection();
+ connection.setConnectTimeout(5000);
+
// Getting the remote input stream
InputStream fis = connection.getInputStream();
try
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2010-04-25 17:35:31
|
Revision: 2301
http://openutils.svn.sourceforge.net/openutils/?rev=2301&view=rev
Author: fgiust
Date: 2010-04-25 17:35:25 +0000 (Sun, 25 Apr 2010)
Log Message:
-----------
MEDIA-128 Use the standard I18nContentSupport for i18n
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2010-04-25 17:21:10 UTC (rev 2300)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2010-04-25 17:35:25 UTC (rev 2301)
@@ -23,7 +23,9 @@
import info.magnolia.cms.core.Content;
import info.magnolia.cms.core.HierarchyManager;
import info.magnolia.cms.core.NodeData;
+import info.magnolia.cms.i18n.I18nContentWrapper;
import info.magnolia.cms.util.NodeDataUtil;
+import info.magnolia.cms.util.NodeMapWrapper;
import info.magnolia.context.MgnlContext;
import info.magnolia.module.ModuleRegistry;
@@ -94,6 +96,9 @@
{
return null;
}
+
+ Content content = null;
+
if (obj instanceof String)
{
String mediaIdentifier = (String) obj;
@@ -110,12 +115,12 @@
{
if (hm.isExist(mediaIdentifier))
{
- return hm.getContent(mediaIdentifier);
+ content = hm.getContent(mediaIdentifier);
}
}
else
{
- return hm.getContentByUUID(StringUtils.trim(mediaIdentifier));
+ content = hm.getContentByUUID(StringUtils.trim(mediaIdentifier));
}
}
catch (ItemNotFoundException e)
@@ -129,9 +134,18 @@
}
else if (obj instanceof Content)
{
- return (Content) obj;
+ content = (Content) obj;
}
- return null;
+
+ if (!(content instanceof NodeMapWrapper))
+ {
+ content = new NodeMapWrapper(new I18nContentWrapper(content), MgnlContext
+ .getAggregationState()
+ .getMainContent()
+ .getHandle());
+ }
+
+ return content;
}
/**
@@ -140,9 +154,15 @@
* @param media media
* @param locale language
* @return description
+ * @deprecated use the standard Magnolia i18nContentSupport for this. Please note that versions < 4.2 of the media
+ * module used PROPERTY-language instead of PROPERTY_languaga which is now the magnolia standard so you may need to
+ * adapt existing repositories
*/
+ @Deprecated
public static String descLoc(Content media, Locale locale)
{
+ log.warn("\"descLoc()\" has been deprecated, please check javadocs");
+
if (media == null)
{
return null;
@@ -160,24 +180,20 @@
}
/**
- * Get description for a media
- * @param media media
- * @return description
- */
- public static String desc(Content media)
- {
- return descLoc(media, null);
- }
-
- /**
* Get localized title for a media. If the locale is "it", it searches for a nodedata called title-it, or (if not
* found) title-en or (if not found) title.
* @param media media
* @param locale language
* @return title
+ * @deprecated use the standard Magnolia i18nContentSupport for this. Please note that versions < 4.2 of the media
+ * module used PROPERTY-language instead of PROPERTY_languaga which is now the magnolia standard so you may need to
+ * adapt existing repositories
*/
+ @Deprecated
public static String titleLoc(Content media, Locale locale)
{
+ log.warn("\"titleLoc()\" has been deprecated, please check javadocs");
+
if (media == null)
{
return null;
@@ -195,24 +211,20 @@
}
/**
- * Get title for a media
- * @param media media
- * @return title
- */
- public static String title(Content media)
- {
- return titleLoc(media, null);
- }
-
- /**
* Get localized tags for a media. If the locale is "it", it searches for a nodedata called tags-it, or (if not
* found) tags-en or (if not found) tags.
* @param media media
* @param locale language
* @return tags
+ * @deprecated use the standard Magnolia i18nContentSupport for this. Please note that versions < 4.2 of the media
+ * module used PROPERTY-language instead of PROPERTY_languaga which is now the magnolia standard so you may need to
+ * adapt existing repositories
*/
+ @Deprecated
public static String[] tagsLoc(Content media, Locale locale)
{
+ log.warn("\"tagsLoc()\" has been deprecated, please check javadocs");
+
if (media == null)
{
return null;
@@ -236,12 +248,44 @@
}
/**
+ * Get description for a media for the current locale.
+ * @param media media
+ * @return description
+ * @deprecated use media.getNodeData("description") or ${media.description}
+ */
+ @Deprecated
+ public static String desc(Content media)
+ {
+ log.warn("\"desc()\" has been deprecated, please check javadocs");
+
+ return descLoc(media, null);
+ }
+
+ /**
+ * Get title for a media for the current locale.
+ * @param media media
+ * @return title
+ * @deprecated use media.getNodeData("title") or ${media.title}
+ */
+ @Deprecated
+ public static String title(Content media)
+ {
+ log.warn("\"title()\" has been deprecated, please check javadocs");
+
+ return titleLoc(media, null);
+ }
+
+ /**
* Get tags for a media
* @param media media
* @return tags
+ * @deprecated use media.getNodeData("tags") or ${media.tags}
*/
+ @Deprecated
public static String[] tags(Content media)
{
+ log.warn("\"tags()\" has been deprecated, please check javadocs");
+
return tagsLoc(media, null);
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2010-04-25 17:21:10 UTC (rev 2300)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2010-04-25 17:35:25 UTC (rev 2301)
@@ -24,19 +24,25 @@
import info.magnolia.cms.beans.runtime.MultipartForm;
import info.magnolia.cms.core.Content;
import info.magnolia.cms.core.NodeData;
+import info.magnolia.cms.i18n.I18nContentSupport;
+import info.magnolia.cms.i18n.I18nContentSupportFactory;
import info.magnolia.cms.security.AccessDeniedException;
import info.magnolia.cms.util.NodeDataUtil;
import info.magnolia.context.MgnlContext;
import info.magnolia.module.admininterface.SaveHandlerImpl;
import java.io.File;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
import javax.servlet.http.HttpServletRequest;
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager;
@@ -226,52 +232,11 @@
}
/**
- * Get the nodedata value for a given name and current locale searching first for [propertyname]-[lang]_[COUNTRY]
- * then for [propertyname]-[lang] then for [propertyname]-en then for [propertyname].<br />
- * i.e for the property title and for a locale it,IT:
- * <ol>
- * <li>search for nodedata "title-it_IT"</li>
- * <li>search for nodedata "title-it"</li>
- * <li>search for nodedata "title-en"</li>
- * <li>search for nodedata "title"</li>
- * </ol>
- * @param media media
- * @param property base property name
- * @return nodedata value for a given name and current locale
- */
- protected String getPropertyLocalized(Content media, String property)
- {
- Locale locale = MgnlContext.getLocale();
- String language = locale.getLanguage().toLowerCase();
- String languageCountry = language + "_" + locale.getCountry().toLowerCase();
- try
- {
- if (media.hasNodeData(property + "-" + languageCountry))
- {
- return NodeDataUtil.getString(media, property + "-" + languageCountry);
- }
- else if (media.hasNodeData(property + "-" + language))
- {
- return NodeDataUtil.getString(media, property + "-" + language);
- }
- else if (media.hasNodeData(property + "-en"))
- {
- return NodeDataUtil.getString(media, property + "-" + language);
- }
- }
- catch (RepositoryException ex)
- {
- log.error(ex.getMessage(), ex);
- }
- return NodeDataUtil.getString(media, property);
- }
-
- /**
* {@inheritDoc}
*/
public String getTitle(Content media)
{
- return getPropertyLocalized(media, "title");
+ return I18nContentSupportFactory.getI18nSupport().getNodeData(media, "title").getString();
}
/**
@@ -279,7 +244,7 @@
*/
public String getTags(Content media)
{
- return getPropertyLocalized(media, "tags");
+ return I18nContentSupportFactory.getI18nSupport().getNodeData(media, "tags").getString();
}
/**
@@ -287,7 +252,7 @@
*/
public String getDescription(Content media)
{
- return getPropertyLocalized(media, "description");
+ return I18nContentSupportFactory.getI18nSupport().getNodeData(media, "description").getString();
}
/**
@@ -295,7 +260,7 @@
*/
public String getAbstract(Content media)
{
- return getPropertyLocalized(media, "abstract");
+ return I18nContentSupportFactory.getI18nSupport().getNodeData(media, "abstract").getString();
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2010-05-02 19:52:04
|
Revision: 2334
http://openutils.svn.sourceforge.net/openutils/?rev=2334&view=rev
Author: fgiust
Date: 2010-05-02 19:51:57 +0000 (Sun, 02 May 2010)
Log Message:
-----------
MEDIA-113 don't delete existing binary values
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java 2010-05-02 18:08:24 UTC (rev 2333)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java 2010-05-02 19:51:57 UTC (rev 2334)
@@ -19,6 +19,7 @@
package net.sourceforge.openutils.mgnlmedia.media.dialog;
+import info.magnolia.cms.beans.runtime.FileProperties;
import info.magnolia.cms.core.Content;
import info.magnolia.cms.core.HierarchyManager;
import info.magnolia.cms.core.NodeData;
@@ -209,6 +210,27 @@
}
/**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getValue()
+ {
+ // handle binary values (needed only for properties converted from the "file" type)
+ NodeData nd = null;
+ if (getStorageNode() != null)
+ {
+ nd = getStorageNode().getNodeData(this.getName());
+ }
+
+ if (nd != null && nd.getType() == PropertyType.BINARY)
+ {
+ return nd.getAttribute(FileProperties.NAME);
+ }
+
+ return super.getValue();
+ }
+
+ /**
* Filename
* @param media2
* @return filename
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java 2010-05-02 18:08:24 UTC (rev 2333)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java 2010-05-02 19:51:57 UTC (rev 2334)
@@ -28,6 +28,7 @@
import info.magnolia.module.admininterface.FieldSaveHandler;
import javax.jcr.ItemNotFoundException;
+import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.servlet.http.HttpServletRequest;
@@ -64,61 +65,64 @@
HttpServletRequest request = MgnlContext.getWebContext().getRequest();
String value = request.getParameter(name);
- if (value == null || StringUtils.EMPTY.equals(value))
+ if (StringUtils.isBlank(value))
{
- for (String property : new String[]{
- name, name + "_width", name + "_height"
- })
+ for (String property : new String[]{name, name + "_width", name + "_height" })
{
if (parentNode.hasNodeData(property))
{
- parentNode.deleteNodeData(property);
+ if (parentNode.getNodeData(property).getType() != PropertyType.BINARY)
+ {
+ parentNode.deleteNodeData(property);
+ }
}
}
return;
}
-
- HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModule.REPO);
-
- try
+ else
{
- Content media = hm.getContentByUUID(value);
- MediaTypeConfiguration mtc = MediaConfigurationManager.getInstance().getMediaTypeConfigurationFromMedia(
- media);
- mtc.getHandler().onSavingPropertyMedia(
- media,
- parentNode,
- configNode,
- name,
- request,
- form,
- type,
- valueType,
- isRichEditValue,
- encoding);
- }
- catch (ItemNotFoundException e)
- {
- log.warn("Missing media {} referenced in node {}", value, parentNode.getHandle());
- }
+ HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModule.REPO);
- boolean resizing = NodeDataUtil.getBoolean(configNode, "resizing", false);
- for (String dimKey : new String[]{
- "width", "height"
- })
- {
- String paramName = name + '_' + dimKey;
- long dimValue = NumberUtils.toLong(request.getParameter(paramName), -1);
- if (resizing && dimValue >= 0)
+ try
{
- NodeDataUtil.getOrCreateAndSet(parentNode, paramName, dimValue);
+ Content media = hm.getContentByUUID(value);
+
+ MediaTypeConfiguration mtc = MediaConfigurationManager
+ .getInstance()
+ .getMediaTypeConfigurationFromMedia(media);
+ mtc.getHandler().onSavingPropertyMedia(
+ media,
+ parentNode,
+ configNode,
+ name,
+ request,
+ form,
+ type,
+ valueType,
+ isRichEditValue,
+ encoding);
}
- else if (parentNode.hasNodeData(paramName))
+ catch (ItemNotFoundException e)
{
- parentNode.deleteNodeData(paramName);
+ log.warn("Missing media {} referenced in node {}", value, parentNode.getHandle());
}
+
+ boolean resizing = NodeDataUtil.getBoolean(configNode, "resizing", false);
+ for (String dimKey : new String[]{"width", "height" })
+ {
+ String paramName = name + '_' + dimKey;
+ long dimValue = NumberUtils.toLong(request.getParameter(paramName), -1);
+ if (resizing && dimValue >= 0)
+ {
+ NodeDataUtil.getOrCreateAndSet(parentNode, paramName, dimValue);
+ }
+ else if (parentNode.hasNodeData(paramName))
+ {
+ parentNode.deleteNodeData(paramName);
+ }
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2010-05-11 20:05:42
|
Revision: 2394
http://openutils.svn.sourceforge.net/openutils/?rev=2394&view=rev
Author: fgiust
Date: 2010-05-11 20:05:35 +0000 (Tue, 11 May 2010)
Log Message:
-----------
MEDIA-106 advanced search: first import
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/SearchFilterOptionProvider.java
Added Paths:
-----------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchFormPage.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchPage.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/SearchFilterOptionProvider.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/SearchFilterOptionProvider.java 2010-05-11 19:53:42 UTC (rev 2393)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/SearchFilterOptionProvider.java 2010-05-11 20:05:35 UTC (rev 2394)
@@ -28,6 +28,9 @@
import javax.jcr.RepositoryException;
+import net.sourceforge.openutils.mgnlmedia.media.advancedsearch.Option;
+import net.sourceforge.openutils.mgnlmedia.media.advancedsearch.SearchFilterAbstract;
+
import org.apache.commons.lang.StringUtils;
@@ -94,7 +97,12 @@
.getHierarchyManager("config")
.getContent(reference)
.getChildren();
- Option opt;
+
+ Option opt = new Option();
+ opt.setValue("");
+ opt.setLabel("---");
+ addOptions(opt);
+
for (Content content : referenceOptions)
{
opt = new Option();
Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchFormPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchFormPage.java (rev 0)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchFormPage.java 2010-05-11 20:05:35 UTC (rev 2394)
@@ -0,0 +1,61 @@
+/**
+ *
+ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html)
+ * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.sourceforge.openutils.mgnlmedia.media.pages;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import net.sourceforge.openutils.mgnlmedia.media.advancedsearch.configuration.SearchMediaQueryConfiguration;
+import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
+
+
+/**
+ * Page that renders the folder view
+ * @author molaschi
+ * @version $Id$
+ */
+public class MediaAdvancedSearchFormPage extends MediaFolderViewPage
+{
+
+ protected SearchMediaQueryConfiguration configuration;
+
+ /**
+ * @param name
+ * @param request
+ * @param response
+ */
+ public MediaAdvancedSearchFormPage(String name, HttpServletRequest request, HttpServletResponse response)
+ {
+ super(name, request, response);
+
+ configuration = MediaModule.getSearchConfiguration();
+
+ }
+
+ /**
+ * Returns the configuration.
+ * @return the configuration
+ */
+ public SearchMediaQueryConfiguration getConfiguration()
+ {
+ return configuration;
+ }
+
+}
Property changes on: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchFormPage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchPage.java (rev 0)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchPage.java 2010-05-11 20:05:35 UTC (rev 2394)
@@ -0,0 +1,433 @@
+/**
+ *
+ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html)
+ * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.sourceforge.openutils.mgnlmedia.media.pages;
+
+import info.magnolia.cms.exchange.ActivationManagerFactory;
+import info.magnolia.cms.security.Permission;
+import info.magnolia.cms.util.RequestFormUtil;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.RepositoryException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import net.sourceforge.openutils.mgnlcriteria.jcr.query.AdvancedResult;
+import net.sourceforge.openutils.mgnlcriteria.jcr.query.AdvancedResultItem;
+import net.sourceforge.openutils.mgnlcriteria.jcr.query.ResultIterator;
+import net.sourceforge.openutils.mgnlmedia.media.advancedsearch.configuration.SearchMediaQueryConfiguration;
+import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager;
+import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration;
+import net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import freemarker.ext.beans.BeansWrapper;
+import freemarker.template.TemplateHashModel;
+import freemarker.template.TemplateMethodModel;
+import freemarker.template.TemplateModelException;
+
+
+/**
+ * Page that renders the folder view
+ * @author molaschi
+ * @version $Id$
+ */
+public class MediaAdvancedSearchPage extends MediaAdvancedSearchFormPage
+{
+
+ private Logger log = LoggerFactory.getLogger(MediaAdvancedSearchPage.class);
+
+ private static final String VIEW_RESULTS = "-results";
+
+ private static final String VIEW_RESULTS_XML = "-results-xml";
+
+ private TemplateMethodModel getStatic = new GetStaticMethodModel();
+
+ private String queryString;
+
+ private String format;
+
+ private AdvancedResult contentMediaDetails;
+
+ private String selectTab;
+
+ // Pirelli pagination
+ private int page = 1; // Numero di pagina
+
+ private int items = 100; // Items per page
+
+ // Path di ricerca
+ private String path;
+
+ /**
+ * @param name
+ * @param request
+ * @param response
+ */
+ public MediaAdvancedSearchPage(String name, HttpServletRequest request, HttpServletResponse response)
+ {
+ super(name, request, response);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings({"unchecked", "deprecation" })
+ @Override
+ protected void populateFromRequest(Object bean)
+ {
+ RequestFormUtil requestFormUtil = new RequestFormUtil(this.getRequest());
+ Map<String, Object> parameters = new HashMap<String, Object>(); // needed, can't directly modify the map
+ // returned by request.getParameterMap()
+
+ // FIX: siccome arriva da un virtual uri mapping, i parametri originali non sono nella query string e quindi non
+ // posso usare il requestFormUtil.getParam... che fa un parsing custom della querystring
+ parameters.putAll(request.getParameterMap());
+ parameters.putAll(requestFormUtil.getDocuments()); // handle uploaded files too
+
+ try
+ {
+ BeanUtils.populate(bean, parameters);
+ }
+ catch (Exception e)
+ {
+ log.error("can't set properties on the handler", e);
+ }
+ }
+
+ public String show()
+ {
+
+ // @todo defaultBasePath handling only on xml requests?
+ if ("xml".equals(format))
+ {
+ contentMediaDetails = configuration.search(request, null, "media", "nt:base", items, page);
+ }
+ else
+ {
+ contentMediaDetails = configuration.search(request, "/", "media", "nt:base");
+ }
+
+ setMedias(new ArrayList<MediaBean>(contentMediaDetails.getTotalSize()));
+
+ setNumberOfMedia(new HashMap<String, Integer>());
+
+ selectTab = StringUtils.trimToEmpty(selectTab);
+ if (StringUtils.isNotBlank(selectTab))
+ {
+ setType(selectTab);
+ }
+
+ ResultIterator<AdvancedResultItem> items = contentMediaDetails.getItems();
+
+ // @todo don't do this, all the search should be laxy
+ while (items.hasNext())
+ {
+ AdvancedResultItem media = items.next();
+
+ MediaTypeConfiguration mtc = MediaConfigurationManager.getInstance().getMediaTypeConfigurationFromMedia(
+ media);
+
+ if (mtc != null)
+ {
+ getNumberOfMedia().put(mtc.getName(), MapUtils.getInteger(getNumberOfMedia(), mtc.getName(), 0) + 1);
+
+ if (!"xml".equals(format) && (StringUtils.isBlank(getType()) || getType().equals(mtc.getName())))
+ {
+ MediaBean mb = new MediaBean();
+
+ mb.setContent(media);
+ mb.setMetaData(media.getMetaData());
+ mb.setHandle(media.getHandle());
+ mb.setFilename(mtc.getHandler().getFilename(media));
+ mb.setTitle(mtc.getHandler().getTitle(media));
+ mb.setThumbnailUrl(mtc.getHandler().getThumbnailUrl(media));
+ mb.setPreviewUrl(mtc.getHandler().getPreviewUrl(media));
+ mb.setDescription(mtc.getHandler().getDescription(media));
+ mb.setUuid(media.getUUID());
+
+ try
+ {
+ mb.setWritable(media.getParent().isGranted(Permission.WRITE));
+ mb.setCanPublish(!MediaEl.module().isSingleinstance()
+ && mb.isWritable()
+ && ActivationManagerFactory.getActivationManager().hasAnyActiveSubscriber());
+
+ mb.getUsedInWebPages().addAll(
+ MediaConfigurationManager.getInstance().getUsedInWebPages(media.getUUID()));
+ }
+ catch (RepositoryException ex)
+ {
+ log.error("Exception caught", ex);
+ }
+
+ mb.setMediaInfo(mtc.getHandler().getMediaInfo(media));
+ mb.setExternal(mtc.getHandler().isExternal(media));
+
+ try
+ {
+ mb.setWritable(media.getParent().isGranted(Permission.WRITE));
+ mb.getUsedInWebPages().addAll(
+ MediaConfigurationManager.getInstance().getUsedInWebPages(media.getUUID()));
+ }
+ catch (RepositoryException ex)
+ {
+ log.error(ex.getMessage(), ex);
+ log.error("Going on after exception");
+ }
+ getMedias().add(mb);
+ }
+ }
+ }
+
+ StringBuilder qs = new StringBuilder();
+ for (String key : (Set<String>) request.getParameterMap().keySet())
+ {
+ if (!"type".equals(key))
+ {
+ if (request.getParameterMap().get(key).getClass().isArray())
+ {
+ for (String value : (String[]) request.getParameterMap().get(key))
+ {
+ if ("command".equals(key))
+ {
+ continue;
+ }
+ if (qs.length() > 0)
+ {
+ qs.append("&");
+ }
+ qs.append(key).append("=").append(value);
+ }
+ }
+ else
+ {
+ qs.append(key).append("=").append(request.getParameter(key));
+ }
+ }
+ }
+ queryString = qs.toString();
+
+ setSearch(queryString);
+ if (!StringUtils.isNotBlank(selectTab))
+ {
+ selectTab = getType();
+ }
+
+ if (StringUtils.isNotBlank(format) && "xml".equals(format))
+ {
+ this.response.setContentType("text/xml");
+ return VIEW_RESULTS_XML;
+ }
+ return VIEW_RESULTS;
+ }
+
+ /**
+ * Returns the getStatic.
+ * @return the getStatic
+ */
+ public TemplateMethodModel getGetStatic()
+ {
+ return getStatic;
+ }
+
+ public class GetStaticMethodModel implements TemplateMethodModel
+ {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Object exec(List arguments) throws TemplateModelException
+ {
+ if (arguments != null && arguments.size() > 0)
+ {
+ BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
+ TemplateHashModel staticModel = wrapper.getStaticModels();
+ return staticModel.get((String) arguments.get(0));
+ }
+ return null;
+ }
+
+ }
+
+ /**
+ * Returns the queryString.
+ * @return the queryString
+ */
+ public String getQueryString()
+ {
+ return queryString;
+ }
+
+ /**
+ * Sets the queryString.
+ * @param queryString the queryString to set
+ */
+ public void setQueryString(String queryString)
+ {
+ this.queryString = queryString;
+ }
+
+ /**
+ * Returns the format.
+ * @return the format
+ */
+ public String getFormat()
+ {
+ return format;
+ }
+
+ /**
+ * Sets the format.
+ * @param format the format to set
+ */
+ public void setFormat(String format)
+ {
+ this.format = format;
+ }
+
+ /**
+ * Returns the contentMediaDetails.
+ * @return the contentMediaDetails
+ */
+ public AdvancedResult getContentMediaDetails()
+ {
+ return contentMediaDetails;
+ }
+
+ /**
+ * Sets the contentMediaDetails.
+ * @param contentMediaDetails the contentMediaDetails to set
+ */
+ public void setContentMediaDetails(AdvancedResult contentMediaDetails)
+ {
+ this.contentMediaDetails = contentMediaDetails;
+ }
+
+ /**
+ * Returns the configuration.
+ * @return the configuration
+ */
+ public SearchMediaQueryConfiguration getConfiguration()
+ {
+ return configuration;
+ }
+
+ /**
+ * Sets the configuration.
+ * @param configuration the configuration to set
+ */
+ public void setConfiguration(SearchMediaQueryConfiguration configuration)
+ {
+ this.configuration = configuration;
+ }
+
+ /**
+ * Sets the getStatic.
+ * @param getStatic the getStatic to set
+ */
+ public void setGetStatic(TemplateMethodModel getStatic)
+ {
+ this.getStatic = getStatic;
+ }
+
+ /**
+ * Returns the selectTab.
+ * @return the selectTab
+ */
+ public String getSelectTab()
+ {
+ return selectTab;
+ }
+
+ /**
+ * Sets the selectTab.
+ * @param selectTab the selectTab to set
+ */
+ public void setSelectTab(String selectTab)
+ {
+ this.selectTab = selectTab;
+ }
+
+ /**
+ * Returns the page.
+ * @return the page
+ */
+ public int getPage()
+ {
+ return page;
+ }
+
+ /**
+ * Sets the page.
+ * @param page the page to set
+ */
+ public void setPage(int page)
+ {
+ this.page = page;
+ }
+
+ /**
+ * Returns the items.
+ * @return the items
+ */
+ public int getItems()
+ {
+ return items;
+ }
+
+ /**
+ * Sets the items.
+ * @param items the items to set
+ */
+ public void setItems(int items)
+ {
+ this.items = items;
+ }
+
+ /**
+ * Returns the path.
+ * @return the path
+ */
+ public String getPath()
+ {
+ return path;
+ }
+
+ /**
+ * Sets the path.
+ * @param path the path to set
+ */
+ public void setPath(String path)
+ {
+ this.path = path;
+ }
+
+}
Property changes on: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchPage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2010-05-12 15:42:07
|
Revision: 2422
http://openutils.svn.sourceforge.net/openutils/?rev=2422&view=rev
Author: fgiust
Date: 2010-05-12 15:42:01 +0000 (Wed, 12 May 2010)
Log Message:
-----------
license headers
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaUsedInManager.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/UsedInWorkspace.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBeanBuilder.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaUsedInManager.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaUsedInManager.java 2010-05-12 15:34:40 UTC (rev 2421)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaUsedInManager.java 2010-05-12 15:42:01 UTC (rev 2422)
@@ -1,3 +1,22 @@
+/**
+ *
+ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html)
+ * Copyright(C) 2008-2010, Openmind S.r.l. http://www.openmindonline.it
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
package net.sourceforge.openutils.mgnlmedia.media.configuration;
import info.magnolia.cms.beans.config.ContentRepository;
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/UsedInWorkspace.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/UsedInWorkspace.java 2010-05-12 15:34:40 UTC (rev 2421)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/UsedInWorkspace.java 2010-05-12 15:42:01 UTC (rev 2422)
@@ -1,3 +1,22 @@
+/**
+ *
+ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html)
+ * Copyright(C) 2008-2010, Openmind S.r.l. http://www.openmindonline.it
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
package net.sourceforge.openutils.mgnlmedia.media.configuration;
import info.magnolia.cms.beans.config.ContentRepository;
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBeanBuilder.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBeanBuilder.java 2010-05-12 15:34:40 UTC (rev 2421)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBeanBuilder.java 2010-05-12 15:42:01 UTC (rev 2422)
@@ -1,3 +1,22 @@
+/**
+ *
+ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html)
+ * Copyright(C) 2008-2010, Openmind S.r.l. http://www.openmindonline.it
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
package net.sourceforge.openutils.mgnlmedia.media.pages;
import info.magnolia.cms.beans.config.ContentRepository;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <die...@us...> - 2010-06-29 14:27:45
|
Revision: 2722
http://openutils.svn.sourceforge.net/openutils/?rev=2722&view=rev
Author: diego_schivo
Date: 2010-06-29 14:27:39 +0000 (Tue, 29 Jun 2010)
Log Message:
-----------
MEDIA-145 FolderViewPage populated using AdvancedResult
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2010-06-29 13:40:35 UTC (rev 2721)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2010-06-29 14:27:39 UTC (rev 2722)
@@ -218,7 +218,6 @@
* @param sorting sorting
* @return all media nodes of passed type
*/
- @SuppressWarnings("unchecked")
public Collection<Content> getMediaNodes(final Content folder, final String type, final String sorting)
{
List<Content> medias = (List<Content>) folder.getChildren(new Content.ContentFilter()
@@ -389,7 +388,10 @@
{
Criteria criteria = JCRCriteriaFactory.createCriteria().setWorkspace(MediaModule.REPO);
path = StringUtils.removeEnd(StringUtils.removeStart(StringUtils.trimToEmpty(path), "/"), "/");
- criteria.setBasePath("//" + path + (recursive ? "//*" : "/*"));
+ if (!StringUtils.isEmpty(path))
+ {
+ criteria.setBasePath("//" + path + (recursive ? "//*" : "/*"));
+ }
criteria.add(Restrictions.eq("@jcr:primaryType", MGNL_MEDIA_TYPE));
if (!StringUtils.isEmpty(type))
{
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-06-29 13:40:35 UTC (rev 2721)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-06-29 14:27:39 UTC (rev 2722)
@@ -38,6 +38,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import javax.jcr.RepositoryException;
@@ -46,6 +47,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import net.sourceforge.openutils.mgnlcriteria.jcr.query.AdvancedResult;
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager;
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration;
import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule;
@@ -55,7 +57,8 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
-import com.google.common.collect.Collections2;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
/**
@@ -195,7 +198,7 @@
HierarchyManager hm = MgnlContext.getInstance().getHierarchyManager(MediaModule.REPO);
final MediaTypeConfiguration mtc = MediaConfigurationManager.getInstance().getTypes().get(type);
- Collection<Content> mediasOfType = null;
+ AdvancedResult typeResult = null;
if (!StringUtils.isBlank(path))
{
@@ -206,8 +209,7 @@
writable = folder.isGranted(Permission.WRITE);
canPublish = writable && ActivationManagerFactory.getActivationManager().hasAnyActiveSubscriber();
- mediasOfType = MediaConfigurationManager.getInstance().getMediaNodes(folder, type, sorting);
-
+ typeResult = MediaConfigurationManager.getInstance().find(folder.getHandle(), type, null, false, 0, -1);
}
catch (RepositoryException ex)
{
@@ -216,23 +218,16 @@
}
else if (!StringUtils.isBlank(search))
{
- try
- {
- writable = false;
- canPublish = false;
+ writable = false;
+ canPublish = false;
- mediasOfType = MediaConfigurationManager.getInstance().find(null, type, search, true);
-
- }
- catch (RepositoryException ex)
- {
- log.error("Exception caught", ex);
- }
+ typeResult = MediaConfigurationManager.getInstance().find(null, type, search, true, 0, -1);
}
- if (mediasOfType != null)
+ if (typeResult != null && typeResult.getItems().hasNext())
{
- medias = Collections2.transform(mediasOfType, new MediaBeanBuilder(mtc));
+ Iterator<MediaBean> it = Iterators.transform(typeResult.getItems(), new MediaBeanBuilder(mtc));
+ medias = Lists.newArrayList(it);
}
else
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <die...@us...> - 2010-06-30 06:45:40
|
Revision: 2737
http://openutils.svn.sourceforge.net/openutils/?rev=2737&view=rev
Author: diego_schivo
Date: 2010-06-30 06:45:34 +0000 (Wed, 30 Jun 2010)
Log Message:
-----------
MEDIA-145 deprecated methods
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2010-06-30 06:40:53 UTC (rev 2736)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2010-06-30 06:45:34 UTC (rev 2737)
@@ -194,6 +194,7 @@
* Get all media nodes in a folder
* @param folder folder
* @return all media nodes
+ * @deprecated use the find method overload based on Magnolia Criteria API
*/
public Collection<Content> getMediaNodes(Content folder)
{
@@ -218,6 +219,7 @@
* @param type media
* @param sorting sorting
* @return all media nodes of passed type
+ * @deprecated use the find method overload based on Magnolia Criteria API
*/
public Collection<Content> getMediaNodes(final Content folder, final String type, final String sorting)
{
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-06-30 06:40:53 UTC (rev 2736)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-06-30 06:45:34 UTC (rev 2737)
@@ -42,7 +42,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -155,7 +154,7 @@
{
super.init();
- if (mediaType != null && mediaType.length() > 0)
+ if (!StringUtils.isEmpty(mediaType))
{
String[] mediaTypes = StringUtils.split(mediaType, ",");
type = mediaTypes[0];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <die...@us...> - 2010-06-30 07:39:19
|
Revision: 2741
http://openutils.svn.sourceforge.net/openutils/?rev=2741&view=rev
Author: diego_schivo
Date: 2010-06-30 07:39:12 +0000 (Wed, 30 Jun 2010)
Log Message:
-----------
MEDIA-145 refactoring: moved "page" and "items" fields to super-class
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchPage.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2010-06-30 07:23:21 UTC (rev 2740)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2010-06-30 07:39:12 UTC (rev 2741)
@@ -396,12 +396,14 @@
* @param path
* @param type
* @param search
- * @param recursive
- * @param pageIndex
- * @param pageSize
+ * @param childrenOnly
+ * @param sorting
+ * @param itemsPerPage
+ * @param pageNumberStartingFromOne
* @return
*/
- public AdvancedResult find(String path, String type, String search, boolean childrenOnly, String sorting, int pageIndex, int pageSize)
+ public AdvancedResult find(String path, String type, String search, boolean childrenOnly, String sorting,
+ int itemsPerPage, int pageNumberStartingFromOne)
{
Criteria criteria = JCRCriteriaFactory.createCriteria().setWorkspace(MediaModule.REPO);
@@ -438,10 +440,10 @@
}
// paging
- if (pageSize > 0)
+ if (itemsPerPage > 0)
{
- criteria.setFirstResult(pageIndex * pageSize);
- criteria.setMaxResults(pageSize);
+ criteria.setFirstResult((pageNumberStartingFromOne - 1) * itemsPerPage);
+ criteria.setMaxResults(itemsPerPage);
}
return criteria.execute();
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchPage.java 2010-06-30 07:23:21 UTC (rev 2740)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchPage.java 2010-06-30 07:39:12 UTC (rev 2741)
@@ -56,10 +56,6 @@
private String selectTab;
- private int page = 1;
-
- private int items = 100;
-
/**
* @param name
* @param request
@@ -240,41 +236,4 @@
{
this.selectTab = selectTab;
}
-
- /**
- * Returns the page.
- * @return the page
- */
- public int getPage()
- {
- return page;
- }
-
- /**
- * Sets the page.
- * @param page the page to set
- */
- public void setPage(int page)
- {
- this.page = page;
- }
-
- /**
- * Returns the items.
- * @return the items
- */
- public int getItems()
- {
- return items;
- }
-
- /**
- * Sets the items.
- * @param items the items to set
- */
- public void setItems(int items)
- {
- this.items = items;
- }
-
}
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-06-30 07:23:21 UTC (rev 2740)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-06-30 07:39:12 UTC (rev 2741)
@@ -134,7 +134,9 @@
protected List<Page> pages;
- protected int page;
+ protected int page = 1;
+
+ protected int items = 10;
/**
* @param name
@@ -195,11 +197,6 @@
bgSelector = StringUtils.defaultIfEmpty(bgSelector, "white");
sorting = StringUtils.defaultIfEmpty(sorting, SORT_BY_CREATIONDATE);
- if (page <= 0)
- {
- page = 1;
- }
-
develop = SystemProperty.getBooleanProperty("magnolia.develop");
}
@@ -218,7 +215,7 @@
StringUtils.isEmpty(search),
null,
0,
- -1);
+ 1);
numberOfMedia.put(mtc.getName(), (int) typeResult.getItems().getSize());
}
}
@@ -248,8 +245,8 @@
null,
true,
sorting,
- page - 1,
- 5);
+ items,
+ page);
}
}
else if (!StringUtils.isBlank(search))
@@ -812,6 +809,24 @@
this.page = page;
}
+ /**
+ * Returns the items.
+ * @return the items
+ */
+ public int getItems()
+ {
+ return items;
+ }
+
+ /**
+ * Sets the items.
+ * @param items the items to set
+ */
+ public void setItems(int items)
+ {
+ this.items = items;
+ }
+
public boolean isSingleInstance()
{
return MediaEl.module().isSingleinstance();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <die...@us...> - 2010-06-30 10:22:03
|
Revision: 2750
http://openutils.svn.sourceforge.net/openutils/?rev=2750&view=rev
Author: diego_schivo
Date: 2010-06-30 10:21:56 +0000 (Wed, 30 Jun 2010)
Log Message:
-----------
MEDIA-145 removed unused method parameter
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/configuration/SearchMediaQueryConfiguration.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchPage.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/configuration/SearchMediaQueryConfiguration.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/configuration/SearchMediaQueryConfiguration.java 2010-06-30 10:14:10 UTC (rev 2749)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/configuration/SearchMediaQueryConfiguration.java 2010-06-30 10:21:56 UTC (rev 2750)
@@ -92,12 +92,12 @@
/**
* {@inheritDoc}
*/
- public AdvancedResult search(HttpServletRequest request, String basePath, String repository, String itemType)
+ public AdvancedResult search(HttpServletRequest request, String basePath, String repository)
{
- return search(request, basePath, repository, itemType, maxresults, 1);
+ return search(request, basePath, repository, maxresults, 1);
}
- public AdvancedResult search(HttpServletRequest request, String basePath, String repository, String itemType,
+ public AdvancedResult search(HttpServletRequest request, String basePath, String repository,
int itemsPerPage, int pageNumberStartingFromOne)
{
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchPage.java 2010-06-30 10:14:10 UTC (rev 2749)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaAdvancedSearchPage.java 2010-06-30 10:21:56 UTC (rev 2750)
@@ -87,11 +87,11 @@
if ("xml".equals(format))
{
// paging disabled for xml requests
- contentMediaDetails = configuration.search(request, null, "media", "nt:base");
+ contentMediaDetails = configuration.search(request, null, "media");
}
else
{
- contentMediaDetails = configuration.search(request, "/", "media", "nt:base", items, page);
+ contentMediaDetails = configuration.search(request, "/", "media", items, page);
}
setNumberOfMedia(new HashMap<String, Integer>());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|