Codota Logo
CacheSavingException
Code IndexAdd Codota to your IDE (free)

How to use
CacheSavingException
in
com.octo.android.robospice.persistence.exception

Best Java code snippets using com.octo.android.robospice.persistence.exception.CacheSavingException (Showing top 11 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Gson g =
  • Codota Iconnew Gson()
  • Codota IconGsonBuilder gsonBuilder;gsonBuilder.create()
  • Codota Iconnew GsonBuilder().create()
  • Smart code suggestions by Codota
}
origin: com.octo.android.robospice/robospice-spring-android

@Override
protected void saveData(T data, Object cacheKey) throws IOException, CacheSavingException {
  String resultJson;
  // transform the content in json to store it in the cache
  resultJson = gson.toJson(data);
  // finally store the json in the cache
  if (!StringUtils.isEmpty(resultJson)) {
    FileUtils.writeStringToFile(getCacheFile(cacheKey), resultJson, CharEncoding.UTF_8);
  } else {
    throw new CacheSavingException("Data was null and could not be serialized in json");
  }
}
origin: com.octo.android.robospice/robospice-spring-android

@Override
protected void saveData(T data, Object cacheKey) throws IOException, CacheSavingException {
  String resultJson;
  // transform the content in json to store it in the cache
  resultJson = mJsonMapper.writeValueAsString(data);
  // finally store the json in the cache
  if (!StringUtils.isEmpty(resultJson)) {
    FileUtils.writeStringToFile(getCacheFile(cacheKey), resultJson, CharEncoding.UTF_8);
  } else {
    throw new CacheSavingException("Data was null and could not be serialized in json");
  }
}
origin: com.octo.android.robospice/robospice-cache

@Override
public Bitmap saveDataToCacheAndReturnData(Bitmap data, Object cacheKey) throws CacheSavingException {
  BufferedOutputStream out = null;
  try {
    File cacheFile = getCacheFile(cacheKey);
    out = new BufferedOutputStream(new FileOutputStream(cacheFile));
    boolean didCompress = data.compress(compressFormat, quality, out);
    if (!didCompress) {
      throw new CacheSavingException(String.format("Could not compress bitmap for path: %s", getCacheFile(cacheKey).getAbsolutePath()));
    }
    return data;
  } catch (IOException e) {
    throw new CacheSavingException(e);
  } finally {
    IOUtils.closeQuietly(out);
  }
}
origin: com.octo.android.robospice/robospice-spring-android

@Override
protected void saveData(T data, Object cacheKey) throws IOException, CacheSavingException {
  String resultJson;
  // transform the content in json to store it in the cache
  resultJson = mJsonMapper.writeValueAsString(data);
  synchronized (getCacheFile(cacheKey).getAbsolutePath().intern()) {
    // finally store the json in the cache
    if (!StringUtils.isEmpty(resultJson)) {
      FileUtils.writeStringToFile(getCacheFile(cacheKey), resultJson, CharEncoding.UTF_8);
    } else {
      throw new CacheSavingException("Data was null and could not be serialized in json");
    }
  }
}
origin: com.octo.android.robospice/robospice-spring-android

  @Override
  protected void saveData(T data, Object cacheKey) throws IOException, CacheSavingException {
    try {
      serializer.write(data, getCacheFile(cacheKey));
    } catch (Exception e) {
      throw new CacheSavingException("Data was null and could not be serialized in xml");
    }
  }
}
origin: com.octo.android.robospice/robospice-cache

@Override
public InputStream saveDataToCacheAndReturnData(InputStream data, Object cacheKey) throws CacheSavingException {
  FileOutputStream output = null;
  // special case for big inputstream object : as it can be read
  // only once and is too big to be locally
  // duplicated,
  // 1) we save it in file
  // 2) we load and return it from the file
  try {
    output = new FileOutputStream(getCacheFile(cacheKey));
    IOUtils.copy(data, output);
    return new FileInputStream(getCacheFile(cacheKey));
  } catch (IOException e) {
    throw new CacheSavingException(e);
  } finally {
    IOUtils.closeQuietly(output);
  }
}
origin: com.octo.android.robospice/robospice-cache

@Override
public InputStream saveDataToCacheAndReturnData(InputStream data, final Object cacheKey) throws CacheSavingException {
  // special case for inputstream object : as it can be read only
  // once,
  // 0) we extract the content of the input stream as a byte[]
  // 1) we save it in file asynchronously if enabled
  // 2) the result will be a new InputStream on the byte[]
  final byte[] byteArray;
  try {
    byteArray = IOUtils.toByteArray(data);
    if (isAsyncSaveEnabled()) {
      Thread t = new Thread() {
        @Override
        public void run() {
          try {
            FileUtils.writeByteArrayToFile(getCacheFile(cacheKey), byteArray);
          } catch (IOException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          }
        };
      };
      t.start();
    } else {
      FileUtils.writeByteArrayToFile(getCacheFile(cacheKey), byteArray);
    }
    return new ByteArrayInputStream(byteArray);
  } catch (IOException e) {
    throw new CacheSavingException(e);
  }
}
origin: com.octo.android.robospice/robospice-retrofit

@Override
public T saveDataToCacheAndReturnData(final T data, final Object cacheKey) throws CacheSavingException {
  try {
    if (isAsyncSaveEnabled()) {
      Thread t = new Thread() {
        @Override
        public void run() {
          try {
            saveData(data, cacheKey);
          } catch (IOException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          } catch (CacheSavingException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          }
        };
      };
      t.start();
    } else {
      saveData(data, cacheKey);
    }
  } catch (CacheSavingException e) {
    throw e;
  } catch (Exception e) {
    throw new CacheSavingException(e);
  }
  return data;
}
origin: com.octo.android.robospice/robospice-google-http-client

@Override
public T saveDataToCacheAndReturnData(final T data, final Object cacheKey) throws CacheSavingException {
  try {
    if (isAsyncSaveEnabled()) {
      Thread t = new Thread() {
        @Override
        public void run() {
          try {
            saveData(data, cacheKey);
          } catch (IOException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          } catch (CacheSavingException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          }
        };
      };
      t.start();
    } else {
      saveData(data, cacheKey);
    }
  } catch (CacheSavingException e) {
    throw e;
  } catch (Exception e) {
    throw new CacheSavingException(e);
  }
  return data;
}
origin: com.octo.android.robospice/robospice-spring-android

@Override
public T saveDataToCacheAndReturnData(final T data, final Object cacheKey) throws CacheSavingException {
  try {
    if (isAsyncSaveEnabled()) {
      Thread t = new Thread() {
        @Override
        public void run() {
          try {
            saveData(data, cacheKey);
          } catch (IOException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          } catch (CacheSavingException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          }
        };
      };
      t.start();
    } else {
      saveData(data, cacheKey);
    }
  } catch (CacheSavingException e) {
    throw e;
  } catch (Exception e) {
    throw new CacheSavingException(e);
  }
  return data;
}
origin: com.octo.android.robospice/robospice-cache

  @Override
  public String saveDataToCacheAndReturnData(final String data, final Object cacheKey) throws CacheSavingException {
    Ln.v("Saving String " + data + " into cacheKey = " + cacheKey);
    try {
      if (isAsyncSaveEnabled()) {

        Thread t = new Thread() {
          @Override
          public void run() {
            try {
              FileUtils.writeStringToFile(getCacheFile(cacheKey), data, CharEncoding.UTF_8);
            } catch (IOException e) {
              Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
            }
          };
        };
        t.start();
      } else {
        FileUtils.writeStringToFile(getCacheFile(cacheKey), data, CharEncoding.UTF_8);
      }
    } catch (Exception e) {
      throw new CacheSavingException(e);
    }
    return data;
  }
}
com.octo.android.robospice.persistence.exceptionCacheSavingException

Javadoc

Exception thrown when a problem occurs while saving data to cache. Those exceptions are not thrown by default in the framework.

Most used methods

  • <init>

Popular in Java

  • Finding current android device location
  • setScale (BigDecimal)
  • getApplicationContext (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Properties (java.util)
    The Properties class represents a persistent set of properties. The Properties can be saved to a st
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • TreeMap (java.util)
    A Red-Black tree based NavigableMap implementation. The map is sorted according to the Comparable of
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now