/* (non-Javadoc)
  * @see com.aptana.ide.core.ftp.BaseFTPConnectionFileManager#changeFilePermissions(org.eclipse.core.runtime.IPath, long, org.eclipse.core.runtime.IProgressMonitor)
  */
 @Override
 protected void changeFilePermissions(IPath path, long permissions, IProgressMonitor monitor)
     throws CoreException, FileNotFoundException {
   if (chmodSupported == Boolean.FALSE) {
     return;
   }
   try {
     IPath dirPath = path.removeLastSegments(1);
     changeCurrentDir(dirPath);
     Policy.checkCanceled(monitor);
     chmodSupported =
         ftpClient.site(
             "CHMOD "
                 + Long.toOctalString(permissions)
                 + " "
                 + path.lastSegment()); // $NON-NLS-1$ //$NON-NLS-2$
   } catch (FileNotFoundException e) {
     throw e;
   } catch (OperationCanceledException e) {
     throw e;
   } catch (Exception e) {
     throw new CoreException(
         new Status(Status.ERROR, FTPPlugin.PLUGIN_ID, "Set permissions failed", e));
   } finally {
     monitor.done();
   }
 }
  public Policy unmarshall(JsonUnmarshallerContext context) throws Exception {
    Policy policy = new Policy();

    int originalDepth = context.getCurrentDepth();
    String currentParentElement = context.getCurrentParentElement();
    int targetDepth = originalDepth + 1;

    JsonToken token = context.getCurrentToken();
    if (token == null) token = context.nextToken();
    if (token == VALUE_NULL) return null;

    while (true) {
      if (token == null) break;

      if (token == FIELD_NAME || token == START_OBJECT) {
        if (context.testExpression("policyName", targetDepth)) {
          context.nextToken();
          policy.setPolicyName(StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("policyArn", targetDepth)) {
          context.nextToken();
          policy.setPolicyArn(StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
      } else if (token == END_ARRAY || token == END_OBJECT) {
        if (context.getLastParsedParentElement() == null
            || context.getLastParsedParentElement().equals(currentParentElement)) {
          if (context.getCurrentDepth() <= originalDepth) break;
        }
      }
      token = context.nextToken();
    }

    return policy;
  }
 private void createPolicy() throws Exception {
   Policy policy = new Policy(POLICY_NAME, "", false);
   PolicyManager pm = new PolicyManager(adminToken, SUB_REALM1);
   SubjectTypeManager mgr = pm.getSubjectTypeManager();
   Subject subject = mgr.getSubject("AuthenticatedUsers");
   Map<String, Set<String>> actionValues = new HashMap<String, Set<String>>();
   {
     Set<String> set = new HashSet<String>();
     set.add("allow");
     actionValues.put("GET", set);
   }
   {
     Set<String> set = new HashSet<String>();
     set.add("allow");
     actionValues.put("POST", set);
   }
   policy.addRule(
       new Rule(
           "rule",
           "iPlanetAMWebAgentService",
           "http://www.ReferredResourcesTest.com/1/2",
           actionValues));
   policy.addSubject("subject", subject);
   pm.addPolicy(policy);
 }
  public static float trajectoryReward(
      State initialState,
      Policy p,
      int nbOfSteps,
      LinkedList<State> statesTrajectory,
      LinkedList<Action> actionsTrajectory,
      LinkedList<Float> rewardsTrajectory) {
    State s = initialState;
    Action a = p.chooseAction(s);
    float trajectoryReward = reward(s, a);

    if (statesTrajectory != null) {
      statesTrajectory.add(s);
      actionsTrajectory.add(a);
      rewardsTrajectory.add(reward(s, a));
    }

    int nbOfIterations = 1;
    while (!s.isTerminal() && nbOfIterations < nbOfSteps) {
      s = MarkovDecisionProcess.nextState(s, a);
      a = p.chooseAction(s);
      trajectoryReward += reward(s, a);

      if (statesTrajectory != null) {
        statesTrajectory.add(s);
        actionsTrajectory.add(a);
        rewardsTrajectory.add(reward(s, a));
      }

      nbOfIterations++;
    }

    return trajectoryReward;
  }
  /** Loads the relevant preference values from the JOSM preferences */
  public void initFromPreferences() {
    String pref = Main.pref.get("pluginmanager.version-based-update.policy", "ask");
    Policy p = Policy.fromPreferenceValue(pref);
    if (p == null) {
      p = Policy.ASK;
    }
    rbVersionBasedUpatePolicy.get(p).setSelected(true);

    pref = Main.pref.get("pluginmanager.time-based-update.policy", "ask");
    p = Policy.fromPreferenceValue(pref);
    if (p == null) {
      p = Policy.ASK;
    }
    rbTimeBasedUpatePolicy.get(p).setSelected(true);

    pref = Main.pref.get("pluginmanager.warntime", null);
    int days = 0;
    if (pref != null) {
      // remove legacy preference
      Main.pref.put("pluginmanager.warntime", null);
      pref = pref.trim();
      try {
        days = Integer.parseInt(pref);
      } catch (NumberFormatException e) {
        // ignore - load from preference pluginmanager.time-based-update.interval
      }
      if (days <= 0) {
        days = 60;
      }
    }
    if (days == 0) {
      days = Main.pref.getInteger("preference pluginmanager.time-based-update.interval", 60);
    }
    tfUpdateInterval.setText(Integer.toString(days));
  }
Exemple #6
0
 @Override
 public void setCharset(String newCharset, IProgressMonitor monitor) throws CoreException {
   monitor = Policy.monitorFor(monitor);
   try {
     String message = NLS.bind(Messages.resources_settingCharset, getFullPath());
     monitor.beginTask(message, Policy.totalWork);
     // need to get the project as a scheduling rule because we might be creating a new folder/file
     // to
     // hold the project settings
     final ISchedulingRule rule = workspace.getRuleFactory().charsetRule(this);
     try {
       workspace.prepareOperation(rule, monitor);
       ResourceInfo info = getResourceInfo(false, false);
       checkAccessible(getFlags(info));
       workspace.beginOperation(true);
       workspace.getCharsetManager().setCharsetFor(getFullPath(), newCharset);
       info = getResourceInfo(false, true);
       info.incrementCharsetGenerationCount();
       monitor.worked(Policy.opWork);
     } catch (OperationCanceledException e) {
       workspace.getWorkManager().operationCanceled();
       throw e;
     } finally {
       workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork));
     }
   } finally {
     monitor.done();
   }
 }
Exemple #7
0
 @Override
 public void setContents(InputStream content, int updateFlags, IProgressMonitor monitor)
     throws CoreException {
   monitor = Policy.monitorFor(monitor);
   try {
     String message = NLS.bind(Messages.resources_settingContents, getFullPath());
     monitor.beginTask(message, Policy.totalWork);
     if (workspace.shouldValidate) workspace.validateSave(this);
     final ISchedulingRule rule = workspace.getRuleFactory().modifyRule(this);
     try {
       workspace.prepareOperation(rule, monitor);
       ResourceInfo info = getResourceInfo(false, false);
       checkAccessible(getFlags(info));
       workspace.beginOperation(true);
       IFileInfo fileInfo = getStore().fetchInfo();
       internalSetContents(
           content, fileInfo, updateFlags, false, Policy.subMonitorFor(monitor, Policy.opWork));
     } catch (OperationCanceledException e) {
       workspace.getWorkManager().operationCanceled();
       throw e;
     } finally {
       workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork));
     }
   } finally {
     monitor.done();
     FileUtil.safeClose(content);
   }
 }
 public static PanelPermission getInstance(Principal prpal, Object resource) {
   Policy policy = SecurityServices.lookup().getSecurityPolicy();
   PanelPermission perm =
       (PanelPermission)
           policy.getPermission(prpal, PanelPermission.class, getResourceName(resource));
   if (perm == null) perm = PanelPermission.newInstance(resource, null);
   return perm;
 }
 static Policy fromPreferenceValue(String preferenceValue) {
   if (preferenceValue == null) return null;
   preferenceValue = preferenceValue.trim().toLowerCase();
   for (Policy p : Policy.values()) {
     if (p.getPreferencesValue().equals(preferenceValue)) return p;
   }
   return null;
 }
 @Override
 public PrabAction makeDecisionS(State s, Task t, Random outRand) {
   Random thisRand = outRand == null ? random : outRand;
   PrabAction policyAction = policy.makeDecisionS(s, t, thisRand);
   if (policyAction == null) {
     policyAction = rp.makeDecisionS(s, t, random);
   }
   return policyAction;
 }
  /**
   * Main constructor used from POA::create_POA. This need only be visible within the POA package.
   */
  Policies(Policy[] policies, int id) throws InvalidPolicy {
    // Make sure the defaults are set according to the POA spec
    this();

    defaultObjectCopierFactoryId = id;

    if (policies == null) return;

    // Set to record all indices in policies for which errors
    // were observed.
    BitSet errorSet = new BitSet(policies.length);

    for (short i = 0; i < policies.length; i++) {
      Policy policy = policies[i];
      int POAPolicyValue = getPOAPolicyValue(policy);

      // Save the policy in policyMap to support
      // POA.get_effective_policy, if it was not already saved
      // in policyMap.
      Integer key = new Integer(policy.policy_type());
      Policy prev = (Policy) (policyMap.get(key));
      if (prev == null) policyMap.put(key, policy);

      if (POAPolicyValue >= 0) {
        setPolicyValue(key.intValue(), POAPolicyValue);

        // if the value of this POA policy was previously set to a
        // different value than the current value given in
        // POAPolicyValue, record an error.
        if ((prev != null) && (getPOAPolicyValue(prev) != POAPolicyValue)) errorSet.set(i);
      }
    }

    // Check for bad policy combinations

    // NON_RETAIN requires USE_DEFAULT_SERVANT or USE_SERVANT_MANAGER
    if (!retainServants() && useActiveMapOnly()) {
      addToErrorSet(policies, SERVANT_RETENTION_POLICY_ID.value, errorSet);
      addToErrorSet(policies, REQUEST_PROCESSING_POLICY_ID.value, errorSet);
    }

    // IMPLICIT_ACTIVATION requires SYSTEM_ID and RETAIN
    if (isImplicitlyActivated()) {
      if (!retainServants()) {
        addToErrorSet(policies, IMPLICIT_ACTIVATION_POLICY_ID.value, errorSet);
        addToErrorSet(policies, SERVANT_RETENTION_POLICY_ID.value, errorSet);
      }

      if (!isSystemAssignedIds()) {
        addToErrorSet(policies, IMPLICIT_ACTIVATION_POLICY_ID.value, errorSet);
        addToErrorSet(policies, ID_ASSIGNMENT_POLICY_ID.value, errorSet);
      }
    }

    checkForPolicyError(errorSet);
  }
  /* this code is workaround for subtle bug/feature in JDK1.3.1 and 1.4,
  related to loading applets behind proxy */
  protected PermissionCollection getPermissions(CodeSource codesource) {
    PermissionCollection sysPerms = null;
    Policy policy =
        (Policy)
            AccessController.doPrivileged(
                new PrivilegedAction() {
                  public Object run() {
                    return Policy.getPolicy();
                  }
                });
    if (policy != null) sysPerms = policy.getPermissions(new CodeSource(null, null));
    else sysPerms = new Permissions();

    final PermissionCollection perms = sysPerms;
    if (base != null && base.getHost() != null)
      perms.add(new SocketPermission(base.getHost() + ":1-", "accept,connect,resolve"));
    URL url = codesource.getLocation();

    if (url.getProtocol().equals("file")) {

      String path = url.getFile().replace('/', File.separatorChar);

      if (!path.endsWith(File.separator)) {
        int endIndex = path.lastIndexOf(File.separatorChar);
        if (endIndex != -1) {
          path = path.substring(0, endIndex + 1) + "-";
          perms.add(new FilePermission(path, "read"));
        }
      }
      perms.add(new SocketPermission("localhost", "connect,accept"));
      AccessController.doPrivileged(
          new PrivilegedAction() {
            public Object run() {
              try {
                String host = InetAddress.getLocalHost().getHostName();
                perms.add(new SocketPermission(host, "connect,accept"));
              } catch (UnknownHostException uhe) {
              }
              return null;
            }
          });

      if (base.getProtocol().equals("file")) {
        String bpath = base.getFile().replace('/', File.separatorChar);
        if (bpath.endsWith(File.separator)) {
          bpath += "-";
        }
        perms.add(new FilePermission(bpath, "read"));
      }
    }
    // for (Enumeration e=perms.elements();e.hasMoreElements();)
    // System.err.println("p="+e.nextElement());
    return perms;
  }
  /**
   * Confers with policy and calls appropriate callback method.
   *
   * @param response
   * @param rawData
   */
  private void handleResponse(int response, ResponseData rawData) {
    // Update policy data and increment retry counter (if needed)
    mPolicy.processServerResponse(response, rawData);

    // Given everything we know, including cached data, ask the policy if we should grant
    // access.
    if (mPolicy.allowAccess(System.currentTimeMillis())) {
      mCallback.allow(response);
    } else {
      mCallback.dontAllow(response);
    }
  }
Exemple #14
0
 public void addAuthenticationFunction() {
   Policy policy = getPolicy(true);
   AndExpression andN = policy.getAndNode(true);
   andN.addLiteralExpression(
       "xdi.getGraphValue('"
           + XRI_SECRET_TOKEN
           + "') != null && (xdi.getGraphValue('"
           + XRI_SECRET_TOKEN
           + "') == xdi.getMessageProperty('"
           + XRI_SECRET_TOKEN
           + "'))");
 }
Exemple #15
0
  public Repository toRepository() {
    Repository result = new Repository();
    result.setId(myId);
    result.setName(myName);
    result.setUrl(myUrl);
    result.setLayout(myLayout);

    if (myReleasesPolicy != null) result.setReleases(myReleasesPolicy.toRepositoryPolicy());
    if (mySnapshotsPolicy != null) result.setSnapshots(mySnapshotsPolicy.toRepositoryPolicy());

    return result;
  }
 private void recursiveDeleteTree(IPath path, IProgressMonitor monitor, MultiStatus status)
     throws IOException, ParseException {
   try {
     changeCurrentDir(path);
     FTPFile[] ftpFiles = listFiles(path, monitor);
     List<String> dirs = new ArrayList<String>();
     for (FTPFile ftpFile : ftpFiles) {
       String name = ftpFile.getName();
       if (".".equals(name) || "..".equals(name)) { // $NON-NLS-1$ //$NON-NLS-2$
         continue;
       }
       if (ftpFile.isDir()) {
         dirs.add(name);
         continue;
       }
       Policy.checkCanceled(monitor);
       monitor.subTask(path.append(name).toPortableString());
       try {
         ftpClient.delete(name);
       } catch (FTPException e) {
         status.add(
             new Status(
                 IStatus.ERROR,
                 FTPPlugin.PLUGIN_ID,
                 StringUtils.format(
                     Messages.FTPConnectionFileManager_deleting_failed,
                     path.append(name).toPortableString()),
                 e));
       }
       monitor.worked(1);
     }
     for (String name : dirs) {
       monitor.subTask(path.append(name).toPortableString());
       recursiveDeleteTree(path.append(name), monitor, status);
       Policy.checkCanceled(monitor);
       changeCurrentDir(path);
       Policy.checkCanceled(monitor);
       ftpClient.rmdir(name);
       monitor.worked(1);
     }
   } catch (IOException e) {
     throw e;
   } catch (Exception e) {
     status.add(
         new Status(
             IStatus.ERROR,
             FTPPlugin.PLUGIN_ID,
             StringUtils.format(
                 Messages.FTPConnectionFileManager_deleting_failed, path.toPortableString()),
             e));
   }
 }
 /*
  * Execute the RunnableEvent
  */
 private void executeRunnable(Event event, IProgressMonitor monitor) {
   try {
     // Dispatch any queued results to clear pending output events
     dispatchEvents(Policy.subMonitorFor(monitor, 1));
   } catch (TeamException e) {
     handleException(e);
   }
   try {
     ((RunnableEvent) event).run(Policy.subMonitorFor(monitor, 1));
   } catch (CoreException e) {
     handleException(e);
   }
 }
  @Test(dependsOnMethods = {"createReferralPolicyWithoutRule"})
  private void addRuleToReferralPolicy() throws Exception {
    PolicyManager pm = new PolicyManager(adminToken, "/");
    Policy policy = pm.getPolicy(REFERRAL_POLICY_NAME2);

    Rule rule = new Rule("iPlanetAMWebAgentService", Collections.EMPTY_MAP);
    Set<String> set = new HashSet<String>();
    set.add("http://www.ReferredResourcesTest.com/1/*");
    rule.setResourceNames(set);
    policy.addRule(rule);

    pm.replacePolicy(policy);
  }
  /**
   * Returns a list of classes which should be preloaded.
   *
   * @param takeAllClasses forces all classes to be taken (irrespective of ranking)
   */
  List<LoadedClass> highestRankedClasses(boolean takeAllClasses) {
    if (!isApplication()) {
      return Collections.emptyList();
    }

    // Sort by rank.
    Operation[] ranked = new Operation[operations.size()];
    ranked = operations.toArray(ranked);
    Arrays.sort(ranked, new ClassRank());

    // The percentage of time to save by preloading.
    int timeToSave = totalTimeMicros() * percentageToPreload() / 100;
    int timeSaved = 0;

    boolean service = Policy.isService(this.name);

    List<LoadedClass> highest = new ArrayList<LoadedClass>();
    for (Operation operation : ranked) {

      // These are actual ranking decisions, which can be overridden
      if (!takeAllClasses) {
        if (highest.size() >= MAX_TO_PRELOAD) {
          System.out.println(name + " got " + (timeSaved * 100 / timeToSave) + "% through");
          break;
        }

        if (timeSaved >= timeToSave) {
          break;
        }
      }

      // The remaining rules apply even to wired-down processes
      if (!Policy.isPreloadableClass(operation.loadedClass.name)) {
        continue;
      }

      if (!operation.loadedClass.systemClass) {
        continue;
      }

      // Only load java.* class for services.
      if (!service || operation.loadedClass.name.startsWith("java.")) {
        highest.add(operation.loadedClass);
      }

      // For services, still count the time even if it's not in java.*
      timeSaved += operation.medianExclusiveTimeMicros();
    }

    return highest;
  }
Exemple #20
0
 /** Find a "relatively" unused element, but not the element just added. */
 protected final Element findEvictionCandidate(Element elementJustAdded) {
   Element[] elements;
   if (useKeySample) {
     elements = sampleElementsViaKeyArray();
     // this can return null. Let the cache get bigger by one.
     Element element = policy.selectedBasedOnPolicy(elements, elementJustAdded);
     return element;
   } else {
     // +1 because element was added
     elements = sampleElements(map.size());
     // this can return null. Let the cache get bigger by one.
     return policy.selectedBasedOnPolicy(elements, elementJustAdded);
   }
 }
  public static void logPerformances(Policy policy, boolean logBadTrajectories) {
    float[] performance = performance(policy, logBadTrajectories);

    PrintWriter performanceLog = null;
    try {
      performanceLog = new PrintWriter(new FileWriter("performance.log", true));
    } catch (IOException e) {
      e.printStackTrace();
    }

    String line;
    if (policy.getClass() == DirectPolicySearch.class) {
      DirectPolicySearch dps = (DirectPolicySearch) policy;
      float totalComputationTime = (float) dps.getTotalComputationTime() / 1000f / 60f;

      line =
          dps.getName()
              + ";"
              + dps.getTotalNbOfIterations()
              + ";"
              + totalComputationTime
              + ";"
              + performance[0]
              + ";"
              + performance[1];
    } else if (policy.getClass() == Qiteration.class) {
      Qiteration qit = (Qiteration) policy;
      float totalComputationTime = (float) qit.getTotalComputationTime() / 1000f / 60f;

      line =
          qit.getName()
              + ";"
              + qit.getDiscountFactor()
              + ";"
              + qit.getTotalNbOfIterations()
              + ";"
              + totalComputationTime
              + ";"
              + performance[0]
              + ";"
              + performance[1];
    } else {
      line = policy.getName() + ";" + performance[0] + ";" + performance[1];
    }
    performanceLog.println(line);

    performanceLog.close();
  }
  /** This method wraps <code>scan()</code> using the Policy object passed in. */
  public CleanResults scan(String taintedHTML, String filename)
      throws ScanException, PolicyException {

    Policy policy = Policy.getInstance(filename);

    return this.scan(taintedHTML, policy);
  }
  protected JPanel buildVersionBasedUpdatePolicyPanel() {
    JPanel pnl = new JPanel(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();
    gc.anchor = GridBagConstraints.NORTHWEST;
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1.0;

    bgVersionBasedUpdatePolicy = new ButtonGroup();
    rbVersionBasedUpatePolicy = new HashMap<Policy, JRadioButton>();
    JRadioButton btn = new JRadioButton(tr("Ask before updating"));
    rbVersionBasedUpatePolicy.put(Policy.ASK, btn);
    bgVersionBasedUpdatePolicy.add(btn);

    btn = new JRadioButton(tr("Always update withouth asking"));
    rbVersionBasedUpatePolicy.put(Policy.ALWAYS, btn);
    bgVersionBasedUpdatePolicy.add(btn);

    btn = new JRadioButton(tr("Never update"));
    rbVersionBasedUpatePolicy.put(Policy.NEVER, btn);
    bgVersionBasedUpdatePolicy.add(btn);

    JMultilineLabel lbl =
        new JMultilineLabel(
            tr(
                "Please decide whether JOSM shall automatically update active plugins at startup after an update of JOSM itself."));
    gc.gridy = 0;
    pnl.add(lbl, gc);
    for (Policy p : Policy.values()) {
      gc.gridy++;
      pnl.add(rbVersionBasedUpatePolicy.get(p), gc);
    }
    return pnl;
  }
Exemple #24
0
  public void updatePolicy(Policy policy, double discount) {
    double change;
    double maxError = MAX_ERROR * (1 - discount) / discount;
    do {
      change = 0;
      // Bellman step
      Utility u = new Utility(this);
      for (int y = 0; y < rows; y++) {
        for (int x = 0; x < cols; x++) {
          Pos p = new Pos(x, y);
          double reward = env.getRewardForPos(p);
          if (env.isTerminalState(p)) {
            util[y][x] = reward;
          } else {
            util[y][x] = reward + discount * policy.getAction(p).getProbableReward(p, u, env);
          }
        }
      }

      // get most changed
      for (int y = 0; y < rows; y++) {
        for (int x = 0; x < cols; x++) {
          double diff = Math.abs(util[y][x] - u.util[y][x]);
          if (diff > change) {
            change = diff;
          }
        }
      }
    } while (change > maxError);
  }
  public static void create(long personID, String content) {
    try {
      User user = User.loadFromSession();
      Person person = Person.findById(personID);

      Policy policy =
          Policy.getInstance(
              Play.applicationPath.getAbsolutePath() + "/conf/antisamy-myspace-1.3.xml");
      AntiSamy as = new AntiSamy();
      CleanResults cr = as.scan(content, policy);

      InsConfidential c = new InsConfidential();
      c.content = cr.getCleanHTML();
      c.createAt = new GregorianCalendar();
      c.employe = user.person;
      c.person = person;
      c.save();

      flash.success("messageAdded");

      InsConfidentials.show(personID);
    } catch (ScanException ex) {
      Logger.error(InsConfidentials.class.getName() + " : " + ex);
    } catch (PolicyException ex) {
      Logger.error(InsConfidentials.class.getName() + " : " + ex);
    }
  }
  public static void save(long id, String content) {
    try {

      Policy policy =
          Policy.getInstance(
              Play.applicationPath.getAbsolutePath() + "/conf/antisamy-myspace-1.3.xml");
      AntiSamy as = new AntiSamy();
      CleanResults cr = as.scan(content, policy);

      InsConfidential c = InsConfidential.findById(id);
      c.content = cr.getCleanHTML();
      c.save();

      PersonEvaluation.changeMessage(c);

      renderJSON("{\"result\":\"ok\"}");

    } catch (ScanException ex) {

      Logger.error(InsConfidentials.class.getName() + " : " + ex);
      renderJSON("{\"result\":\"ko\"}");
    } catch (PolicyException ex) {

      Logger.error(InsConfidentials.class.getName() + " : " + ex);
      renderJSON("{\"result\":\"ko\"}");
    }
  }
 /* (non-Javadoc)
  * @see com.aptana.ide.core.ftp.BaseFTPConnectionFileManager#deleteFile(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IProgressMonitor)
  */
 @Override
 protected void deleteFile(IPath path, IProgressMonitor monitor)
     throws CoreException, FileNotFoundException {
   try {
     IPath dirPath = path.removeLastSegments(1);
     changeCurrentDir(dirPath);
     Policy.checkCanceled(monitor);
     try {
       ftpClient.delete(path.lastSegment());
     } catch (FTPException e) {
       System.out.println(e);
       throw e;
     }
   } catch (FileNotFoundException e) {
     throw e;
   } catch (OperationCanceledException e) {
     throw e;
   } catch (Exception e) {
     throw new CoreException(
         new Status(
             Status.ERROR,
             FTPPlugin.PLUGIN_ID,
             StringUtils.format(Messages.FTPConnectionFileManager_deleting_failed, path),
             e));
   } finally {
     monitor.done();
   }
 }
 /* (non-Javadoc)
  * @see com.aptana.ide.core.ftp.BaseFTPConnectionFileManager#renameFile(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IProgressMonitor)
  */
 @Override
 protected void renameFile(IPath sourcePath, IPath destinationPath, IProgressMonitor monitor)
     throws CoreException, FileNotFoundException {
   try {
     changeCurrentDir(Path.ROOT);
     Policy.checkCanceled(monitor);
     try {
       ftpClient.rename(sourcePath.toPortableString(), destinationPath.toPortableString());
     } catch (FTPException e) {
       throwFileNotFound(e, sourcePath);
       System.out.println(e);
       throw e;
     }
   } catch (FileNotFoundException e) {
     throw e;
   } catch (OperationCanceledException e) {
     throw e;
   } catch (Exception e) {
     throw new CoreException(
         new Status(
             Status.ERROR,
             FTPPlugin.PLUGIN_ID,
             Messages.FTPConnectionFileManager_renaming_failed,
             e));
   } finally {
     monitor.done();
   }
 }
 /* (non-Javadoc)
  * @see com.aptana.ide.core.ftp.IFTPConnectionFileManager#init(java.lang.String, int, org.eclipse.core.runtime.IPath, java.lang.String, char[], boolean, java.lang.String, java.lang.String, java.lang.String)
  */
 public void init(
     String host,
     int port,
     IPath basePath,
     String login,
     char[] password,
     boolean passive,
     String transferType,
     String encoding,
     String timezone) {
   Assert.isTrue(ftpClient == null, Messages.FTPConnectionFileManager_already_initialized);
   try {
     this.pool = new FTPClientPool(this);
     ftpClient = createFTPClient();
     this.host = host;
     this.port = port;
     this.login = login;
     this.password = (password == null) ? new char[0] : password;
     this.basePath = basePath != null ? basePath : Path.ROOT;
     this.authId = Policy.generateAuthId("FTP", login, host, port); // $NON-NLS-1$
     this.transferType = transferType;
     this.timezone = timezone != null && timezone.length() == 0 ? null : timezone;
     initFTPClient(ftpClient, passive, encoding);
   } catch (Exception e) {
     IdeLog.logImportant(
         FTPPlugin.getDefault(), Messages.FTPConnectionFileManager_initialization_failed, e);
     ftpClient = null;
   }
 }
 /* (non-Javadoc)
  * @see com.aptana.ide.core.io.vfs.IConnectionFileManager#disconnect(org.eclipse.core.runtime.IProgressMonitor)
  */
 public synchronized void disconnect(IProgressMonitor monitor) throws CoreException {
   try {
     checkConnected();
   } catch (Exception ignore) {
   }
   if (!isConnected()) {
     return;
   }
   monitor = Policy.monitorFor(monitor);
   monitor.beginTask(
       Messages.FTPConnectionFileManager_closing_connection, IProgressMonitor.UNKNOWN);
   try {
     ftpClient.quit();
   } catch (Exception e) {
     try {
       ftpClient.quitImmediately();
     } catch (Exception ignore) {
     }
     throw new CoreException(
         new Status(
             Status.ERROR,
             FTPPlugin.PLUGIN_ID,
             Messages.FTPConnectionFileManager_disconnect_failed,
             e));
   } finally {
     cwd = null;
     pool.dispose();
     cleanup();
     monitor.done();
   }
 }