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

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


    public ModuleDescriptor[] getModulesSince(final long since) {
        return (ModuleDescriptor[])getTransactionTemplate().execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus status) {
                List l = getObjects("get.since", new Object[] {new Long(since)}, getModuleDescriptorRowMapper());
                for (Iterator iter = l.iterator(); iter.hasNext();) {
                    ModuleDescriptorImpl md = (ModuleDescriptorImpl)iter.next();
                    fillMD5s(md);
                    fillSHA1s(md);
                    fillServers(md);
                }
                ModuleDescriptor[] result = new ModuleDescriptor[l.size()];
View Full Code Here


    public ModuleDescriptor[] getModulesSinceVisibility(final long since, final Visibility v) {
        return (ModuleDescriptor[])getTransactionTemplate().execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus status) {
                List l = getObjects("get.since.visibility", new Object[] {new Long(since), new Integer(v.getId())}, getModuleDescriptorRowMapper());
                for (Iterator iter = l.iterator(); iter.hasNext();) {
                    ModuleDescriptorImpl md = (ModuleDescriptorImpl)iter.next();
                    fillMD5s(md);
                    fillSHA1s(md);
                    fillServers(md);
                }
                ModuleDescriptor[] result = new ModuleDescriptor[l.size()];
View Full Code Here

        setReservedUntil(getConfiguration().getLong(MODULE_ID_RESERVED_UNTIL, -1));
    }
   
    public ModuleDescriptor getModuleDescriptor(UAK uak, Visibility v, String org, String mod, String rev) {
        final ModuleDescriptorDao dao = WOJServer.getInstance().getDataService().getModuleDescriptorDao();
        ModuleDescriptorImpl moduleDescriptor = (ModuleDescriptorImpl)dao.getModuleDescriptor(org, mod, rev, uak.getUserId(), uak.getGroups(), v);
        if (moduleDescriptor == null) {
            return null;
        }
        moduleDescriptor.setSize(WOJServer.getInstance().getContentService().getUsedSpace(moduleDescriptor));
        return moduleDescriptor;
    }
View Full Code Here

                    checkZipFile(zip);
                    LOGGER.debug("Zip file successfully checked");
                    URL contentUrl = new URL("jar:"+zip.toURL()+"!/"+Parameters.MODULE_DESCRIPTOR_FILE_NAME);
                    String xmlContent = IOHelper.readEntirely(new BufferedReader(new InputStreamReader(contentUrl.openStream())));
                    LOGGER.debug("Xml descriptor entirely read");
                    ModuleDescriptorImpl md = (ModuleDescriptorImpl)ServiceProvider.getDefault().getEncodingService().decode(xmlContent);
                    LOGGER.debug("Xml descriptor decoded in a ModuleDescriptor: "+md.getModuleInfoAsString());
                    checkModuleDescriptor(md);
                    LOGGER.debug("ModuleDescriptor successfully checked");

                    // check if user has right to publish at given visibility
                    if (uak.getPublishVisibilityRight().getId() < md.getVisibility().getId()) {
                        LOGGER.error("Impossible to publish to visibility: "+md.getVisibility()+" for user: " +uak.getUserName());
                        throw new UnauthorizedException(uak, "publish to visibility "+md.getVisibility());
                    }
                   
                    long moduleSize = computeModuleSize(zip);
                    md.setSize(moduleSize);

                    if (Visibility.PRIVATE.equals(md.getVisibility())) {
                        checkRequiredSize(md, moduleSize);
                    }                   

                    addModuleDescriptor(uak, zip, md);
                    LOGGER.info("Module: " + md + " added.");
View Full Code Here

                    checkZipFile(zip);
                    LOGGER.debug("Zip file successfully checked");
                    URL contentUrl = new URL("jar:"+zip.toURL()+"!/"+Parameters.MODULE_DESCRIPTOR_FILE_NAME);
                    String xmlContent = IOHelper.readEntirely(new BufferedReader(new InputStreamReader(contentUrl.openStream())));
                    LOGGER.debug("Xml descriptor entirely read");
                    ModuleDescriptorImpl md = (ModuleDescriptorImpl)ServiceProvider.getDefault().getEncodingService().decode(xmlContent);
                    LOGGER.debug("Xml descriptor decoded in a ModuleDescriptor: "+md.getModuleInfoAsString());
                    checkModuleDescriptor(md);
                    LOGGER.debug("ModuleDescriptor successfully checked");
                    // check if user has right to publish at given visibility
                    if (uak.getPublishVisibilityRight().getId() < md.getVisibility().getId()) {
                        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);
                        }                   
                    }
                    md.setSize(size);
                    LOGGER.debug("adding "+md.getModuleInfoAsString());
                    addModuleDescriptor(uak, zip, md);
                    LOGGER.info("Module: " + md + " replaced.");
                } catch (IOException e) {
                    status.setRollbackOnly();
                    LOGGER.info("Cannot replace module for zip file : " + zip, e);
View Full Code Here

       
    // Ask for moduleDesc to ModuleManagementService.
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug("Asking for ModuleDescriptor: " + modOrg + "|" + modName + "|" + modRev + " visibility: " + Visibility.fromInt(visibility));
        }
        ModuleDescriptorImpl mDesc;
        if (checkIntegrity) {
            mDesc = (ModuleDescriptorImpl)askForModuleDescriptor(uak, modOrg, modName, modRev, uak.getUserId(), uak.getGroups(), visibility);
        } else {  
            // we don't have to check if the module exist or not here: we always create a new one, but which is not stored yet
            // (integrity is always checked when the module is actually added)
            mDesc = (ModuleDescriptorImpl)newModuleDescriptor(uak, modOrg, modName, modRev, uak.getUserId(), visibility);
        }

    // test for already existing module
    if (mDesc.isNew()) {
          LOGGER.debug("ModuleDescriptor isn't in DB. Setting given values ...");
      // It is not un DB (there is no module desc with same org, name, rev with the same visibility)
      // We set wanted values
      mDesc.setMD5s(md5s);
      mDesc.setSHA1s(sha1s);
      LOGGER.debug(md5s.size() + " MD5 added and " + sha1s.size() + " SHA1 added.");
      mDesc.setReplicated(replicated);
            mDesc.setHasSources(hasSource);
            mDesc.setHasJavadoc(hasJavadoc);
      LOGGER.debug("Source for module: " + hasSource + ". Javadoc for module: " + hasJavadoc);
            mDesc.setHomeURL(homeURL);
          if (visibility == Visibility.PUBLIC.getId()) {
            // Public visibility => accessorId = null.
            mDesc.setAccessorId(null);
          } else if (groupPublication && !uak.getGroups().isEmpty()) {
            // submitter decided to make a group publication
            // assessor Id = submitter groupId = First of allGroupsList
            // If submitter does not belong to any group see else comment
            mDesc.setAccessorId(Long.valueOf(uak.getGroups().get(0).toString()));
          } else {
            // Submitter want a unique access to the module
            // accessorId = user_id
            mDesc.setAccessorId(uak.getUserId());           
          }
    } else {
      String msg = modOrg + " " + modName + " " + modRev + " already exists in " + Visibility.fromInt(visibility);
      if (visibility != Visibility.PUBLIC.getId()) {
        msg += " for " + uak.getUserName();
View Full Code Here

        if (size <= 0) {
            size = IOHelper.getTotalSize(new File(getBaseDir(md))) / 1024;
            LOGGER.debug("computed size of "+md.getModuleInfoAsString()+": "+size);
            if (md instanceof ModuleDescriptorImpl) {
                LOGGER.debug("storing size of "+md.getModuleInfoAsString()+": "+size);
                ModuleDescriptorImpl mdimpl = (ModuleDescriptorImpl)md;
                mdimpl.setSize(size);
                ModuleDescriptorDao dao = WOJServer.getInstance().getDataService().getModuleDescriptorDao();
                dao.update(mdimpl);
            }
        }
        return size;
View Full Code Here

TOP

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

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.