public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (receiver instanceof IProject) { return PropertiesUtil.hasNonDefaultEncodingLanguagePropertiesFile((IProject) receiver); } return false; }
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { boolean retval = false; if (receiver instanceof IProject) { retval = PropertiesUtil.hasNonDefaultEncodingLanguagePropertiesFile((IProject) receiver); } else if (receiver instanceof IFile) { try { if (!ILiferayConstants.LANGUAGE_PROPERTIES_FILE_ENCODING_CHARSET.equals( ((IFile) receiver).getCharset()) && PropertiesUtil.isLanguagePropertiesFile((IFile) receiver)) { retval = true; } } catch (CoreException e) { LiferayCore.logError(e); } } return retval; }
private static void updateLocalJar(SimpleDateFormat sdf, File bladeCacheSettings) throws Exception { String latestJar = getLatestRemoteBladeCLIJar(); if (latestJar == null) { File bundledJar = getLocalCopy(); latestJar = bundledJar.getName(); cachedBladeCLIPath = new Path(bundledJar.getCanonicalPath()); } Properties props = new Properties(); props.setProperty(timeStampKey, sdf.format(new Date())); props.setProperty(localJarKey, latestJar); PropertiesUtil.saveProperties(props, bladeCacheSettings); }
private static boolean shouldUpdate(SimpleDateFormat sdf, File bladeCacheSettingsFile) throws BladeCLIException { boolean shouldUpdate = false; // file doesn't exist if (!bladeCacheSettingsFile.exists()) { return true; } Properties props = PropertiesUtil.loadProperties(bladeCacheSettingsFile); // can't load properties if (props == null) { return true; } String up2dateCheckTimestamp = props.getProperty(timeStampKey); Date lastTime = null; try { lastTime = sdf.parse(up2dateCheckTimestamp); } catch (ParseException e) { } // can't parse time if (lastTime == null) { return true; } String validTime = getValidTime(); if (validTime.equals("-1")) { // do nothing } else if (validTime.equals("0")) { shouldUpdate = true; } else { String scope; int count; try { scope = validTime.substring(validTime.length() - 1, validTime.length()); String countStr = validTime.substring(0, validTime.length() - 1); count = Integer.parseInt(countStr); } catch (Exception e) { scope = "h"; count = 24; } Date currentTime = new Date(); long distance = currentTime.getTime() - lastTime.getTime(); if (scope.equals("h")) { long hours = distance / 1000 / 3600; if (hours > count) { shouldUpdate = true; } } else if (scope.equals("m")) { long minutes = distance / 1000 / 60; if (minutes > count) { shouldUpdate = true; } } else if (scope.equals("s")) { long seconds = distance / 1000; if (seconds > count) { shouldUpdate = true; } } else { shouldUpdate = true; } } if (!shouldUpdate) { try { File localJarFile = new File(getRepoCacheDir(), props.getProperty(localJarKey)); if (!localJarFile.exists()) { return true; } else { cachedBladeCLIPath = new Path(localJarFile.getCanonicalPath()); } } catch (Exception e) { throw new BladeCLIException(e.getMessage()); } } return shouldUpdate; }