Package org.jayasoft.woj.common.model.content

Examples of org.jayasoft.woj.common.model.content.ModuleDescriptor


            for (int j = 0; j < modules.length; j++) {
                File module = modules[j];
                File[] revs = module.listFiles();
                for (int k = 0; k < revs.length; k++) {
                    File rev = revs[k];
                    ModuleDescriptor md = dao.getModuleDescriptor(org.getName(), module.getName(), rev.getName(), uak.getUserId(), uak.getGroups(),Visibility.PUBLIC);
                    if(md != null && !md.isNew()) {
                        File[] jars = new File(rev.getAbsolutePath()+"/"+Parameters.BINARIES_FOLDER).listFiles(new FileFilter() {
                            public boolean accept(File pathname) {
                                return pathname.getName().endsWith("zip") || pathname.getName().endsWith("jar") ;
                            }
                        });
View Full Code Here


    void removeModule(Visibility visibility, String org, String mod, String rev) throws ServiceException {
        try {
            LOGGER.info("removeModule: "+visibility+" "+org+" "+mod+" "+rev); //$NON-NLS-1$
            checkCanConnectServer();
            ModuleDescriptor md = getModuleDescriptor(visibility, org, mod, rev);
            if (md == null) {
                throw new IllegalArgumentException("unknown module "+visibility+" "+org+" "+mod+" "+rev);
            } else {
                LOGGER.debug("removeModule: "+visibility+" "+org+" "+mod+" "+rev+" => "+md.getId()); //$NON-NLS-1$
            }
            getServerServicesProvider().getModuleManagementService().removeModule(new Long(md.getId()));
            LOGGER.info("removeModule done"); //$NON-NLS-1$
        } catch (ServiceNotAvailableException e) {
            LOGGER.error("Server error while removing module ",e); //$NON-NLS-1$
            setServerNotAvailable();
            throw e;
View Full Code Here

    public ModuleInfo getModuleInfo(String md5, UAK uak) {
      LOGGER.debug("Getting ModuleInfo for checksum: " + md5);
      ModuleInfo mi = null;
        if(md5 != null) {
            ModuleDescriptorDao dao= WOJServer.getInstance().getDataService().getModuleDescriptorDao();
            ModuleDescriptor result = dao.getModuleDescriptor(md5, null, uak);
            if (result != null) {
            LOGGER.debug("ModuleInfo: " + result.toString() + " was found for md5: " + md5);
            return new ModuleInfoImpl(result.getOrganisation(), result.getModule(), result.getRevision(), result.getVisibility(), result.hasSources(), result.hasJavadoc());
            } else {
              LOGGER.warn("No ModuleInfo was found in DB for checksum: " + md5);
            }
        }
        return mi;
View Full Code Here

    }
   
    public String[] getClassList(String org, String mod, String rev, UAK uak) {
            // TODO ask to content service
            ModuleDescriptorDao dao= WOJServer.getInstance().getDataService().getModuleDescriptorDao();
            ModuleDescriptor md = dao.getModuleDescriptor(org,mod,rev,uak.getUserId(), uak.getGroups());
            if (md == null) {
                LOGGER.info("unknown module "+org+" "+mod+" "+rev+": unable to list its classes");
                return new String[0];
            }
           
            String urlVisibility;
            if (!Visibility.PUBLIC.equals(md.getVisibility())) {
                urlVisibility = md.getVisibility().getName() + "/" + md.getAccessorId();
            } else {
                urlVisibility = md.getVisibility().getName();
            }
           
        String path = getBaseDir()+"/"+urlVisibility+"/"+org+"/"+mod+"/"+rev+"/"+Parameters.SOURCES_FOLDER+"/";
            LOGGER.debug("Searching all class in " + path);       
        String[] result = null;
View Full Code Here

        }
      }
      if(mds != null) {
        Map orgs = new HashMap();
        for (int i = 0; i < mds.length; i++) {
        ModuleDescriptor descriptor = mds[i];
        String organisationName = descriptor.getOrganisation();
        Organisation organisation = (Organisation) orgs.get(organisationName);
        if(organisation == null) {
          organisation = new Organisation(organisationName);
          orgs.put(organisationName, organisation);
        }
        organisation.addModuleRevision(descriptor.getModule(), descriptor.getRevision());
      }
        List values = new ArrayList(orgs.values());
        Collections.sort(values, new Comparator() {
        public int compare(Object o1, Object o2) {
          if (o1 instanceof Organisation && o2 instanceof Organisation ) {
View Full Code Here

  private Collection getPublicModulesPaths(long since) {
    ModuleDescriptor[] mdescs = WOJServer.getInstance().getModuleManagementService().getModulesSince(since);
    Collection result = new ArrayList();
    for (int i = 0; i < mdescs.length; i++) {
      ModuleDescriptor mdesc = mdescs[i];
      if (Visibility.PUBLIC.equals(mdesc.getVisibility())) {
        String fromPath = getFileContentService().getBaseDir(mdesc);
        result.add(fromPath);
      }
    }
    return result;
View Full Code Here

    public ContentReference doGetContentReference(UAK uak, String visibility, String org, String mod, String rev, String path) {
        if (SecurityHelper.isAlreadyLogged(uak)) {
            LOGGER.info("user " + uak.getUserId() + " is already logged, unauthorized access");
            throw new DuplicateLoginException(uak);
        }
        ModuleDescriptor md = null;
        Visibility v = null;
        if (Parameters.SERVLET_NAME.DISPATCH.equals(visibility)) {
            LOGGER.info("no visibility found in url");
            ModuleDescriptorDao dao = WOJServer.getInstance().getDataService().getModuleDescriptorDao();
            md = dao.getModuleDescriptor(org, mod, rev, uak.getUserId(), uak.getGroups());
            if (md == null) {
                throw new UnknwownContentException(visibility+"/"+org+"/"+mod+"/"+rev+"/"+path);
            }
            v = md.getVisibility();
        } else {
            v = Visibility.fromString(visibility);
        }
       
        if (v == Visibility.PRIVATE) {
            ServletHelper.ensureCurrentRequestEncrypted(uak, visibility+"/"+org+"/"+mod+"/"+rev+"/"+path);
        }
               
        Long accessorId = null;
        boolean hasSources = true;
        boolean hasJavadoc = true;
        if (md != null || !Visibility.PUBLIC.equals(v)) {
            if (md == null) {
                ModuleDescriptorDao dao= WOJServer.getInstance().getDataService().getModuleDescriptorDao();
                md = dao.getModuleDescriptor(org, mod, rev, uak.getUserId(), uak.getGroups(), v);
            }
           
            // look for accessor id
            if (md == null) {
                throw new UnknwownContentException(visibility+"/"+org+"/"+mod+"/"+rev+"/"+path);
            } else {
                accessorId = md.getAccessorId();
                hasSources = md.hasSources();
                hasJavadoc = md.hasJavadoc();
            }
        }
       
        ContentModuleInfo mi = new ContentModuleInfoImpl(org, mod, rev, v, hasSources, hasJavadoc, accessorId);
       
View Full Code Here

                        LOGGER.error("Impossible to publish to visibility: "+md.getVisibility()+" for user: " +uak.getUserName());
                        throw new UnauthorizedException(uak, "publish to visibility "+md.getVisibility());
                    }

                    ModuleDescriptorDao dao = WOJServer.getInstance().getDataService().getModuleDescriptorDao();
                    ModuleDescriptor dbmd = dao.getModuleDescriptor(md.getOrganisation(), md.getModule(), md.getRevision(), uak.getUserId(), uak.getGroups(), md.getVisibility());
                    long size = computeModuleSize(zip);
                    if (dbmd != null) {
                        if (Visibility.PRIVATE.equals(md.getVisibility())) {
                            //TODO: mutex to avoid unauthorized adding
                            long replacedSize = WOJServer.getInstance().getContentService().getUsedSpace(dbmd);
                            long requiredSize = size - replacedSize;
                            requiredSize = requiredSize < 0 ? 0 : requiredSize;
                           
                            checkRequiredSize(md, requiredSize);
                        }                   
                        LOGGER.debug("removing "+dbmd.getModuleInfoAsString());
                        removeModuleDescriptor(uak, String.valueOf(dbmd.getId()));
                    } else {
                        if (Visibility.PRIVATE.equals(md.getVisibility())) {
                            checkRequiredSize(md, size);
                        }                   
                    }
View Full Code Here

      Long creator_id,
      List all_groups,
      int visibility) {
   
        ModuleDescriptorDao dao= WOJServer.getInstance().getDataService().getModuleDescriptorDao();
        ModuleDescriptor result = dao.getModuleDescriptor(mod_org, mod_name, mod_rev, creator_id, all_groups, Visibility.fromInt(visibility));
        if (result == null) {
            result = newModuleDescriptor(uak, mod_org, mod_name, mod_rev, creator_id, visibility);
        }
        return result;
  }
View Full Code Here

    public void promoteModuleDescriptorVisibility(String mdId, String visibility) {
        LOGGER.debug("Asking promotion of module: " + mdId + " to " + visibility);
    Visibility newVisibility = Visibility.fromString(visibility);
    ModuleDescriptorDao dao = WOJServer.getInstance().getDataService().getModuleDescriptorDao();
    ModuleDescriptor md = dao.getModule(mdId);
    Visibility oldVisibility = md.getVisibility();
    Long oldAccessorId = md.getAccessorId();
    if (oldVisibility != Visibility.SANDBOX) {
      String msg = md.getModuleInfoAsString() + "cannot be promoted it's not in SANDBOX visibility, it may already have been promoted";
      LOGGER.warn(msg);
      throw new IllegalArgumentException(msg);
    } else {
      dao.promoteModuleDescriptorVisibility(md, newVisibility);
      WOJServer.getInstance().getContentService().refreshContentForModuleDescriptorVisibilityPromotion(md, oldAccessorId, oldVisibility);
     
      // Notification
      notifyModulePromoted(WOJServer.getInstance(), md, newVisibility);
          LOGGER.info("Module: " + md.getModuleInfoAsString() + "has been promoted to " + newVisibility);
    }
  }
View Full Code Here

TOP

Related Classes of org.jayasoft.woj.common.model.content.ModuleDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.