Fix av buggar i filerepository
git-svn-id: svn://svn.dsv.su.se/scipro/scipro/trunk@246 73ecded7-942e-4092-bab0-0e58ef0ee984
This commit is contained in:
parent
0cde34029d
commit
43b8f79e8d
src/main/java/se/su/dsv/scipro
data/dataobjects
project/pages
repository
@ -47,7 +47,7 @@ public class FileDescription extends DomainObject implements Comparable<FileDesc
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
private Date lastModified;
|
||||
private Date targetLastModified;
|
||||
private String mimeType;
|
||||
private String identifier;
|
||||
private String path;
|
||||
@ -79,11 +79,11 @@ public class FileDescription extends DomainObject implements Comparable<FileDesc
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public Date getLastModified() {
|
||||
return lastModified;
|
||||
public Date getTargetLastModified() {
|
||||
return targetLastModified;
|
||||
}
|
||||
public void setLastModified(Date lastModified) {
|
||||
this.lastModified = lastModified;
|
||||
public void setTargetLastModified(Date lastModified) {
|
||||
this.targetLastModified = lastModified;
|
||||
}
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
|
@ -1,11 +1,13 @@
|
||||
package se.su.dsv.scipro.project.pages;
|
||||
|
||||
import org.apache.wicket.markup.html.link.Link;
|
||||
import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.basepages.BasePage;
|
||||
import se.su.dsv.scipro.basepages.MenuPage;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FileDescriptionDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.StringResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
@ -21,23 +23,17 @@ import se.su.dsv.scipro.repository.panels.FileLinkPanel;
|
||||
public class ProjectPage extends MenuPage {
|
||||
|
||||
@SpringBean
|
||||
protected ProjectDao projectDao;
|
||||
|
||||
protected ProjectDao projectDao;
|
||||
@SpringBean
|
||||
protected UserDao userDao;
|
||||
|
||||
protected UserDao userDao;
|
||||
@SpringBean
|
||||
StringResourceDao stringResourceDao;
|
||||
protected StringResourceDao stringResourceDao;
|
||||
@SpringBean
|
||||
protected FileDescriptionDao fdDao;
|
||||
|
||||
protected FileChooser fileChooser;
|
||||
|
||||
public ProjectPage() {
|
||||
// for(StringResource sr : stringResourceDao.findAll()){
|
||||
// System.out.println("-------------------------------------------");
|
||||
// System.out.println("Key: "+sr.getKey());
|
||||
// System.out.println("Language: "+sr.getLanguage());
|
||||
// System.out.println("Definition: "+sr.getString());
|
||||
// }
|
||||
|
||||
Project project = projectDao.findAll().get(0);
|
||||
String markupId = "projectFiles";
|
||||
@ -46,11 +42,17 @@ public class ProjectPage extends MenuPage {
|
||||
User user = userDao.load(SciProSession.get().getUser().getId());
|
||||
|
||||
|
||||
FileDescription fileDesc = new FileDescription();
|
||||
fileDesc.setName("testfil.xxx");
|
||||
fileDesc.setIdentifier("db2de02a-0c2f-4915-abc8-c2fe69c7ee00");
|
||||
fileDesc.setSize(-1L);
|
||||
add(new FileLinkPanel("fileLink", fileDesc));
|
||||
// FileDescription fileDesc = new FileDescription();
|
||||
// fileDesc.setName("testfil.xxx");
|
||||
// fileDesc.setIdentifier("db2de02a-0c2f-4915-abc8-c2fe69c7ee00");
|
||||
// fileDesc.setSize(-1L);
|
||||
if(fdDao.countAll() > 0){
|
||||
FileDescription fileDesc = fdDao.findAll().get(0);
|
||||
System.out.println(fileDesc.getPath());
|
||||
add(new FileLinkPanel("fileLink", fileDesc));
|
||||
} else {
|
||||
add(new EmptyPanel("fileLink"));
|
||||
}
|
||||
|
||||
add( fileChooser = FileChooser.createProjectFileChooser("fileChooser", 3, false, project));
|
||||
add(new Link<Void>("testLink"){
|
||||
@ -58,7 +60,9 @@ public class ProjectPage extends MenuPage {
|
||||
|
||||
@Override
|
||||
public void onClick() {
|
||||
System.out.println(fileChooser.getChoices());
|
||||
System.out.println(fileChooser.getChoices());
|
||||
for(FileDescription fd : fileChooser.getChoices())
|
||||
fdDao.save(fd);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -106,7 +106,6 @@ public class FileRepositoryImpl implements FileRepository {
|
||||
try {
|
||||
fileStream.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -173,7 +172,7 @@ public class FileRepositoryImpl implements FileRepository {
|
||||
desc.setPath(file.getPath());
|
||||
desc.setName(file.getName());
|
||||
Node fileNode = file.getNode("jcr:content");
|
||||
desc.setLastModified(fileNode.getProperty("jcr:lastModified").getDate().getTime());
|
||||
desc.setTargetLastModified(fileNode.getProperty("jcr:lastModified").getDate().getTime());
|
||||
desc.setMimeType(fileNode.getProperty("jcr:mimeType").getString());
|
||||
desc.setSize(fileNode.getProperty("jcr:data").getLength());
|
||||
desc.setIdentifier(fileNode.getIdentifier());
|
||||
@ -219,10 +218,13 @@ public class FileRepositoryImpl implements FileRepository {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean existsFileByPath(String name) {
|
||||
public boolean existsFileByPath(String path) {
|
||||
try {
|
||||
if(path == null)
|
||||
return false;
|
||||
path = (path.startsWith("/")?path.substring(1):path);
|
||||
Node root = repositoryManager.getDefaultSession().getRootNode();
|
||||
return root.hasNode(name) && "nt:file".equalsIgnoreCase(root.getNode(name).getPrimaryNodeType().getName()) ;
|
||||
return root.hasNode(path) && "nt:file".equalsIgnoreCase(root.getNode(path).getPrimaryNodeType().getName()) ;
|
||||
} catch (Exception e) {
|
||||
throw new FileStorageException ("Error while checking file", e);
|
||||
}
|
||||
@ -273,7 +275,7 @@ public class FileRepositoryImpl implements FileRepository {
|
||||
FileDescription desc = new FileDescription();
|
||||
desc.setPath(file.getPath());
|
||||
desc.setName(file.getName());
|
||||
desc.setLastModified(file.getNode("jcr:content").getProperty("jcr:lastModified").getDate().getTime());
|
||||
desc.setTargetLastModified(file.getNode("jcr:content").getProperty("jcr:lastModified").getDate().getTime());
|
||||
desc.setMimeType(file.getNode("jcr:content").getProperty("jcr:mimeType").getString());
|
||||
desc.setSize(file.getNode("jcr:content").getProperty("jcr:data").getLength());
|
||||
|
||||
@ -302,7 +304,6 @@ public class FileRepositoryImpl implements FileRepository {
|
||||
this.storeFile(absolutePath + upload.getClientFileName(), mimeString, upload.getInputStream());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}//storeFile
|
||||
@ -485,7 +486,7 @@ public class FileRepositoryImpl implements FileRepository {
|
||||
}
|
||||
@Override
|
||||
public int compare(FileDescription o1, FileDescription o2) {
|
||||
int result = o1.getLastModified().compareTo(o2.getLastModified());
|
||||
int result = o1.getTargetLastModified().compareTo(o2.getTargetLastModified());
|
||||
if(reversed)
|
||||
return -result;
|
||||
else
|
||||
|
@ -298,7 +298,7 @@ public class FileChooser extends Panel {
|
||||
}
|
||||
|
||||
}));
|
||||
inner.add(new Label("modified", df.format(desc.getLastModified())));
|
||||
inner.add(new Label("modified", df.format(desc.getTargetLastModified())));
|
||||
inner.add(new Label("size", fileRepository.formatBytes(desc.getSize())));
|
||||
inner.add(new Label("mimeType", desc.getMimeType()));
|
||||
String userId = "";
|
||||
|
@ -235,8 +235,8 @@ public abstract class AbstractFilePanel extends Panel {
|
||||
}
|
||||
|
||||
}));
|
||||
System.out.println(desc.getPath());
|
||||
inner.add(new Label("modified", df.format(desc.getLastModified())));
|
||||
//System.out.println(desc.getPath());
|
||||
inner.add(new Label("modified", df.format(desc.getTargetLastModified())));
|
||||
inner.add(new Label("size", fileRepository.formatBytes(desc.getSize())));
|
||||
inner.add(new Label("mimeType", desc.getMimeType()));
|
||||
Label uuid = new Label("uuid", desc.getIdentifier());
|
||||
|
Loading…
x
Reference in New Issue
Block a user