Package com.ibm.as400.access

Examples of com.ibm.as400.access.CharConverter


            throw new RuntimeCamelException("Unable to read from data queue: " + queue.getName(), e);
        }
    }

    private Exchange receive(DataQueue queue, long timeout) throws Exception {
        DataQueueEntry entry;
        if (timeout >= 0) {
            int seconds = (int) timeout / 1000;
            log.trace("Reading from data queue: {} with {} seconds timeout", queue.getName(), seconds);
            entry = queue.read(seconds);
        } else {
            log.trace("Reading from data queue: {} with no timeout", queue.getName());
            entry = queue.read(-1);
        }

        Exchange exchange = new DefaultExchange(endpoint.getCamelContext());
        if (entry != null) {
            exchange.getIn().setHeader(Jt400DataQueueEndpoint.SENDER_INFORMATION, entry.getSenderInformation());
            if (endpoint.getFormat() == Format.binary) {
                exchange.getIn().setBody(entry.getData());
            } else {
                exchange.getIn().setBody(entry.getString());
            }
            return exchange;
        }
        return null;
    }
View Full Code Here


     *            indicates a blocking read.
     */
    public Exchange receive(long timeout) {
        DataQueue queue = endpoint.getDataQueue();
        try {
            DataQueueEntry entry;
            if (timeout >= 0) {
                entry = queue.read((int)timeout);
            } else {
                entry = queue.read();
            }
            Exchange exchange = new DefaultExchange(endpoint.getCamelContext());
            if (entry != null) {
                if (endpoint.getFormat() == Format.binary) {
                    exchange.getIn().setBody(entry.getData());
                } else {
                    exchange.getIn().setBody(entry.getString());
                }
                return exchange;
            }
        } catch (AS400SecurityException e) {
            throw new RuntimeCamelException("Unable to read from data queue: " + e.getMessage(), e);
View Full Code Here

     *            indicates a blocking read.
     */
    public Exchange receive(long timeout) {
        DataQueue queue = endpoint.getDataQueue();
        try {
            DataQueueEntry entry;
            if (timeout >= 0) {
                int seconds = (int)timeout / 1000;
                log.trace("Reading from data queue: {} with {} seconds timeout", queue.getName(), seconds);
                entry = queue.read(seconds);
            } else {
                log.trace("Reading from data queue: {} with no timeout", queue.getName());
                entry = queue.read(-1);
            }

            Exchange exchange = new DefaultExchange(endpoint.getCamelContext());
            if (entry != null) {
                if (endpoint.getFormat() == Format.binary) {
                    exchange.getIn().setBody(entry.getData());
                } else {
                    exchange.getIn().setBody(entry.getString());
                }
                return exchange;
            }
        } catch (AS400SecurityException e) {
            throw new RuntimeCamelException("Unable to read from data queue: " + queue.getName(), e);
View Full Code Here

  {
    try
    {
      // Write file ONLY if file exist because the format of the file is
      // needed!
      if (new IFSFile(mAS400System, mQSYSobjPathname.getPath()).exists())
      {
        // initiate the SequentialFile object
        mOriginFile = new SequentialFile(mAS400System, mQSYSobjPathname
            .getPath());
View Full Code Here

   *                server.
   */
  protected void renameFile(AS400 as400System, String sourceFilename,
      String destFilename) throws XException
  {
    IFSFile srcFile = new IFSFile(as400System, sourceFilename);
    IFSFile destFile = new IFSFile(as400System, destFilename);

    // construct temp name and temp member for destination file
    String tempName = new StringBuffer(destFile.getParent()).append(
        Constants.FILE_SEPERATOR).append("xbusTemp.MBR").toString();
    IFSFile tempFile = null;
    try
    {
      // 1. rename destination file to temp one if it exists
      if (destFile.exists())
      {
        tempFile = new IFSFile(as400System, tempName);
        if (tempFile.exists())
          if (!tempFile.delete())
          {
            throw new XException(Constants.LOCATION_EXTERN,
                Constants.LAYER_TECHNICAL,
                Constants.PACKAGE_TECHNICAL_AS400, "7",
                (List) null);
          }
        if (!destFile.renameTo(tempFile))
        {
          throw new XException(Constants.LOCATION_EXTERN,
              Constants.LAYER_TECHNICAL,
              Constants.PACKAGE_TECHNICAL_AS400, "8", (List) null);
        }
        // Reinitialize to check existance of the renamed member
        // Return value of renameTo is not reliable. It may be <true>
        // even if
        // the renaming was not successful.
        tempFile = new IFSFile(as400System, tempName);
        // Make sure that renaming was successful.
        if (!tempFile.exists())
        {
          throw new XException(Constants.LOCATION_EXTERN,
              Constants.LAYER_TECHNICAL,
              Constants.PACKAGE_TECHNICAL_AS400, "8", (List) null);
        }
        // Reinitialise to allow further renaming
        destFile = new IFSFile(as400System, destFilename);
      } // if (destFile.exists())

      boolean renameBackTempFile = false;
      // Should the renaming of the destination member be reversed?

      // 2. rename source file to dest file
      if (srcFile.renameTo(destFile))
      {
        // Reinitialise to check existance of the destination file
        // Return value of renameTo is not reliable. It may be <true>
        // even if
        // the renaming was not successful.
        destFile = new IFSFile(as400System, destFilename);
        // Make sure that renaming was successful.
        if (!destFile.exists())
          renameBackTempFile = true;
        // delete temp member
        if (tempFile != null && tempFile.exists())
          deleteMember(as400System, tempName);
      } // if (srcFile.renameTo(destFile))
      else
        // Reverse initial renaming of the destination file member
        renameBackTempFile = true;

      // 3. Rename the destination file member bach to its original name
      // if
      // any error prevented the renaming of the source file.
      // Only necessary if the destination filemember existed before and
      // was
      // renamed to a temporyry member name.
      if (tempFile != null && renameBackTempFile)
      { // Reverse initial renaming of the destination file member
        // Reinitialise to allow backwards renaming
        destFile = new IFSFile(as400System, destFilename);
        // rename back temp member to destination member
        tempFile.renameTo(destFile);

        List params = new Vector();
        params.add(sourceFilename);
        params.add(destFilename);
        throw new XException(Constants.LOCATION_EXTERN,
View Full Code Here

    {
      // Open the source file for exclusive access.
      source = new IFSFileInputStream(as400System, sourceName,
          IFSFileInputStream.SHARE_NONE);

      IFSFile targetFile = new IFSFile(as400System, targetName);
      if (!targetFile.exists())
      {
        targetFile.createNewFile();
      } // if (!targetFile.exists())

      // Open the target file for exclusive access.
      target = new IFSFileOutputStream(as400System, targetName,
          IFSFileOutputStream.SHARE_NONE, false);
View Full Code Here

      // Create an object in the integrated file system for the file name.
      // It is used to parse an integrated file system name into its
      // components.
      mQSYSObject = new QSYSObjectPathName(xbusSystem
          .replaceAllMarkers(mConfigFilename)[0]);
      IFSFile ifsFile = new IFSFile(mAS400System, mQSYSObject.getPath());

      // only if the file exist and it is accessible.
      if (ifsFile.exists())
      {
        Trace.info("Receiving data from "
            + xbusSystem.replaceAllMarkers(mConfigFilename)[0]);

        // initiate the SequentialFile object
View Full Code Here

  protected void copyFile(AS400 as400System, String sourceName,
      String targetName) throws XException
  {
    byte[] buffer = new byte[1024 * 64];

    IFSFileInputStream source = null;
    IFSFileOutputStream target = null;
    try
    {
      // Open the source file for exclusive access.
      source = new IFSFileInputStream(as400System, sourceName,
          IFSFileInputStream.SHARE_NONE);

      IFSFile targetFile = new IFSFile(as400System, targetName);
      if (!targetFile.exists())
      {
        targetFile.createNewFile();
      } // if (!targetFile.exists())

      // Open the target file for exclusive access.
      target = new IFSFileOutputStream(as400System, targetName,
          IFSFileOutputStream.SHARE_NONE, false);

      // Read the first 64K bytes from the source file.
      int bytesRead = source.read(buffer);

      // While there is data in the source file copy the data from
      // the source file to the target file.
      while (bytesRead > 0)
      {
        target.write(buffer, 0, bytesRead);
        bytesRead = source.read(buffer);
      }

      // Clean up by closing the source and target file.
      source.close();
      target.close();
    } // try
    catch (Exception e)
    {
      // If any of the above operations failed trace error
View Full Code Here

      String targetName) throws XException
  {
    byte[] buffer = new byte[1024 * 64];

    IFSFileInputStream source = null;
    IFSFileOutputStream target = null;
    try
    {
      // Open the source file for exclusive access.
      source = new IFSFileInputStream(as400System, sourceName,
          IFSFileInputStream.SHARE_NONE);

      IFSFile targetFile = new IFSFile(as400System, targetName);
      if (!targetFile.exists())
      {
        targetFile.createNewFile();
      } // if (!targetFile.exists())

      // Open the target file for exclusive access.
      target = new IFSFileOutputStream(as400System, targetName,
          IFSFileOutputStream.SHARE_NONE, false);

      // Read the first 64K bytes from the source file.
      int bytesRead = source.read(buffer);

      // While there is data in the source file copy the data from
      // the source file to the target file.
      while (bytesRead > 0)
      {
        target.write(buffer, 0, bytesRead);
        bytesRead = source.read(buffer);
      }

      // Clean up by closing the source and target file.
      source.close();
      target.close();
    } // try
    catch (Exception e)
    {
      // If any of the above operations failed trace error
      // and output the exception.
View Full Code Here

    @Deprecated
    protected BaseDataQueue getDataQueue() {
        if (dataQueue == null) {
            AS400 system = new AS400(baseEndpoint.getSystemName(), baseEndpoint.getUserID(), baseEndpoint.getPassword());
            String objectPath = baseEndpoint.getObjectPath();
            dataQueue = keyed ? new KeyedDataQueue(system, objectPath) : new DataQueue(system, objectPath);
        }
        return dataQueue;
    }
View Full Code Here

TOP

Related Classes of com.ibm.as400.access.CharConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.