Esempio n. 1
0
  /**
   * Checks if a file has been modified by comparing the last update date of both files and
   * Artifact. If they are different, the file is assumed to have been modified.
   *
   * @param artifact artifact to check for modification
   * @return boolean value of artifact modified or not
   */
  public static boolean isArtifactModified(Artifact artifact) {
    long currentTimeStamp = artifact.getLastModifiedTime();

    setArtifactLastModifiedTime(artifact);

    return (currentTimeStamp != artifact.getLastModifiedTime());
  }
 private void addToDeployedArtifacts(Artifact artifact) {
   ConcurrentHashMap<Object, Artifact> artifactMap = deployedArtifacts.get(artifact.getType());
   if (artifactMap == null) {
     artifactMap = new ConcurrentHashMap<Object, Artifact>();
   }
   artifactMap.put(artifact.getKey(), artifact);
   deployedArtifacts.put(artifact.getType(), artifactMap);
 }
 private void removeFromDeployedArtifacts(Artifact artifact) {
   Map<Object, Artifact> artifactMap = deployedArtifacts.get(artifact.getType());
   if (artifactMap != null && artifactMap.containsKey(artifact.getKey())) {
     artifactMap.remove(artifact.getKey());
     if (artifactMap.isEmpty()) {
       deployedArtifacts.remove(artifact.getType());
     }
   }
 }
 /**
  * Undeploy the artifacts found in the artifact to be undeployed list
  *
  * @param artifactsToUndeploy list of artifacts to undeploy
  */
 public void undeployArtifacts(List<Artifact> artifactsToUndeploy) {
   for (Object artifact : artifactsToUndeploy) {
     Artifact artifactToUnDeploy = (Artifact) artifact;
     try {
       Deployer deployer = getDeployer(artifactToUnDeploy.getType());
       if (deployer != null) {
         deployer.undeploy(artifactToUnDeploy.getKey());
         removeFromDeployedArtifacts(artifactToUnDeploy);
       } else {
         throw new CarbonDeploymentException(
             "Deployer instance cannot be found for "
                 + "the type : "
                 + artifactToUnDeploy.getType());
       }
     } catch (CarbonDeploymentException e) {
       logger.error("Error while undeploying artifacts", e);
     }
   }
 }
 /**
  * Updates the artifacts found in the artifacts to be updated list
  *
  * @param artifactsToUpdate list of artifacts to update
  */
 public void updateArtifacts(List<Artifact> artifactsToUpdate) {
   for (Object artifact : artifactsToUpdate) {
     Artifact artifactToUpdate = (Artifact) artifact;
     try {
       Deployer deployer = getDeployer(artifactToUpdate.getType());
       if (deployer != null) {
         Object artifactKey = deployer.update(artifactToUpdate);
         artifactToUpdate.setKey(artifactKey);
         addToDeployedArtifacts(artifactToUpdate);
       } else {
         throw new CarbonDeploymentException(
             "Deployer instance cannot be found for "
                 + "the type : "
                 + artifactToUpdate.getType());
       }
     } catch (CarbonDeploymentException e) {
       // TODO : Handle faulty artifact deployment
       logger.error("Error while updating artifacts", e);
     }
   }
 }
Esempio n. 6
0
 /**
  * Sets the last modified time to the given artifact
  *
  * @param artifact artifact for update modified time
  */
 public static void setArtifactLastModifiedTime(Artifact artifact) {
   File file = artifact.getFile();
   if (file != null && (artifact.getLastModifiedTime() < file.lastModified())) {
     artifact.setLastModifiedTime(file.lastModified());
   }
 }