1 /* 2 * Copyright (c) 2002-2017, Mairie de Paris 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice 10 * and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice 13 * and the following disclaimer in the documentation and/or other materials 14 * provided with the distribution. 15 * 16 * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its 17 * contributors may be used to endorse or promote products derived from 18 * this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 * 32 * License 1.0 33 */ 34 package org.apache.pluto.portalImpl; 35 36 37 //import org.apache.xml.serialize.OutputFormat; 38 import com.sun.org.apache.xml.internal.serialize.OutputFormat; 39 import com.sun.org.apache.xml.internal.serialize.XMLSerializer; 40 41 import org.apache.pluto.om.common.Parameter; 42 import org.apache.pluto.om.common.ParameterCtrl; 43 import org.apache.pluto.om.common.ParameterSet; 44 import org.apache.pluto.om.common.ParameterSetCtrl; 45 import org.apache.pluto.om.common.SecurityRoleRef; 46 import org.apache.pluto.om.common.SecurityRoleRefSet; 47 import org.apache.pluto.om.common.SecurityRoleRefSetCtrl; 48 import org.apache.pluto.om.common.SecurityRoleSet; 49 import org.apache.pluto.om.portlet.PortletDefinition; 50 import org.apache.pluto.om.servlet.ServletDefinition; 51 import org.apache.pluto.om.servlet.ServletDefinitionCtrl; 52 import org.apache.pluto.om.servlet.ServletDefinitionListCtrl; 53 import org.apache.pluto.portalImpl.om.common.impl.DescriptionImpl; 54 import org.apache.pluto.portalImpl.om.common.impl.DescriptionSetImpl; 55 import org.apache.pluto.portalImpl.om.common.impl.DisplayNameImpl; 56 import org.apache.pluto.portalImpl.om.common.impl.DisplayNameSetImpl; 57 import org.apache.pluto.portalImpl.om.portlet.impl.PortletApplicationDefinitionImpl; 58 import org.apache.pluto.portalImpl.om.servlet.impl.ServletDefinitionImpl; 59 import org.apache.pluto.portalImpl.om.servlet.impl.ServletMappingImpl; 60 import org.apache.pluto.portalImpl.om.servlet.impl.WebApplicationDefinitionImpl; 61 import org.apache.pluto.portalImpl.xml.Constants; 62 import org.apache.pluto.portalImpl.xml.XmlParser; 63 import org.apache.pluto.portlet.admin.PlutoAdminException; 64 65 //import org.apache.xml.serialize.XMLSerializer; 66 import org.exolab.castor.mapping.Mapping; 67 import org.exolab.castor.xml.Marshaller; 68 import org.exolab.castor.xml.Unmarshaller; 69 70 import java.io.BufferedReader; 71 import java.io.File; 72 import java.io.FileInputStream; 73 import java.io.FileOutputStream; 74 import java.io.FileWriter; 75 import java.io.IOException; 76 import java.io.InputStream; 77 import java.io.InputStreamReader; 78 import java.io.RandomAccessFile; 79 import java.io.Reader; 80 import java.io.StreamTokenizer; 81 82 import java.util.Collection; 83 import java.util.Enumeration; 84 import java.util.Iterator; 85 import java.util.Locale; 86 import java.util.StringTokenizer; 87 import java.util.Vector; 88 import java.util.jar.JarEntry; 89 import java.util.jar.JarFile; 90 91 92 /** 93 * @deprecated this deployment utility has been deprecated in 94 * favor of the one provided with the deploy subproject. 95 * 96 * @see org.apache.pluto.driver.deploy.CLI 97 * 98 */ 99 public class Deploy 100 { 101 private static boolean debug = false; 102 private static String dirDelim = System.getProperty( "file.separator" ); 103 private static String webInfDir = dirDelim + "WEB-INF" + dirDelim; 104 private static String webAppsDir; 105 private static String portalImplWebDir; 106 private static String plutoHome; 107 108 public static void deployArchive( String webAppsDir, String warFile ) 109 throws IOException 110 { 111 String warFileName = warFile; 112 113 if ( warFileName.indexOf( "/" ) != -1 ) 114 { 115 warFileName = warFileName.substring( warFileName.lastIndexOf( "/" ) + 1 ); 116 } 117 118 if ( warFileName.indexOf( dirDelim ) != -1 ) 119 { 120 warFileName = warFileName.substring( warFileName.lastIndexOf( dirDelim ) + 1 ); 121 } 122 123 if ( warFileName.endsWith( ".war" ) ) 124 { 125 warFileName = warFileName.substring( 0, warFileName.lastIndexOf( "." ) ); 126 } 127 128 System.out.println( "deploying '" + warFileName + "' ..." ); 129 130 String destination = webAppsDir + warFileName; 131 132 JarFile jarFile = new JarFile( warFile ); 133 Enumeration files = jarFile.entries( ); 134 135 while ( files.hasMoreElements( ) ) 136 { 137 JarEntry entry = (JarEntry) files.nextElement( ); 138 139 /* Check for use of '/WEB-INF/tld/portlet.tld' instead of 'http://java.sun.com/portlet' in taglib declaration*/ 140 String fileName = entry.getName( ); 141 142 if ( !entry.isDirectory( ) && entry.getName( ).endsWith( ".jsp" ) ) 143 { 144 InputStream is = jarFile.getInputStream( entry ); 145 Reader r = new BufferedReader( new InputStreamReader( is ) ); 146 StreamTokenizer st = new StreamTokenizer( r ); 147 st.quoteChar( '\'' ); 148 st.quoteChar( '"' ); 149 150 while ( st.nextToken( ) != StreamTokenizer.TT_EOF ) 151 { 152 if ( ( st.ttype == '\'' ) || ( st.ttype == '"' ) ) 153 { 154 String sval = st.sval; 155 String sqc = Character.toString( (char) st.ttype ); 156 157 if ( sval.equals( "/WEB-INF/tld/portlet.tld" ) ) 158 { 159 System.out.println( "Warning: " + sqc + st.sval + sqc + " has been found in file " + 160 fileName + ". Use instead " + sqc + "http://java.sun.com/portlet" + sqc + 161 " with your portlet taglib declaration!\n" ); 162 163 break; 164 } 165 } 166 } 167 } 168 169 File file = new File( destination, fileName ); 170 File dirF = new File( file.getParent( ) ); 171 dirF.mkdirs( ); 172 173 if ( entry.isDirectory( ) ) 174 { 175 file.mkdirs( ); 176 } 177 else 178 { 179 byte[] buffer = new byte[1024]; 180 int length = 0; 181 InputStream fis = jarFile.getInputStream( entry ); 182 FileOutputStream fos = new FileOutputStream( file ); 183 184 while ( ( length = fis.read( buffer ) ) >= 0 ) 185 { 186 fos.write( buffer, 0, length ); 187 } 188 189 fos.close( ); 190 } 191 } 192 193 System.out.println( "finished!" ); 194 } 195 196 public static void prepareWebArchive( String webAppsDir, String warFile ) 197 throws Exception, IOException 198 { 199 String webModule = warFile; 200 201 if ( webModule.indexOf( "/" ) != -1 ) 202 { 203 webModule = webModule.substring( webModule.lastIndexOf( "/" ) + 1 ); 204 } 205 206 if ( webModule.indexOf( dirDelim ) != -1 ) 207 { 208 webModule = webModule.substring( webModule.lastIndexOf( dirDelim ) + 1 ); 209 } 210 211 if ( webModule.endsWith( ".war" ) ) 212 { 213 webModule = webModule.substring( 0, webModule.lastIndexOf( "." ) ); 214 } 215 216 System.out.println( "prepare web archive '" + webModule + "' ..." ); 217 218 Mapping mappingPortletXml = null; 219 Mapping mappingWebXml = null; 220 221 // get portlet xml mapping file 222 String _portlet_mapping = webAppsDir + portalImplWebDir + "WEB-INF" + dirDelim + "data" + dirDelim + "xml" + 223 dirDelim + "portletdefinitionmapping.xml"; 224 mappingPortletXml = new Mapping( ); 225 226 try 227 { 228 mappingPortletXml.loadMapping( _portlet_mapping ); 229 } 230 catch ( Exception e ) 231 { 232 System.out.println( "CASTOR-Exception: " + e ); 233 throw new IOException( "Failed to load mapping file " + _portlet_mapping + ". Cause of mapping error: " + 234 e.getMessage( ) ); 235 } 236 237 File portletXml = new File( webAppsDir + webModule + webInfDir + "portlet.xml" ); 238 239 // get web xml mapping file 240 String _web_mapping = webAppsDir + portalImplWebDir + "WEB-INF" + dirDelim + "data" + dirDelim + "xml" + 241 dirDelim + "servletdefinitionmapping.xml"; 242 mappingWebXml = new Mapping( ); 243 244 try 245 { 246 mappingWebXml.loadMapping( _web_mapping ); 247 } 248 catch ( Exception e ) 249 { 250 throw new IOException( "Failed to load mapping file " + _web_mapping + ". Cause of mapping error: " + 251 e.getMessage( ) ); 252 } 253 254 File webXml = new File( webAppsDir + webModule + webInfDir + "web.xml" ); 255 256 try 257 { 258 org.w3c.dom.Document portletDocument = XmlParser.parsePortletXml( new FileInputStream( portletXml ) ); 259 260 Unmarshaller unmarshaller = new Unmarshaller( mappingPortletXml ); 261 262 // modified by YCLI: START :: to ignore extra elements and attributes 263 unmarshaller.setIgnoreExtraElements( true ); 264 unmarshaller.setIgnoreExtraAttributes( true ); 265 266 // modified by YCLI: END 267 PortletApplicationDefinitionImpl portletApp = (PortletApplicationDefinitionImpl) unmarshaller.unmarshal( portletDocument ); 268 269 // refill structure with necessary information 270 Vector structure = new Vector( ); 271 structure.add( webModule ); 272 structure.add( null ); 273 structure.add( null ); 274 portletApp.preBuild( structure ); 275 276 if ( debug ) 277 { 278 System.out.println( portletApp ); 279 } 280 281 // now generate web part 282 WebApplicationDefinitionImpl webApp = null; 283 284 if ( webXml.exists( ) ) 285 { 286 org.w3c.dom.Document webDocument = XmlParser.parseWebXml( new FileInputStream( webXml ) ); 287 288 Unmarshaller unmarshallerWeb = new Unmarshaller( mappingWebXml ); 289 290 // modified by YCLI: START :: to ignore extra elements and attributes 291 unmarshallerWeb.setIgnoreExtraElements( true ); 292 unmarshallerWeb.setIgnoreExtraAttributes( true ); 293 // modified by YCLI: END 294 webApp = (WebApplicationDefinitionImpl) unmarshallerWeb.unmarshal( webDocument ); 295 } 296 else 297 { 298 webApp = new WebApplicationDefinitionImpl( ); 299 300 DisplayNameImpl dispName = new DisplayNameImpl( ); 301 dispName.setDisplayName( webModule ); 302 dispName.setLocale( Locale.ENGLISH ); 303 304 DisplayNameSetImpl dispSet = new DisplayNameSetImpl( ); 305 dispSet.add( dispName ); 306 webApp.setDisplayNames( dispSet ); 307 308 DescriptionImpl desc = new DescriptionImpl( ); 309 desc.setDescription( "Automated generated Application Wrapper" ); 310 desc.setLocale( Locale.ENGLISH ); 311 312 DescriptionSetImpl descSet = new DescriptionSetImpl( ); 313 descSet.add( desc ); 314 webApp.setDescriptions( descSet ); 315 } 316 317 org.apache.pluto.om.ControllerFactory controllerFactory = new org.apache.pluto.portalImpl.om.ControllerFactoryImpl( ); 318 319 ServletDefinitionListCtrl servletDefinitionSetCtrl = (ServletDefinitionListCtrl) controllerFactory.get( webApp.getServletDefinitionList( ) ); 320 Collection servletMappings = webApp.getServletMappings( ); 321 322 Iterator portlets = portletApp.getPortletDefinitionList( ).iterator( ); 323 324 while ( portlets.hasNext( ) ) 325 { 326 PortletDefinition portlet = (PortletDefinition) portlets.next( ); 327 328 // check if already exists 329 ServletDefinition servlet = webApp.getServletDefinitionList( ).get( portlet.getName( ) ); 330 331 if ( servlet != null ) 332 { 333 if ( !servlet.getServletClass( ).equals( "org.apache.pluto.core.PortletServlet" ) ) 334 { 335 System.out.println( "Note: Replaced already existing the servlet with the name '" + 336 portlet.getName( ) + "' with the wrapper servlet." ); 337 } 338 339 ServletDefinitionCtrl _servletCtrl = (ServletDefinitionCtrl) controllerFactory.get( servlet ); 340 _servletCtrl.setServletClass( "org.apache.pluto.core.PortletServlet" ); 341 } 342 else 343 { 344 servlet = servletDefinitionSetCtrl.add( portlet.getName( ), "org.apache.pluto.core.PortletServlet" ); 345 } 346 347 ServletDefinitionCtrl servletCtrl = (ServletDefinitionCtrl) controllerFactory.get( servlet ); 348 349 DisplayNameImpl dispName = new DisplayNameImpl( ); 350 dispName.setDisplayName( portlet.getName( ) + " Wrapper" ); 351 dispName.setLocale( Locale.ENGLISH ); 352 353 DisplayNameSetImpl dispSet = new DisplayNameSetImpl( ); 354 dispSet.add( dispName ); 355 servletCtrl.setDisplayNames( dispSet ); 356 357 DescriptionImpl desc = new DescriptionImpl( ); 358 desc.setDescription( "Automated generated Portlet Wrapper" ); 359 desc.setLocale( Locale.ENGLISH ); 360 361 DescriptionSetImpl descSet = new DescriptionSetImpl( ); 362 descSet.add( desc ); 363 servletCtrl.setDescriptions( descSet ); 364 365 ParameterSet parameters = servlet.getInitParameterSet( ); 366 367 ParameterSetCtrl parameterSetCtrl = (ParameterSetCtrl) controllerFactory.get( parameters ); 368 369 Parameter parameter1 = parameters.get( "portlet-class" ); 370 371 if ( parameter1 == null ) 372 { 373 parameterSetCtrl.add( "portlet-class", portlet.getClassName( ) ); 374 } 375 else 376 { 377 ParameterCtrl parameterCtrl = (ParameterCtrl) controllerFactory.get( parameter1 ); 378 parameterCtrl.setValue( portlet.getClassName( ) ); 379 } 380 381 Parameter parameter2 = parameters.get( "portlet-guid" ); 382 383 if ( parameter2 == null ) 384 { 385 parameterSetCtrl.add( "portlet-guid", portlet.getId( ).toString( ) ); 386 } 387 else 388 { 389 ParameterCtrl parameterCtrl = (ParameterCtrl) controllerFactory.get( parameter2 ); 390 parameterCtrl.setValue( portlet.getId( ).toString( ) ); 391 } 392 393 boolean found = false; 394 Iterator mappings = servletMappings.iterator( ); 395 396 while ( mappings.hasNext( ) ) 397 { 398 ServletMappingImpl servletMapping = (ServletMappingImpl) mappings.next( ); 399 400 if ( servletMapping.getServletName( ).equals( portlet.getName( ) ) ) 401 { 402 found = true; 403 servletMapping.setUrlPattern( "/" + portlet.getName( ).replace( ' ', '_' ) + "/*" ); 404 } 405 } 406 407 if ( !found ) 408 { 409 ServletMappingImpl servletMapping = new ServletMappingImpl( ); 410 servletMapping.setServletName( portlet.getName( ) ); 411 servletMapping.setUrlPattern( "/" + portlet.getName( ).replace( ' ', '_' ) + "/*" ); 412 servletMappings.add( servletMapping ); 413 } 414 415 SecurityRoleRefSet servletSecurityRoleRefs = ( (ServletDefinitionImpl) servlet ).getInitSecurityRoleRefSet( ); 416 417 SecurityRoleRefSetCtrl servletSecurityRoleRefSetCtrl = (SecurityRoleRefSetCtrl) controllerFactory.get( servletSecurityRoleRefs ); 418 419 SecurityRoleSet webAppSecurityRoles = webApp.getSecurityRoles( ); 420 421 SecurityRoleRefSet portletSecurityRoleRefs = portlet.getInitSecurityRoleRefSet( ); 422 423 Iterator p = portletSecurityRoleRefs.iterator( ); 424 425 while ( p.hasNext( ) ) 426 { 427 SecurityRoleRef portletSecurityRoleRef = (SecurityRoleRef) p.next( ); 428 429 if ( ( portletSecurityRoleRef.getRoleLink( ) == null ) && 430 ( webAppSecurityRoles.get( portletSecurityRoleRef.getRoleName( ) ) == null ) ) 431 { 432 System.out.println( 433 "Note: The web application has no security role defined which matches the role name \"" + 434 portletSecurityRoleRef.getRoleName( ) + 435 "\" of the security-role-ref element defined for the wrapper-servlet with the name '" + 436 portlet.getName( ) + "'." ); 437 438 break; 439 } 440 441 SecurityRoleRef servletSecurityRoleRef = servletSecurityRoleRefs.get( portletSecurityRoleRef.getRoleName( ) ); 442 443 if ( null != servletSecurityRoleRef ) 444 { 445 System.out.println( 446 "Note: Replaced already existing element of type <security-role-ref> with value \"" + 447 portletSecurityRoleRef.getRoleName( ) + 448 "\" for subelement of type <role-name> for the wrapper-servlet with the name '" + 449 portlet.getName( ) + "'." ); 450 servletSecurityRoleRefSetCtrl.remove( servletSecurityRoleRef ); 451 } 452 453 servletSecurityRoleRefSetCtrl.add( portletSecurityRoleRef ); 454 } 455 } 456 457 if ( debug ) 458 { 459 System.out.println( webApp ); 460 } 461 462 OutputFormat of = new OutputFormat( ); 463 of.setIndenting( true ); 464 of.setIndent( 4 ); // 2-space indention 465 of.setLineWidth( 16384 ); 466 // As large as needed to prevent linebreaks in text nodes 467 of.setDoctype( Constants.WEB_PORTLET_PUBLIC_ID, Constants.WEB_PORTLET_DTD ); 468 469 FileWriter writer = new FileWriter( webAppsDir + webModule + System.getProperty( "file.separator" ) + 470 "WEB-INF" + System.getProperty( "file.separator" ) + "web.xml" ); 471 XMLSerializer serializer = new XMLSerializer( writer, of ); 472 473 try 474 { 475 Marshaller marshaller = new Marshaller( serializer.asDocumentHandler( ) ); 476 marshaller.setMapping( mappingWebXml ); 477 marshaller.marshal( webApp ); 478 } 479 catch ( Exception e ) 480 { 481 writer.close( ); 482 e.printStackTrace( System.out ); 483 throw new PlutoAdminException( "Error found in Deploy.prepareWebArchive()", e ); 484 } 485 486 // REMOVED copy of tld b/c it's now included in the container distribution. 487 //String strTo = dirDelim + "WEB-INF" + dirDelim + "tld" + dirDelim + "portlet.tld"; 488 //String strFrom = plutoHome + "portal" + dirDelim + "src" + 489 // dirDelim + "webapp" + strTo; 490 491 //copy(strFrom, webAppsDir + webModule + strTo); 492 } 493 catch ( Exception e ) 494 { 495 e.printStackTrace( System.out ); 496 throw new PlutoAdminException( "Error found in Deploy.prepareWebArchive()", e ); 497 } 498 499 System.out.println( "finished!" ); 500 } 501 502 public static void copy( String from, String to ) throws IOException 503 { 504 File f = new File( to ); 505 f.getParentFile( ).mkdirs( ); 506 507 byte[] buffer = new byte[1024]; 508 int length = 0; 509 InputStream fis = new FileInputStream( from ); 510 FileOutputStream fos = new FileOutputStream( f ); 511 512 while ( ( length = fis.read( buffer ) ) >= 0 ) 513 { 514 fos.write( buffer, 0, length ); 515 } 516 517 fos.close( ); 518 } 519 520 public static void main( String[] args ) 521 { 522 String warFile; 523 524 if ( args.length < 4 ) 525 { 526 System.out.println( "No argument specified. This command must be issued as:" ); 527 System.out.println( 528 "deploy <TOMCAT-webapps-directory> <TOMCAT-pluto-webmodule-name> <web-archive> <pluto-home-dir> [-debug] [-addToEntityReg <app-id> [<portlet-id>:<portlet-name>]+]" ); 529 530 return; 531 } 532 533 if ( args.length > 4 ) 534 { 535 if ( ( args[4].equals( "-debug" ) ) || ( args[4].equals( "/debug" ) ) ) 536 { 537 debug = true; 538 } 539 } 540 541 if ( debug ) 542 { 543 for ( int i = 0; i < args.length; i++ ) 544 { 545 System.out.println( "args[" + i + "]:" + args[i] ); 546 } 547 } 548 549 webAppsDir = args[0]; 550 551 if ( !webAppsDir.endsWith( dirDelim ) ) 552 { 553 webAppsDir += dirDelim; 554 } 555 556 portalImplWebDir = args[1]; 557 558 if ( !portalImplWebDir.endsWith( dirDelim ) ) 559 { 560 portalImplWebDir += dirDelim; 561 } 562 563 warFile = args[2]; 564 565 plutoHome = args[3]; 566 567 if ( !plutoHome.endsWith( dirDelim ) ) 568 { 569 plutoHome += dirDelim; 570 } 571 572 if ( args.length > 4 ) 573 { 574 if ( ( args[4].equals( "-debug" ) ) || ( args[4].equals( "/debug" ) ) ) 575 { 576 debug = true; 577 } 578 579 if ( ( args[4].equals( "-addToEntityReg" ) ) || 580 ( ( args.length > 5 ) && ( args[5].equals( "-addToEntityReg" ) ) ) ) 581 { 582 // parameters: app-id portlet application id; must be unique in portletentityregistry.xml 583 // portlet-id portlet id; must be unique inside the portlet application 584 // portlet-name the name of the portlet in portlet.xml 585 addToEntityReg( args ); 586 } 587 } 588 589 try 590 { 591 deployArchive( webAppsDir, warFile ); 592 593 // prepareWebArchive(webAppsDir, warFile); 594 } 595 catch ( PlutoAdminException e ) 596 { 597 throw e; 598 } 599 catch ( Exception e ) 600 { 601 e.printStackTrace( System.out ); 602 throw new PlutoAdminException( "Error found in Deploy.main()", e ); 603 } 604 } 605 606 static private void addToEntityReg( String[] args ) 607 { 608 File portletAppFile = new File( args[2] ); 609 String portletAppFileName = portletAppFile.getName( ); 610 String portletApp = portletAppFileName.substring( 0, portletAppFileName.lastIndexOf( ".war" ) ); 611 int o = ( args[4].equals( "-addToEntityReg" ) ? 5 : 6 ); 612 String appId = args[o++]; 613 614 try 615 { 616 String entityMapping = webAppsDir + portalImplWebDir + "WEB-INF/data/portletentityregistry.xml"; 617 File file = new File( entityMapping ); 618 RandomAccessFile ras = new RandomAccessFile( file, "rw" ); 619 long length = ras.length( ); 620 byte[] contentByte = new byte[(int) length]; 621 ras.read( contentByte ); 622 623 String contentString = new String( contentByte ); 624 long pos = contentString.lastIndexOf( "</portlet-entity-registry>" ); 625 ras.seek( pos ); 626 ras.writeBytes( " <application id=\"" + appId + "\">\r\n" ); 627 ras.writeBytes( " <definition-id>" + portletApp + "</definition-id>\r\n" ); 628 629 StringTokenizer tokenizer; 630 631 for ( int i = o; i < args.length; ++i ) 632 { 633 tokenizer = new StringTokenizer( args[i], ":" ); 634 635 String portletId = tokenizer.nextToken( ); 636 String portletName = tokenizer.nextToken( ); 637 ras.writeBytes( " <portlet id=\"" + portletId + "\">\r\n" ); 638 ras.writeBytes( " <definition-id>" + portletApp + "." + portletName + 639 "</definition-id>\r\n" ); 640 ras.writeBytes( " </portlet>\r\n" ); 641 } 642 643 ras.writeBytes( " </application>\r\n" ); 644 ras.writeBytes( "</portlet-entity-registry>\r\n" ); 645 ras.close( ); 646 } 647 catch ( Exception e ) 648 { 649 e.printStackTrace( System.out ); 650 throw new PlutoAdminException( "Error found in Deploy.addToEntityReg()", e ); 651 } 652 } 653 }