<field name="id" type="string" indexed="true" stored="true" required="true" /> \r
<field name="name" type="text" indexed="true" stored="true" required="true"/>\r
<field name="tag" type="text" indexed="true" stored="true" multiValued="true"/>\r
+ <field name="owner" type="long" indexed="true" stored="true" required="true"/>\r
+ <field name="ureaders" type="long" indexed="true" stored="true" multiValued="true"/>\r
+ <field name="greaders" type="long" indexed="true" stored="true" multiValued="true"/>\r
+ <field name="public" type="boolean" indexed="true" stored="true" required="true"/>\r
<!-- <field name="sku" type="textTight" indexed="true" stored="true" omitNorms="true"/>\r
<field name="name" type="textgen" indexed="true" stored="true"/>\r
<field name="alphaNameSort" type="alphaOnlySort" indexed="true" stored="false"/>\r
void removeUserClass(UserClassDTO userClass) throws RpcException,ObjectNotFoundException;
void removeUser(Long userId) throws RpcException,ObjectNotFoundException,InsufficientPermissionsException;
+
+ void fixSharedFlagForAllFoldersAndFiles() throws RpcException;
}
void removeUserClass(UserClassDTO userClass, AsyncCallback<Void> callback);
void removeUser(Long userId, AsyncCallback<Void> callback);
+
+ void fixSharedFlagForAllFoldersAndFiles( AsyncCallback<Void> callback);
}
</g:ScrollPanel>
</g:tab>
+
+ <g:tab>
+ <g:header>Operations</g:header>
+ <g:ScrollPanel>
+ <adminui:OperationsPanel></adminui:OperationsPanel>
+ </g:ScrollPanel>
+
+ </g:tab>
</g:TabLayoutPanel>
--- /dev/null
+/*
+ * Copyright 2010 Electronic Business Systems Ltd.
+ *
+ * This file is part of GSS.
+ *
+ * GSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GSS. If not, see <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.admin.client.ui;
+
+import gr.ebs.gss.admin.client.TwoAdmin;
+import gr.ebs.gss.admin.client.ui.FilesPanel.UserPanelUiBinder;
+import gr.ebs.gss.server.domain.dto.FileBodyDTO;
+import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
+import gr.ebs.gss.server.domain.dto.PermissionDTO;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.KeyPressEvent;
+import com.google.gwt.event.dom.client.KeyPressHandler;
+import com.google.gwt.gen2.table.event.client.RowSelectionEvent;
+import com.google.gwt.gen2.table.event.client.RowSelectionHandler;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.uibinder.client.UiHandler;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.DeferredCommand;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Grid;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+
+
+/**
+ * @author kman
+ *
+ */
+public class OperationsPanel extends Composite {
+
+ private static UserPanelUiBinder uiBinder = GWT
+ .create(UserPanelUiBinder.class);
+
+ interface UserPanelUiBinder extends UiBinder<Widget, OperationsPanel> {
+ }
+
+
+
+
+ @UiField Button fixButton;
+
+ public OperationsPanel() {
+
+
+ initWidget(uiBinder.createAndBindUi(this));
+
+
+ }
+
+ @UiHandler("fixButton")
+ void handleClick(@SuppressWarnings("unused") ClickEvent e){
+ DeferredCommand.addCommand(new Command() {
+
+ @Override
+ public void execute() {
+ TwoAdmin.get().showLoadingBox();
+ TwoAdmin.get().getAdminService().fixSharedFlagForAllFoldersAndFiles( new AsyncCallback<Void>() {
+
+ @Override
+ public void onSuccess(Void result) {
+ TwoAdmin.get().hideLoadingBox();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ GWT.log("Error Fixing Permissions", caught);
+ TwoAdmin.get().hideLoadingBox();
+ TwoAdmin.get().showErrorBox("Error Fixing Permissions");
+
+ }
+ });
+
+ }
+ });
+ }
+
+
+
+
+
+}
--- /dev/null
+<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
+<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
+ xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:adminui='urn:import:gr.ebs.gss.admin.client.ui'
+ xmlns:dp="urn:import:com.google.gwt.user.datepicker.client"
+ >
+ <ui:style>
+
+ </ui:style>
+
+ <g:VerticalPanel addStyleNames="Gmnuri3D" width="100%">
+ <g:HTMLPanel>
+ <div>
+ <h3>Administrative Operations</h3>
+ </div>
+ </g:HTMLPanel>
+ <g:HorizontalPanel spacing="3">
+ <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
+ <g:HTML>Fix Sharing flag:</g:HTML>
+ </g:cell>
+
+ <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
+ <g:Button ui:field="fixButton">Search</g:Button>
+ </g:cell>
+
+ </g:HorizontalPanel>
+
+
+
+ </g:VerticalPanel>
+
+</ui:UiBinder>
\ No newline at end of file
if(uname==null)
uname = ((DnDTreeItem)folders.getSharesItem()).getOthersResource().getUsernameOfUri(otherUser.getOtherUserResource().getUri());
if(uname != null)
- shared = file.isShared();
+ shared = file.getShared();
}
}
else
- shared = file.isShared();
+ shared = file.getShared();
if (mimetype == null)
return shared ? AbstractImagePrototype.create(images.documentShared()) : AbstractImagePrototype.create(images.document());
mimetype = mimetype.toLowerCase();
public void onComplete() {
folderItem.setUserObject(getResult());
if(GSS.get().getFolders().isFileItem(folderItem)){
- String[] filePaths = new String[folderItem.getFolderResource().getFilePaths().size()];
- int c=0;
- for(String fpath : folderItem.getFolderResource().getFilePaths()){
- filePaths[c] = fpath + "?" + Math.random();
- c++;
- }
- MultipleHeadCommand<FileResource> getFiles = new MultipleHeadCommand<FileResource>(FileResource.class, filePaths, folderItem.getFolderResource().getFileCache()){
-
- @Override
- public void onComplete(){
- List<FileResource> result = getResult();
+
//remove random from path
- for(FileResource r : result){
+ for(FileResource r : folderItem.getFolderResource().getFiles()){
String p = r.getUri();
int indexOfQuestionMark = p.lastIndexOf('?');
if(indexOfQuestionMark>0)
r.setUri(p.substring(0, indexOfQuestionMark));
GWT.log("FETCHED:"+r.getLastModifiedSince(), null);
}
- folderItem.getFolderResource().setFiles(result);
folderItem.getFolderResource().setFilesExpanded(true);
updateFileCache(clearSelection, newFilename);
}
-
- @Override
- public void onError(String p, Throwable throwable) {
- if(throwable instanceof RestException)
- GSS.get().displayError("Unable to retrieve file details:"+((RestException)throwable).getHttpStatusText());
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- GSS.get().displayError("Unable to fetch files for folder " + folderItem.getFolderResource().getName());
- }
-
- };
- DeferredCommand.addCommand(getFiles);
- }
else
updateFileCache(clearSelection, newFilename);
}
@Override
public void onComplete() {
folderItem.setUserObject(getResult());
- updateFileCache(clearSelection, newFilename);
- String[] filePaths = new String[folderItem.getSharedResource().getFilePaths().size()];
- int c=0;
- for(String fpath : folderItem.getSharedResource().getFilePaths()){
- filePaths[c] = fpath + "?" + Math.random();
- c++;
- }
- MultipleHeadCommand<FileResource> getFiles = new MultipleHeadCommand<FileResource>(FileResource.class, filePaths, folderItem.getSharedResource().getFileCache()){
-
- @Override
- public void onComplete(){
- List<FileResource> result = getResult();
- //remove random from path
- for(FileResource r : result){
+ for(FileResource r : folderItem.getSharedResource().getFiles()){
String p = r.getUri();
int indexOfQuestionMark = p.lastIndexOf('?');
if(indexOfQuestionMark>0)
r.setUri(p.substring(0, indexOfQuestionMark));
GWT.log("FETCHED:"+r.getLastModifiedSince(), null);
}
- folderItem.getSharedResource().setFiles(result);
folderItem.getSharedResource().setFilesExpanded(true);
updateFileCache(clearSelection, newFilename);
- }
-
- @Override
- public void onError(String p, Throwable throwable) {
- if(throwable instanceof RestException)
- GSS.get().displayError("Unable to retrieve file details:"+((RestException)throwable).getHttpStatusText());
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- GSS.get().displayError("Unable to fetch files for folder " + folderItem.getFolderResource().getName());
- }
-
- };
- DeferredCommand.addCommand(getFiles);
+
}
@Override
@Override
public void onComplete() {
folderItem.setUserObject(getResult());
- updateFileCache(clearSelection, newFilename);
- String[] filePaths = new String[folderItem.getOtherUserResource().getFilePaths().size()];
- int c=0;
- for(String fpath : folderItem.getOtherUserResource().getFilePaths()){
- filePaths[c] = fpath + "?" + Math.random();
- c++;
- }
- MultipleHeadCommand<FileResource> getFiles = new MultipleHeadCommand<FileResource>(FileResource.class, filePaths, folderItem.getOtherUserResource().getFileCache()){
-
- @Override
- public void onComplete(){
- List<FileResource> result = getResult();
- //remove random from path
- for(FileResource r : result){
+ //updateFileCache(clearSelection, newFilename);
+ for(FileResource r : folderItem.getOtherUserResource().getFiles()){
String p = r.getUri();
int indexOfQuestionMark = p.lastIndexOf('?');
if(indexOfQuestionMark>0)
r.setUri(p.substring(0, indexOfQuestionMark));
GWT.log("FETCHED:"+r.getLastModifiedSince(), null);
}
- folderItem.getOtherUserResource().setFiles(result);
folderItem.getOtherUserResource().setFilesExpanded(true);
updateFileCache(clearSelection, newFilename);
- }
-
- @Override
- public void onError(String p, Throwable throwable) {
- if(throwable instanceof RestException)
- GSS.get().displayError("Unable to retrieve file details:"+((RestException)throwable).getHttpStatusText());
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- GSS.get().displayError("Unable to fetch files for folder " + folderItem.getFolderResource().getName());
- }
-
- };
- DeferredCommand.addCommand(getFiles);
+
}
@Override
String path;
String folderName;
-
+ Boolean shared;
+
+
+ /**
+ * Retrieve the shared.
+ *
+ * @return the shared
+ */
+ public Boolean getShared() {
+ return shared;
+ }
+
+
+ /**
+ * Modify the shared.
+ *
+ * @param shared the shared to set
+ */
+ public void setShared(Boolean shared) {
+ this.shared = shared;
+ }
+
/**
* Retrieve the folderName.
*
versioned = unmarshallBoolean(metadata, "versioned");
createdBy = unmarshallString(metadata, "createdBy");
modifiedBy = unmarshallString(metadata, "modifiedBy");
-
+ setShared(unmarshallBoolean(metadata, "shared"));
if (metadata.get("version") != null)
version = new Integer(metadata.get("version").toString());
private boolean filesExpanded=false;
boolean readForAll;
+
+ Boolean shared;
+
+
+ /**
+ * Retrieve the shared.
+ *
+ * @return the shared
+ */
+ public Boolean getShared() {
+ return shared;
+ }
+
+
+ /**
+ * Modify the shared.
+ *
+ * @param shared the shared to set
+ */
+ public void setShared(Boolean shared) {
+ this.shared = shared;
+ }
/**
* Modify the parentName.
createdBy = unmarshallString(json, "createdBy");
modifiedBy = unmarshallString(json, "modifiedBy");
deleted = unmarshallBoolean(json, "deleted");
+ shared = unmarshallBoolean(json, "shared");
readForAll = unmarshallBoolean(json, "readForAll");
if (deleted)
GWT.log("FOUND A DELETED FOLDER:" + name, null);
String fowner = unmarshallString(fo, "owner");
String fcontent = unmarshallString(fo, "content");
String fpath = unmarshallString(fo, "path");
+ Boolean fshared = unmarshallBoolean(fo, "shared");
fpath = URL.decodeComponent(fpath);
Integer fversion = null;
if (fo.get("version") != null)
fs.setVersion(fversion);
fs.setContentLength(fsize);
fs.setDeleted(fdeleted);
+ fs.setShared(fshared);
fs.setCreationDate(fcreationDate);
fs.setModificationDate(fmodificationDate);
fs.setContentType(fcontent);
fs.setDeleted(fdeleted);
fs.setCreationDate(fcreationDate);
fs.setModificationDate(fmodificationDate);
+ fs.setShared(unmarshallBoolean(fo,"shared"));
fs.setContentType(fcontent);
files.add(fs);
}
fs.setVersion(fversion);
fs.setContentLength(fsize);
fs.setDeleted(fdeleted);
+ fs.setShared(unmarshallBoolean(fo,"shared"));
fs.setCreationDate(fcreationDate);
fs.setModificationDate(fmodificationDate);
fs.setContentType(fcontent);
getService().removeUser(userId);
}
+
+ @Override
+ public void fixSharedFlagForAllFoldersAndFiles() throws RpcException {
+ getService().fixSharedFlagForAllFoldersAndFiles();
+ }
}
import javax.persistence.ManyToOne;\r
import javax.persistence.OneToMany;\r
import javax.persistence.OrderBy;\r
+import javax.persistence.PrePersist;\r
+import javax.persistence.PreUpdate;\r
import javax.persistence.Table;\r
import javax.persistence.UniqueConstraint;\r
import javax.persistence.Version;\r
@OneToMany(cascade = CascadeType.ALL)\r
private Set<Permission> permissions = new HashSet<Permission>();\r
\r
+ @Column(columnDefinition=" boolean DEFAULT false")\r
+ private Boolean shared;\r
/**\r
* Retrieve the ID.\r
*\r
f.setMimeType(currentBody.getMimeType());\r
f.setDeleted(deleted);\r
f.setReadForAll(readForAll);\r
+ f.setShared(getShared());\r
List<String> tags = new ArrayList<String>();\r
for (FileTag tag : fileTags)\r
tags.add(tag.getTag());\r
return owner.getUsername() + PATH_FILES + getPath();\r
}\r
\r
+ /**\r
+ * Retrieve the shared.\r
+ *\r
+ * @return the shared\r
+ */\r
+ public Boolean getShared() {\r
+ if(shared==null)\r
+ return false;\r
+ return shared;\r
+ }\r
+
+
+ /**\r
+ * Modify the shared.\r
+ *\r
+ * @param shared the shared to set\r
+ */\r
+ public void setShared(Boolean shared) {\r
+ this.shared = shared;\r
+ }\r
+ \r
+ @PrePersist\r
+ @PreUpdate\r
+ private void fixSharedFlag(){\r
+ if(isReadForAll()||getPermissions().size()>1)\r
+ shared=true;\r
+ else\r
+ shared=false;\r
+ }\r
}\r
\r
import javax.persistence.ManyToOne;\r
import javax.persistence.OneToMany;\r
import javax.persistence.OrderBy;\r
+import javax.persistence.PrePersist;\r
+import javax.persistence.PreUpdate;\r
import javax.persistence.Version;\r
\r
import org.hibernate.annotations.Cache;\r
*/\r
@Column(columnDefinition=" boolean DEFAULT false")\r
private boolean readForAll=false;\r
+ \r
+ @Column(columnDefinition=" boolean DEFAULT false")\r
+ private Boolean shared;\r
\r
/**\r
* Retrieve the ID.\r
f.setAuditInfo(auditInfo.getDTO());\r
f.setDeleted(deleted);\r
f.setReadForAll(readForAll);\r
+ f.setShared(getShared());\r
if (parent != null)\r
f.setParent(parent.getDTO(0));\r
for (Folder subfolder : subfolders)\r
public boolean isReadForAll() {\r
return readForAll;\r
}\r
+ \r
+ /**\r
+ * Retrieve the shared.\r
+ *\r
+ * @return the shared\r
+ */\r
+ public Boolean getShared() {\r
+ if(shared==null)\r
+ return false;\r
+ return shared;\r
+ }\r
+ \r
+ \r
+ /**\r
+ * Modify the shared.\r
+ *\r
+ * @param shared the shared to set\r
+ */\r
+ public void setShared(Boolean shared) {\r
+ this.shared = shared;\r
+ }\r
+ \r
+ @PrePersist\r
+ @PreUpdate\r
+ private void fixSharedFlag(){\r
+ if(isReadForAll()||getPermissions().size()>1)\r
+ shared=true;\r
+ else\r
+ shared=false;\r
+ }\r
\r
/**\r
* Retrieve the URI for this resource, relative to the REST API root URI.\r
import java.util.List;
import java.util.Set;
+import javax.persistence.Column;
+
import com.google.gwt.i18n.client.NumberFormat;
/**
* Anyone can read this file?
*/
private boolean readForAll=false;
+
+
+ private Boolean shared=false;
/**
* @return the id
*/
public Set<PermissionDTO> getPermissions() {
return permissions;
}
+
+ /**
+ * Retrieve the shared.
+ *
+ * @return the shared
+ */
+ public Boolean getShared() {
+ return shared;
+ }
+
+
+ /**
+ * Modify the shared.
+ *
+ * @param shared the shared to set
+ */
+ public void setShared(Boolean shared) {
+ this.shared = shared;
+ }
}
* Anyone can read this folder?
*/
private boolean readForAll=false;
+
+ private Boolean shared=false;
/**
* @return the id
public boolean isReadForAll() {
return readForAll;
}
-
+
+
+ /**
+ * Retrieve the shared.
+ *
+ * @return the shared
+ */
+ public Boolean getShared() {
+ return shared;
+ }
+
+
+ /**
+ * Modify the shared.
+ *
+ * @param shared the shared to set
+ */
+ public void setShared(Boolean shared) {
+ this.shared = shared;
+ }
}
public void removeUser(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
+ /**
+ *
+ */
+ void fixSharedFlagForAllFoldersAndFiles();
+
}
}
}
}
+ @Override
+ public void fixSharedFlagForAllFoldersAndFiles(){
+ dao.fixSharedFlagForAllFoldersAndFiles();
+ }
}
touchParentFolders(parent, user, new Date());
// Re-index the file if it was modified.
- if (name != null || tagSet != null)
+ if (name != null || tagSet != null || (permissions != null && !permissions.isEmpty()) || readForAll != null)
indexFile(fileId, false);
}
List<FileHeader> result = new ArrayList<FileHeader>();
try {
CommonsHttpSolrServer solr = new CommonsHttpSolrServer(getConfiguration().getString("solr.url"));
- SolrQuery solrQuery = new SolrQuery(escapeCharacters(normalizeSearchQuery(query)));
+ List<Group> groups = dao.getGroupsContainingUser(userId);
+ String constructedQuery = escapeCharacters(normalizeSearchQuery(query)) + " AND (public: true OR ureaders: " + userId;
+ if (!groups.isEmpty()) {
+ constructedQuery += " OR (";
+ for (int i=0; i<groups.size(); i++) {
+ Group g = groups.get(i);
+ constructedQuery += "greaders :" + g.getId();
+ if (i < groups.size() - 1)
+ constructedQuery += " OR ";
+ }
+ constructedQuery += ")";
+ }
+ constructedQuery += ")";
+ SolrQuery solrQuery = new SolrQuery(constructedQuery);
solrQuery.setRows(maxRows);
long startTime = System.currentTimeMillis();
QueryResponse response = solr.query(solrQuery);
Long id = Long.valueOf((String) d.getFieldValue("id"));
try {
FileHeader f = dao.getEntityById(FileHeader.class, id);
- if (f.hasReadPermission(user))
- result.add(f);
+ result.add(f);
} catch (ObjectNotFoundException e) {
logger.warn("Search result id " + id + " cannot be found", e);
}
}
stopTime = System.currentTimeMillis();
- logger.info("Permission checks: " + (stopTime - startTime));
+ logger.info("File loads: " + (stopTime - startTime));
} catch (MalformedURLException e) {
logger.error(e);
throw new EJBException(e);
}
if (i % 100 == 0) {
solr.commit();
- logger.debug("Sent commit to solr at file " + i);
+ logger.info("Sent commit to solr at file " + i);
}
solr.optimize();
solr.commit();
for (FileTag t : file.getFileTags()) {
solrRequest.getParams().add("literal.tag", t.getTag());
}
+ for (Permission p : file.getPermissions()) {
+ if (p.getRead()) {
+ if (p.getUser() != null)
+ solrRequest.setParam("literal.ureaders", p.getUser().getId().toString());
+ else if (p.getGroup() != null)
+ solrRequest.setParam("literal.greaders", p.getGroup().getId().toString());
+ }
+ }
+ solrRequest.setParam("literal.owner", file.getOwner().getId().toString());
+ solrRequest.setParam("literal.public", String.valueOf(file.isReadForAll()));
File fsFile = new File(body.getStoredFilePath());
solrRequest.addFile(fsFile);
-// solrRequest.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
try {
solr.request(solrRequest);
}
catch (SolrException e) {
- logger.warn("File " + id + " failed with " + e.getLocalizedMessage() + ". Retrying without the file");
+ logger.warn("File " + id + " failed with SolrException: " + e.getLocalizedMessage() + ". Retrying without the file");
//Let 's try without the file
sendMetaDataOnly(solr, file);
}
catch (NullPointerException e) {
- logger.warn("File " + id + " failed with " + e.getLocalizedMessage() + ". Retrying without the file");
+ logger.warn("File " + id + " failed with NullPointerException: " + e.getLocalizedMessage() + ". Retrying without the file");
//Let 's try without the file
sendMetaDataOnly(solr, file);
}
catch (SolrServerException e) {
- logger.warn("File " + id + " failed with " + e.getLocalizedMessage() + ". Retrying without the file");
+ logger.warn("File " + id + " failed with SolrServerException: " + e.getLocalizedMessage() + ". Retrying without the file");
//Let 's try without the file
sendMetaDataOnly(solr, file);
}
for (FileTag t : file.getFileTags()) {
solrDoc.addField("tag", t.getTag());
}
+ for (Permission p : file.getPermissions()) {
+ if (p.getRead()) {
+ if (p.getUser() != null)
+ solrDoc.addField("ureaders", p.getUser().getId());
+ else if (p.getGroup() != null)
+ solrDoc.addField("greaders", p.getGroup().getId());
+ }
+ }
+ solrDoc.addField("owner", file.getOwner().getId());
+ solrDoc.addField("public", file.isReadForAll());
solr.add(solrDoc);
}
*/
public List<UserLogin> getLoginsForUser (Long userId);
+ /**
+ *
+ */
+ void fixSharedFlagForAllFoldersAndFiles();
+
}
public FileHeader getFileForIndexing(Long id) throws ObjectNotFoundException {
FileHeader h = getEntityById(FileHeader.class, id);
h.getFileTags().size();
+ h.getPermissions().size();
return h;
}
.getResultList();
return res;
}
+
+ @Override
+ public void fixSharedFlagForAllFoldersAndFiles(){
+ List<Folder> folders = manager.createQuery("select f from Folder f").getResultList();
+ for(Folder f : folders){
+ if(f.isReadForAll()||f.getPermissions().size()>1){
+ f.setShared(true);
+ update(f);
+ }
+ }
+ List<FileHeader> files = manager.createQuery("select f from FileHeader f").getResultList();
+ for(FileHeader f : files){
+ if(f.isReadForAll()||f.getPermissions().size()>1){
+ f.setShared(true);
+ update(f);
+ }
+ }
+ }
}
put("createdBy", folder.getAuditInfo().getCreatedBy().getUsername()).
put("creationDate", folder.getAuditInfo().getCreationDate().getTime()).
put("deleted", folder.isDeleted()).
+ put("shared", folder.getShared()).
put("readForAll", folder.isReadForAll());
if (folder.getAuditInfo().getModifiedBy() != null)
put("version", f.getVersion()).
put("content", f.getMimeType()).
put("size", f.getFileSize()).
+ put("shared", f.getShared()).
+ put("versioned",f.isVersioned()).
put("creationDate", f.getAuditInfo().getCreationDate().getTime()).
put("path", f.getFolder().getPath()).
put("uri", getApiRoot() + f.getURI());
put("versioned", file.isVersioned()).
put("version", oldBody != null ? oldBody.getVersion() : file.getVersion()).
put("readForAll", file.isReadForAll()).
+ put("shared", file.getShared()).
put("tags", renderJson(file.getTags())).
put("path", file.getFolder().getPath()).
put("uri", getApiRoot() + file.getURI()).
put("creationDate", f.getAuditInfo().getCreationDate().getTime()).
put("modificationDate", f.getAuditInfo().getModificationDate().getTime()).
put("path", f.getFolder().getPath()).
+ put("shared", f.getShared()).
+ put("versioned",f.isVersioned()).
put("uri", getApiRoot() + f.getURI());
files.add(j);
}
put("size", f.getFileSize()).
put("content", f.getMimeType()).
put("path", f.getFolder().getPath()).
+ put("shared", f.getShared()).
+ put("versioned",f.isVersioned()).
put("creationDate", f.getAuditInfo().getCreationDate().getTime()).
put("modificationDate", f.getAuditInfo().getModificationDate().getTime()).
put("uri", getApiRoot() + f.getURI());