svnno****@sourc*****
svnno****@sourc*****
2007年 10月 25日 (木) 16:54:34 JST
Revision: 654 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=654 Author: shinsuke Date: 2007-10-25 16:54:33 +0900 (Thu, 25 Oct 2007) Log Message: ----------- code format. Modified Paths: -------------- pal-admin/trunk/src/main/java/jp/sf/pal/admin/deployer/DeploymentStatus.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/deployer/PortletDeployer.java -------------- next part -------------- Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/deployer/DeploymentStatus.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/deployer/DeploymentStatus.java 2007-10-23 04:37:37 UTC (rev 653) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/deployer/DeploymentStatus.java 2007-10-25 07:54:33 UTC (rev 654) @@ -18,8 +18,7 @@ import jp.sf.pal.admin.entity.PortletApplication; -public class DeploymentStatus -{ +public class DeploymentStatus { public static final int DEPLOYED = 2; public static final int DEPLOYING = 1; @@ -32,8 +31,7 @@ public PortletApplication portletApplication; - public DeploymentStatus(PortletApplication portletApplication) - { + public DeploymentStatus(PortletApplication portletApplication) { startTime = 0; status = READY; this.portletApplication = portletApplication; @@ -42,48 +40,42 @@ /** * @return the status */ - public int getStatus() - { + public int getStatus() { return status; } /** * @param status the status to set */ - public void setStatus(int status) - { + public void setStatus(int status) { this.status = status; } /** * @return the portletApplication */ - public PortletApplication getPortletApplication() - { + public PortletApplication getPortletApplication() { return portletApplication; } /** * @param portletApplication the portletApplication to set */ - public void setPortletApplication(PortletApplication portletApplication) - { + public void setPortletApplication(PortletApplication portletApplication) { this.portletApplication = portletApplication; } /** * @return the startTime */ - public long getStartTime() - { + public long getStartTime() { return startTime; } /** * @param startTime the startTime to set */ - public void setStartTime(long startTime) - { + public void setStartTime(long startTime) { this.startTime = startTime; } } Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/deployer/PortletDeployer.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/deployer/PortletDeployer.java 2007-10-23 04:37:37 UTC (rev 653) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/deployer/PortletDeployer.java 2007-10-25 07:54:33 UTC (rev 654) @@ -35,8 +35,7 @@ import org.apache.jetspeed.deployment.DeploymentException; import org.apache.jetspeed.deployment.DeploymentManager; -public class PortletDeployer extends Thread -{ +public class PortletDeployer extends Thread { public static final String FILEPATH_PROTOCOL_HTTPS = "https:"; public static final String PATH_PROTOCOL_HTTP = "http:"; @@ -57,8 +56,7 @@ private DeploymentStatus deploymentStatus; - public PortletDeployer(PortletApplication portletApplication) - { + public PortletDeployer(PortletApplication portletApplication) { this.portletApplication = portletApplication; deploymentStatus = new DeploymentStatus(portletApplication); } @@ -66,122 +64,82 @@ /* (non-Javadoc) * @see java.lang.Thread#run() */ - public void run() - { + public void run() { deploymentStatus.setStatus(DeploymentStatus.DEPLOYING); - try - { + try { deploymentStatus.setStartTime(Calendar.getInstance() .getTimeInMillis()); - if (getDeploymentManager() != null) - { + if (getDeploymentManager() != null) { String binaryUrl = portletApplication.getBinaryUrl(); - if (binaryUrl != null && !binaryUrl.equals("")) - { + if (binaryUrl != null && !binaryUrl.equals("")) { File targetFile = null; - try - { + try { File tempFile = null; - if (binaryUrl.startsWith(FILEPATH_PROTOCOL_TEMP)) - { - tempFile=new File(binaryUrl.substring(FILEPATH_PROTOCOL_TEMP.length())); - } - else - { + if (binaryUrl.startsWith(FILEPATH_PROTOCOL_TEMP)) { + tempFile = new File(binaryUrl + .substring(FILEPATH_PROTOCOL_TEMP.length())); + } else { tempFile = File.createTempFile("rpad_", "." + portletApplication.getPackaging()); FileOutputStream out = new FileOutputStream( tempFile); PALAdminUtil.drain(getInputStream(binaryUrl), out); } - try - { + try { targetFile = new File(tempFile.getParentFile(), portletApplication.getArtifactId() + "." + portletApplication.getPackaging()); tempFile.renameTo(targetFile); - } - catch (Exception e) - { + } catch (Exception e) { targetFile = tempFile; } if (getDeploymentManager().deploy(targetFile) - .getStatus() == org.apache.jetspeed.deployment.DeploymentStatus.STATUS_OKAY) - { + .getStatus() == org.apache.jetspeed.deployment.DeploymentStatus.STATUS_OKAY) { log.info(portletApplication.getName() + " was deployed."); - } - else - { + } else { log.error("Could not deploy " + portletApplication.getName()); } - } - catch (FileNotFoundException e) - { + } catch (FileNotFoundException e) { log.error(e); - } - catch (IOException e) - { + } catch (IOException e) { log.error(e); - } - catch (DeploymentException e) - { + } catch (DeploymentException e) { log.error(e); } - if (targetFile != null && targetFile.exists()) - { + if (targetFile != null && targetFile.exists()) { targetFile.delete(); } - } - else - { + } else { log.error("The target url is invalid. The path is " + binaryUrl); } - } - else - { + } else { log.error("Could not find the deployment manager."); } - } - catch (Exception e) - { + } catch (Exception e) { log.error("Unexpected exception.", e); - } - finally - { + } finally { deploymentStatus.setStatus(DeploymentStatus.DEPLOYED); } } - protected InputStream getInputStream(String path) - { + protected InputStream getInputStream(String path) { if (path.startsWith(PATH_PROTOCOL_HTTP) - || path.startsWith(FILEPATH_PROTOCOL_HTTPS)) - { - try - { + || path.startsWith(FILEPATH_PROTOCOL_HTTPS)) { + try { URL url = new URL(path); return url.openStream(); - } - catch (MalformedURLException e) - { + } catch (MalformedURLException e) { log.error("Wrong url: " + path, e); - } - catch (IOException e) - { + } catch (IOException e) { log.error("Could not load " + path, e); } - } - else if (path.startsWith(FILEPATH_PROTOCOL_FILE)) - { - try - { + } else if (path.startsWith(FILEPATH_PROTOCOL_FILE)) { + try { return new FileInputStream(new File(path.substring(5))); - } - catch (FileNotFoundException e) - { + } catch (FileNotFoundException e) { log.error("Could not load " + path, e); } } @@ -191,48 +149,42 @@ /** * @return the portletApplication */ - public PortletApplication getPortletApplication() - { + public PortletApplication getPortletApplication() { return portletApplication; } /** * @param portletApplication the portletApplication to set */ - public void setPortletApplication(PortletApplication portletApplication) - { + public void setPortletApplication(PortletApplication portletApplication) { this.portletApplication = portletApplication; } /** * @return the deploymentManager */ - public DeploymentManager getDeploymentManager() - { + public DeploymentManager getDeploymentManager() { return deploymentManager; } /** * @param deploymentManager the deploymentManager to set */ - public void setDeploymentManager(DeploymentManager deploymentManager) - { + public void setDeploymentManager(DeploymentManager deploymentManager) { this.deploymentManager = deploymentManager; } /** * @return the deploymentStatus */ - public DeploymentStatus getDeploymentStatus() - { + public DeploymentStatus getDeploymentStatus() { return deploymentStatus; } /** * @param deploymentStatus the deploymentStatus to set */ - public void setDeploymentStatus(DeploymentStatus deploymentStatus) - { + public void setDeploymentStatus(DeploymentStatus deploymentStatus) { this.deploymentStatus = deploymentStatus; }