Codota Logo
RepositoryFile.readFile
Code IndexAdd Codota to your IDE (free)

How to use
readFile
method
in
org.datacleaner.repository.RepositoryFile

Best Java code snippets using org.datacleaner.repository.RepositoryFile.readFile (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

  @Override
  public void run(final OutputStream out) throws Exception {
    existingFile.readFile(new Action<InputStream>() {
      @Override
      public void run(final InputStream in) throws Exception {
        FileHelper.copy(in, out);
      }
    });
  }
});
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

@Override
public void toXml(final OutputStream out) {
  _file.readFile(new Action<InputStream>() {
    @Override
    public void run(InputStream in) throws Exception {
      FileHelper.copy(in, out);
    }
  });
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

  @Override
  public void run(final OutputStream out) throws Exception {
    oldScheduleFile.readFile(new Action<InputStream>() {
      @Override
      public void run(final InputStream in) throws Exception {
        FileHelper.copy(in, out);
      }
    });
  }
};
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

  @Override
  public void run(final OutputStream out) throws Exception {
    existingFile.readFile(new Action<InputStream>() {
      @Override
      public void run(InputStream in) throws Exception {
        FileHelper.copy(in, out);
      }
    });
  }
};
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

@Override
public void toXml(final OutputStream out) {
  _file.readFile(new Action<InputStream>() {
    @Override
    public void run(InputStream in) throws Exception {
      FileHelper.copy(in, out);
    }
  });
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

public CustomJavaComponentJob getCustomJavaComponentJob() {
  // there's a 2 second read cache time - enough to only need to read once
  // for executing a job under normal circumstances
  if (_cachedReadTime == -1 || System.currentTimeMillis() - _cachedReadTime > 2000) {
    _cachedCustomJavaJob = _file
        .readFile(new Func<InputStream, CustomJavaComponentJob>() {
          @Override
          public CustomJavaComponentJob eval(InputStream in) {
            final JaxbCustomJavaComponentJobAdaptor adaptor = new JaxbCustomJavaComponentJobAdaptor();
            CustomJavaComponentJob result = adaptor.unmarshal(in);
            _cachedReadTime = System.currentTimeMillis();
            return result;
          }
        });
  }
  return _cachedCustomJavaJob;
}
origin: datacleaner/DataCleaner

@SuppressWarnings("deprecation")
@Override
public InputStream read() throws ResourceException {
  return getRepositoryFile().readFile();
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

public WriteUpdatedConfigurationFileAction(InputStream updatedConfigurationInputStream,
    RepositoryFile existingConfigurationFile, boolean onlyReferenceData) throws JAXBException {
  super(Configuration.class);
  _updatedConfigurationInputStream = updatedConfigurationInputStream;
  _onlyReferenceData = onlyReferenceData;
  Configuration existingConfiguration;
  try {
    if (existingConfigurationFile == null) {
      existingConfiguration = null;
    } else {
      existingConfiguration = existingConfigurationFile.readFile(in -> {
        return unmarshal(in);
      });
    }
  } catch (Exception e) {
    logger.warn("Failed to parse configuration file - treating it as invalid and will override.", e);
    existingConfiguration = null;
  }
  _existingConfiguration = existingConfiguration;
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

private Document getConfigurationFileDocument(TenantContext tenantContext) {
  return tenantContext.getConfigurationFile().readFile(in -> {
    try {
      return getDocumentBuilder().parse(in);
    } catch (Exception e) {
      throw new IllegalStateException("Could not parse configuration file", e);
    }
  });
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

@Override
public AnalysisResult getAnalysisResult() throws IllegalStateException {
  final Object deserializedObject = _repositoryFile.readFile(new Func<InputStream, Object>() {
    @Override
    public Object eval(InputStream in) {
      ChangeAwareObjectInputStream inputStream = null;
      try {
        inputStream = new ChangeAwareObjectInputStream(in);
        return inputStream.readObject();
      } catch (Exception e) {
        if (e instanceof RuntimeException) {
          throw (RuntimeException) e;
        }
        throw new IllegalStateException(e);
      } finally {
        FileHelper.safeClose(inputStream);
      }
    }
  });
  final AnalysisResult analysisResult = toAnalysisResult(deserializedObject);
  return analysisResult;
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

  /**
   * Read all files from repository
   *
   * @return
   */
  @Override
  public List<ComponentStoreHolder> getList() {
    readLock.lock();
    final List<ComponentStoreHolder> holderList = new ArrayList<>();
    try {
      List<RepositoryFile> files = componentsFolder.getFiles();
      for (RepositoryFile file : files) {
        file.readFile(new Action<InputStream>() {
          @Override
          public void run(InputStream arg) throws Exception {
            String theString = IOUtils.toString(arg);
            holderList.add(objectMapper.readValue(theString, ComponentStoreHolder.class));
          }
        });
      }
    } finally {
      readLock.unlock();
    }
    return holderList;
  }
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

/**
 * Read file from repository and transform it to object
 *
 * @param instanceId
 * @return
 */
public ComponentStoreHolder get(String instanceId) {
  logger.info("Read component with id: {}", instanceId);
  readLock.lock();
  final ComponentStoreHolder[] conf = new ComponentStoreHolder[1];
  try {
    RepositoryFile configFile = componentsFolder.getFile(instanceId);
    if (configFile == null) {
      return null;
    }
    configFile.readFile(new Action<InputStream>() {
      @Override
      public void run(InputStream arg) throws Exception {
        String theString = IOUtils.toString(arg);
        conf[0] = objectMapper.readValue(theString, ComponentStoreHolder.class);
      }
    });
  } finally {
    readLock.unlock();
  }
  return conf[0];
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

  @RolesAllowed(SecurityRoles.CONFIGURATION_EDITOR)
  @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_XML_VALUE)
  @ResponseBody
  public HttpEntity<byte[]> downloadConfigurationFile(@PathVariable("tenant") final String tenant) {

    final TenantContext context = _contextFactory.getContext(tenant);
    final RepositoryFile configurationFile = context.getConfigurationFile();

    if (configurationFile == null) {
      throw new IllegalStateException("Configuration file not found!");
    }

    final byte[] documentBody = configurationFile.readFile(new Func<InputStream, byte[]>() {
      @Override
      public byte[] eval(InputStream in) {
        return FileHelper.readAsBytes(in);
      }
    });

    final HttpHeaders header = new HttpHeaders();
    header.setContentType(MediaType.APPLICATION_XML);
    header.setContentLength(documentBody.length);
    return new HttpEntity<byte[]>(documentBody, header);

  }
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

  @Override
  public ExecutionIdentifier eval(final RepositoryFile file) {
    try {
      final ExecutionIdentifier result = file.readFile(
          new Func<InputStream, ExecutionIdentifier>() {
            @Override
            public ExecutionIdentifier eval(InputStream in) {
              return SaxExecutionIdentifierReader.read(in, file.getQualifiedPath());
            }
          });
      return result;
    } catch (Exception e) {
      logger.warn("The file " + file.getQualifiedPath()
          + " could not be read or parsed correctly " + e);
      return new ExecutionIdentifier("Execution failed for " + FilenameUtils.getBaseName(file
          .getQualifiedPath()));
    }
  }
});
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

@RolesAllowed(SecurityRoles.JOB_EDITOR)
@RequestMapping("/conf.xml")
public void fetchConfigurationFile(@PathVariable("tenant") final String tenant,
    @RequestParam(value = "job", required = false) final String jobName,
    @RequestParam(value = "datastore", required = false) final String datastoreName,
    final HttpServletResponse response) throws Exception {
  final TenantContext tenantContext = _tenantContextFactory.getContext(tenant);
  
  final DataCleanerJobContext jobContext;
  if (StringUtils.isNullOrEmpty(jobName)) { 
    jobContext = null;
  } else {
    final JobContext job = tenantContext.getJob(jobName);
    if (!(job instanceof DataCleanerJobContext)) {
      throw new UnsupportedOperationException("Job not compatible with operation: " + job);
    }
    jobContext = (DataCleanerJobContext) job;
  }
  final RepositoryFile confFile = tenantContext.getConfigurationFile();
  response.setContentType("application/xml");
  final ServletOutputStream out = response.getOutputStream();
  confFile.readFile(new Action<InputStream>() {
    @Override
    public void run(InputStream in) throws Exception {
      // intercept the input stream to decorate it with client-side
      // config elements.
      _configurationInterceptor.intercept(tenant, jobContext, datastoreName, in, out);
    }
  });
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

  @Override
  public Map<String, String> getMetadataProperties() {
    final RepositoryFile file = getJobFile();

    final DataCleanerConfiguration configuration = _tenantContext.getConfiguration();
    final AnalysisJobMetadata jobMetadata = file.readFile(new Func<InputStream, AnalysisJobMetadata>() {
      @Override
      public AnalysisJobMetadata eval(InputStream in) {
        final JaxbJobReader jobReader = new JaxbJobReader(configuration);
        AnalysisJobMetadata metadata = jobReader.readMetadata(in);
        return metadata;
      }
    });
    
    if (jobMetadata == null) {
      return Collections.emptyMap();
    }

    return jobMetadata.getProperties();
  }
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

@Override
public TimelineDefinition getTimelineDefinition(TimelineIdentifier timeline) {
  final String path = timeline.getPath();
  logger.info("Reading timeline from file: {}", path);
  final RepositoryFile timelineNode = (RepositoryFile) _repository.getRepositoryNode(path);
  if (timelineNode == null) {
    throw new IllegalArgumentException("No such timeline: " + timeline.getName() + " (in group: "
        + timeline.getGroup() + ")");
  }
  final TimelineDefinition timelineDefinition = timelineNode
      .readFile(new Func<InputStream, TimelineDefinition>() {
        @Override
        public TimelineDefinition eval(InputStream in) {
          final TimelineReader reader = new JaxbTimelineReader();
          final TimelineDefinition timelineDefinition = reader.read(in);
          return timelineDefinition;
        }
      });
  return timelineDefinition;
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

public void removeReferenceData(final TenantContext tenantContext, final ReferenceData referenceData)
    throws IllegalArgumentException {
  if (referenceData == null) {
    throw new IllegalArgumentException("Reference data can not be null");
  }
  final JaxbConfigurationReader jaxbConfigurationAdaptor = new JaxbConfigurationReader();
  final RepositoryFile configurationFile = tenantContext.getConfigurationFile();
  final Configuration configuration = configurationFile.readFile(in -> {
    return jaxbConfigurationAdaptor.unmarshall(in);
  });
  boolean found = false;
  final List<Object> referenceDataList = getReferenceDataListByType(configuration, referenceData);
  for (Iterator<Object> it = referenceDataList.iterator(); it.hasNext(); ) {
    final String candidateName = WriteUpdatedConfigurationFileAction.getComparableName(it.next());
    if (referenceData.getName().equals(candidateName)) {
      it.remove();
      found = true;
      break;
    }
  }
  if (!found) {
    throw new IllegalArgumentException("Could not find reference data with name '" + referenceData + "'");
  }
  configurationFile.writeFile(out -> {
    jaxbConfigurationAdaptor.marshall(configuration, out);
  });
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

DataCleanerConfiguration readConfiguration(Map<String, String> overrideProperties) {
  final ConfigurationReaderInterceptor interceptor = new MonitorConfigurationReaderInterceptor(_repository,
      _tenantContext, overrideProperties, _injectionManagerFactory);
  final JaxbConfigurationReader reader = new JaxbConfigurationReader(interceptor);
  final RepositoryFile configurationFile = getConfigurationFile();
  _lastModifiedCache = configurationFile.getLastModified();
  if (_lastModifiedCache < 0) {
    logger.warn(
        "Last modified timestamp was negative ({})! Returning plain DataCleanerConfiguration since this indicates that the file has been deleted.",
        _lastModifiedCache);
    final RepositoryFolder tenantRootFolder = _tenantContext.getTenantRootFolder();
    final DataCleanerHomeFolder homeFolder = new DataCleanerHomeFolderImpl(tenantRootFolder);
    final DataCleanerEnvironmentImpl baseEnvironment = MonitorConfigurationReaderInterceptor.createBaseEnvironment(_injectionManagerFactory);
    return new DataCleanerConfigurationImpl(baseEnvironment, homeFolder);
  }
  logger.info("Reading configuration from file: {}", configurationFile);
  final DataCleanerConfiguration readConfiguration = configurationFile
      .readFile(new Func<InputStream, DataCleanerConfiguration>() {
        @Override
        public DataCleanerConfiguration eval(InputStream inputStream) {
          final DataCleanerConfiguration readConfiguration = reader.read(inputStream);
          return readConfiguration;
        }
      });
  return readConfiguration;
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

/**
 * Checks if the current copy of the metadata object is recent.
 * 
 * @param metadataObject
 *            the object to look for.
 */
private void verifyJobMetadataCurrent(final Object metadataObject) {
  long lastModified = _file.getLastModified();
  if (metadataObject == null || lastModified != _lastModifiedCache) {
    synchronized (this) {
      lastModified = _file.getLastModified();
      if (_sourceDatastoreName == null || lastModified != _lastModifiedCache) {
        final DataCleanerConfiguration configuration = _tenantContext.getConfiguration();
        final AnalysisJobMetadata metadata = _file.readFile(new Func<InputStream, AnalysisJobMetadata>() {
          @Override
          public AnalysisJobMetadata eval(InputStream in) {
            final JaxbJobReader jobReader = new JaxbJobReader(configuration);
            AnalysisJobMetadata metadata = jobReader.readMetadata(in);
            return metadata;
          }
        });
        _sourceDatastoreName = metadata.getDatastoreName();
        _sourceColumnPaths = metadata.getSourceColumnPaths();
        _variables = metadata.getVariables();
      }
    }
  }
}
org.datacleaner.repositoryRepositoryFilereadFile

Javadoc

Opens up an InputStream to read from the file.

Popular methods of RepositoryFile

  • writeFile
    Opens up an OutputStream to write to the file.
  • delete
  • getLastModified
  • getName
  • getQualifiedPath
  • getSize
  • getType
  • toResource

Popular in Java

  • Creating JSON documents from java classes using gson
  • requestLocationUpdates (LocationManager)
  • findViewById (Activity)
  • putExtra (Intent)
  • FileWriter (java.io)
    Convenience class for writing character files. The constructors of this class assume that the defaul
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • JTable (javax.swing)
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
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