public Translator[] getChildren(Object o, int versionID) { if (o == null) return CommonTranslators.EMPTY_CHILDREN; else if (((Module) o).isEjbModule()) return EJB_TRANSLATORS; else if (((Module) o).isConnectorModule()) return CONNECTOR_TRANSLATORS; else if (((Module) o).isWebModule()) return WEB_TRANSLATORS; else if (((Module) o).isJavaModule()) return JAVA_TRANSLATORS; else throw new IllegalStateException("Internal error: Module Type excepted"); //$NON-NLS-1$ }
while( iterator.hasNext() ) { Module module = (Module)iterator.next(); if( module.isWebModule() ) {
/** * validate security constraints, roles, and security role refs. */ public void validateSecurity() { EList earRoleList = appDD.getSecurityRoles(); if (!earRoleList.isEmpty()) validateEarRoles(earRoleList); EList moduleList = appDD.getModules(); if (!moduleList.isEmpty()) { for (int i = 0; i < moduleList.size(); i++) { Module m = (Module) moduleList.get(i); if (m.isEjbModule()) { EList ejbRoles = m.getApplication().getSecurityRoles(); if (!ejbRoles.isEmpty()) validateEJBRolesWithEARRoles(earRoleList, ejbRoles); }// if if (m.isWebModule()) { EList webRoles = m.getApplication().getSecurityRoles(); if (!webRoles.isEmpty()) validateWEBRolesWithEARRoles(earRoleList, webRoles); }// if }// for }// if }// validateSecurity
protected void renameRolesInModuleDDs(String existingRoleName, String newRoleName) { List modules = getDeploymentDescriptor().getModules(); for (int i = 0; i < modules.size(); i++) { Module m = (Module) modules.get(i); try { if (m.isEjbModule()) getDeploymentDescriptor((EjbModule) m).renameSecurityRole(existingRoleName, newRoleName); else if (m.isWebModule()) getDeploymentDescriptor((WebModule) m).renameSecurityRole(existingRoleName, newRoleName); } catch (Exception e) { throw new DeploymentDescriptorLoadException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.dd_in_ear_load_EXC_, (new Object[]{m.getUri(), getURI()})), e); // = "Exception occurred loading deployment descriptor for module "{0}" in ear file "{1}"" } } }
/** * @see com.ibm.etools.commonarchive.EARFile */ public void rollUpRoles(Module aModule) { List securityRoles = null; try { if (aModule.isWebModule()) securityRoles = getDeploymentDescriptor((WebModule) aModule).getSecurityRoles(); else if (aModule.isEjbModule()) securityRoles = getAssemblyDescriptorAddIfNecessary(getDeploymentDescriptor((EjbModule) aModule)).getSecurityRoles(); } catch (Exception e) { throw new DeploymentDescriptorLoadException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.dd_in_ear_load_EXC_, (new Object[]{aModule.getUri(), getURI()})), e); // = "Exception occurred loading deployment descriptor for module "{0}" in ear file "{1}"" } if (securityRoles == null) return; for (int i = 0; i < securityRoles.size(); i++) { addCopyIfNotExists((SecurityRole) securityRoles.get(i)); } }
foundBinary = true; Object binaryModule = null; if (module.isWebModule()) { WebArtifactEdit webEdit = WebArtifactEdit.getWebArtifactEditForRead(component); if (webEdit != null) {
/** * @param module * @return */ private List getEJBReferneces(Module module) throws ResourceLoadException, FileNotFoundException, EmptyResourceException { if (module != null) { if (module.isEjbModule()) { EJBJar ejbJar = getDeploymentDescriptor((EjbModule) module); return getEJBReferences(ejbJar); } else if (module.isWebModule()) { WebApp webApp = getDeploymentDescriptor((WebModule) module); if (webApp != null) return webApp.getEjbRefs(); } else if (module.isJavaModule()) { ApplicationClient appClient = getDeploymentDescriptor((JavaClientModule) module); if (appClient != null) return appClient.getEjbReferences(); } } return Collections.EMPTY_LIST; }
/** * @see EARFile */ public void pushDownRole(SecurityRole role, Module aModule) { try { if (aModule.isWebModule()) { WebApp dd = getDeploymentDescriptor((WebModule) aModule); if (dd.getSecurityRoleNamed(role.getRoleName()) == null) dd.getSecurityRoles().add(EtoolsCopyUtility.createCopy(role)); } else if (aModule.isEjbModule()) { AssemblyDescriptor assembly = getAssemblyDescriptorAddIfNecessary(getDeploymentDescriptor((EjbModule) aModule)); if (assembly.getSecurityRoleNamed(role.getRoleName()) == null) assembly.getSecurityRoles().add(EtoolsCopyUtility.createCopy(role)); } } catch (Exception e) { throw new DeploymentDescriptorLoadException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.dd_in_ear_load_EXC_, (new Object[]{aModule.getUri(), getURI()})), e); // = "Exception occurred loading deployment descriptor for module "{0}" in ear file "{1}"" } }
/** * An alt-dd is about to be loaded; register the appropriate resource factory for the uri so it * will get loaded correctly. */ protected void registerResourceFactory(Module aModule, String aUri) { org.eclipse.emf.ecore.resource.Resource.Factory factory = null; if (aModule.isEjbModule()) factory = EJBJarResourceFactory.getRegisteredFactory(); else if (aModule.isWebModule()) factory = WebAppResourceFactory.getRegisteredFactory(); else if (aModule.isJavaModule()) factory = ApplicationClientResourceFactory.getRegisteredFactory(); else if (aModule.isConnectorModule()) factory = ConnectorResourceFactory.getRegisteredFactory(); if (factory != null) { ResourceSet set = getResourceSet(); ((FileNameResourceFactoryRegistry) set.getResourceFactoryRegistry()).registerLastFileSegment(aUri, factory); } }
/** * @see com.ibm.etools.commonarchive.EARFile */ public EList getRolesFromModule(Module aModule) { EList roleList = new org.eclipse.emf.common.util.BasicEList(); try { if (aModule.isWebModule()) roleList = getDeploymentDescriptor((WebModule) aModule).getSecurityRoles(); else if (aModule.isEjbModule()) roleList = getAssemblyDescriptorAddIfNecessary(getDeploymentDescriptor((EjbModule) aModule)).getSecurityRoles(); } catch (Exception e) { throw new DeploymentDescriptorLoadException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.dd_in_ear_load_EXC_, (new Object[]{aModule.getUri(), getURI()})), e); // = "Exception occurred loading deployment descriptor for module "{0}" in ear file "{1}"" } return roleList; }
protected ModuleRef createModuleRef(Module aModule, ModuleFile aFile) { ModuleRef newRef = null; if (aModule.isEjbModule()) newRef = getCommonArchiveFactory().createEJBModuleRef(); else if (aModule.isWebModule()) newRef = getCommonArchiveFactory().createWebModuleRef(); else if (aModule.isConnectorModule()) newRef = getCommonArchiveFactory().createConnectorModuleRef(); else if (aModule.isJavaModule()) newRef = getCommonArchiveFactory().createClientModuleRef(); newRef.setModule(aModule); newRef.setModuleFile(aFile); return newRef; }
/** * @see com.ibm.etools.commonarchive.EARFile */ public SecurityRole addCopy(SecurityRole aRole, Module aModule) throws DuplicateObjectException { EObject dd = null; try { dd = getDeploymentDescriptor(aModule); } catch (Exception e) { throw new DeploymentDescriptorLoadException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.dd_in_ear_load_EXC_, (new Object[]{aModule.getUri(), getURI()})), e); // = "Exception occurred loading deployment descriptor for module "{0}" in ear file "{1}"" } String roleName = aRole.getRoleName(); SecurityRole copy = (SecurityRole) EtoolsCopyUtility.createCopy(aRole); if (aModule.isEjbModule()) { EJBJar ejbJar = (EJBJar) dd; if (ejbJar.containsSecurityRole(roleName)) throw new DuplicateObjectException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.dup_sec_role_module_EXC_, (new Object[]{aModule.getUri(), roleName})), ejbJar.getAssemblyDescriptor().getSecurityRoleNamed(roleName)); // = "Deployment descriptor for {0} already contains a security role named {1}" getAssemblyDescriptorAddIfNecessary(ejbJar).getSecurityRoles().add(copy); } else if (aModule.isWebModule()) { WebApp webApp = (WebApp) dd; if (webApp.containsSecurityRole(roleName)) throw new DuplicateObjectException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.dup_sec_role_module_EXC_, (new Object[]{aModule.getUri(), roleName})), webApp.getSecurityRoleNamed(roleName));// = "Deployment descriptor for {0} already contains a security role named {1}" webApp.getSecurityRoles().add(copy); } addCopyIfNotExists(aRole); return copy; }
protected Archive openNestedArchive(Module m, ArchiveOptions archiveOptions) throws OpenFailureException { String aUri = m.getUri(); try { /* * Since we have a clue about the type of archive to open Use the appropriate open * method, so if a failure occurrs, we can get a more specific message */ if (m.isWebModule()) return getCommonArchiveFactory().openWARFile(archiveOptions, aUri); else if (m.isEjbModule()) return getCommonArchiveFactory().openEJBJarFile(archiveOptions, aUri); else if (m.isJavaModule()) return getCommonArchiveFactory().openApplicationClientFile(archiveOptions, aUri); else if (m.isConnectorModule()) return getCommonArchiveFactory().openRARFile(archiveOptions, aUri); } catch (OpenFailureException ex) { throw new OpenFailureException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.nested_open_fail_EXC_, (new Object[]{aUri, getURI()})), ex); // = "Unable to open module file "{0}" in EAR file "{1}"" } //Should never reach the code below return null; }
moduleVersion = ejbJar.getVersion(); else if (j2eeModule.isWebModule()) { moduleEdit = ComponentUtilities.getArtifactEditForRead(moduleComponent, J2EEProjectUtilities.DYNAMIC_WEB); WebApp webApp = (WebApp) moduleEdit.getContentModelRoot();
moduleVersion = ejbJar.getVersion(); else if (j2eeModule.isWebModule()) { moduleEdit = ComponentUtilities.getArtifactEditForRead(moduleComponent, J2EEProjectUtilities.DYNAMIC_WEB); WebApp webApp = (WebApp) moduleEdit.getContentModelRoot();
protected void checkType(Module moduleDescriptor, File aFile) { if (aFile == null) { String message = CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.A_file_does_not_exist_for_module, new Object[]{moduleDescriptor.getUri()}); throw new NoModuleFileException(message); } //Added for defect 113929 boolean isValid = true; String type = CommonArchiveResourceHandler.Module_file; if (moduleDescriptor.isWebModule() && !aFile.isWARFile()) { isValid = false; type = CommonArchiveResourceHandler.A_WAR_file; } else if (moduleDescriptor.isEjbModule() && !aFile.isEJBJarFile()) { isValid = false; type = CommonArchiveResourceHandler.An_EJB_JAR_file; } else if (moduleDescriptor.isJavaModule() && !aFile.isApplicationClientFile()) { isValid = false; type = CommonArchiveResourceHandler.An_Application_Client_JAR_file; } else if (moduleDescriptor.isConnectorModule() && !aFile.isRARFile()) { isValid = false; type = CommonArchiveResourceHandler.A_RAR_file; } else if (!aFile.isModuleFile()) isValid = false; if (isValid) return; String earUri = ""; //$NON-NLS-1$ if (getEarFile() != null) earUri = getEarFile().getURI(); String message = CommonArchiveResourceHandler.getString("File_not_correct_type", new Object[]{aFile.getURI(), earUri, type}); //$NON-NLS-1$ throw new ArchiveRuntimeException(message); }