@Override public final Record getConversionOf(final Record record) throws Exception { final Record out = record; final SitoolsSettings sitoolsSettings = (SitoolsSettings) getContext().getAttributes().get(ContextAttributes.SETTINGS); final String dataStorageUrl = sitoolsSettings.getString(Consts.APP_DATASTORAGE_ADMIN_URL) + "/directories"; final String dataStorageRelativePart = sitoolsSettings.getString(Consts.APP_DATASTORAGE_URL); final String sitoolsUrl = sitoolsSettings.getString(Consts.APP_URL); final String dataStorageName = getInternParam("DataStorageName").getValue(); final StorageDirectory storageDirectory = RIAPUtils.getObjectFromName(dataStorageUrl, dataStorageName, getContext()); final String dataStorageAttachUrl = sitoolsUrl + dataStorageRelativePart + storageDirectory.getAttachUrl(); LOG.log(Level.FINER, "dataStorageAttachUrl: {0}", dataStorageAttachUrl); final String dataStorageLocalPath = storageDirectory.getLocalPath(); final AttributeValue urlAttr = getInParam("Url", record); final Object urlObj = urlAttr.getValue(); if (Util.isSet(urlObj)) { final String url = String.valueOf(urlObj); final String filename = url.replace(dataStorageAttachUrl, ""); LOG.log(Level.FINER, "filename: {0}", filename); String absoluteFileName = dataStorageLocalPath.concat(filename); LOG.log(Level.FINER, "absoluteFileName: {0}", absoluteFileName); absoluteFileName = absoluteFileName.replace("file://", ""); final File file = new File(absoluteFileName); if (!(file.exists() && file.isFile())) { urlAttr.setValue(getInternParam("ImageNotFoundUrl").getValue()); } } return out; }
/* * (non-Javadoc) * * @see fr.cnes.sitools.plugins.resources.model.ResourceModel#initParametersForAdmin(org.restlet.Context) */ @Override public void initParametersForAdmin(Context context) { super.initParametersForAdmin(context); SitoolsSettings settings = (SitoolsSettings) context.getAttributes().get(ContextAttributes.SETTINGS); ResourceParameter nbThreads = getParameterByName("nbThreads"); nbThreads.setValue(settings.getString(Consts.DEFAULT_THREAD_POOL_SIZE)); }