Пример #1
0
  public byte[] getTextObj() {
    if (_textObj == null) {
      _textObj = (byte[]) Base64.stringToObject(getText());
    }

    return _textObj;
  }
  public Object getNewValue(Object oldValue) throws Exception {
    _type = null;
    _height = null;
    _width = null;
    _size = null;

    String text = (String) oldValue;

    byte[] bytes = (byte[]) Base64.stringToObject(text);

    try {
      Image image = ImageLocalServiceUtil.getImage(bytes);

      _type = image.getType();
      _height = new Integer(image.getHeight());
      _width = new Integer(image.getWidth());
      _size = new Integer(image.getSize());
    } catch (Exception e) {
      if (_log.isWarnEnabled()) {
        String imageId = (String) _imageIdColumn.getOldValue();

        if (_log.isWarnEnabled()) {
          _log.warn("Unable to get image data for " + imageId + ": " + e.getMessage());
        }
      }

      _type = ImageConstants.TYPE_NOT_AVAILABLE;
      _height = null;
      _width = null;
      _size = new Integer(bytes.length);
    }

    return oldValue;
  }
  protected Event serializeEvent(Event event, ClassLoader portletClassLoader) {

    Serializable value = event.getValue();

    if (value == null) {
      return event;
    }

    Class<?> valueClass = value.getClass();

    String valueClassName = valueClass.getName();

    try {
      Class<?> loadedValueClass = portletClassLoader.loadClass(valueClassName);

      if (loadedValueClass.equals(valueClass)) {
        return event;
      }
    } catch (ClassNotFoundException cnfe) {
      if (_log.isWarnEnabled()) {
        _log.warn(portletClassLoader.toString() + " does not contain " + valueClassName, cnfe);
      }
    }

    EventImpl eventImpl = (EventImpl) event;

    String base64Value = eventImpl.getBase64Value();

    value = (Serializable) Base64.stringToObject(base64Value, portletClassLoader);

    return new EventImpl(event.getName(), event.getQName(), value);
  }
Пример #4
0
  public Key getKeyObj() {
    if (_keyObj == null) {
      String key = getKey();

      if (Validator.isNotNull(key)) {
        _keyObj = (Key) Base64.stringToObject(key);
      }
    }

    return _keyObj;
  }